tested pp-postconditions

This commit is contained in:
Lorenzo Caminiti 2015-03-04 19:43:21 -08:00
parent 15e24b1915
commit 13d2570cb9
9 changed files with 12872 additions and 317 deletions

View File

@ -6,6 +6,7 @@ for root, dirs, files in os.walk('.'):
for file in fnmatch.filter(files, '*-generate.py'):
cwd = os.getcwd()
os.chdir(root)
print "In directory:", root
os.system("python " + file)
os.chdir(cwd)

View File

@ -134,16 +134,6 @@ for entry in entries:
#include <boost/contract/ext_/preprocessor/keyword/utility/is.hpp>
#include <boost/contract/ext_/preprocessor/keyword/utility/remove.hpp>
/* PRIVATE */
// Must expand to a single comma `,` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_COMMA{2} ,
#define {2}BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_COMMA ,
// Must expand to empty `` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_EMPTY{2}
#define {2}BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_EMPTY
/* PUBLIC */
// Precondition: tokens must start with a token concatenable to a macro name
@ -170,6 +160,16 @@ for entry in entries:
BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_BACK( \\
BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_EMPTY, tokens)
/* PRIVATE */
// Must expand to a single comma `,` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_COMMA{2} ,
#define {2}BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_COMMA ,
// Must expand to empty `` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_EMPTY{2}
#define {2}BOOST_CONTRACT_EXT_PP_KEYWORD_{1}_CAT_TO_EMPTY
#endif // #include guard
'''.format(script, keyword.upper(), keyword.lower()))

View File

@ -3,6 +3,7 @@
#define BOOST_CONTRACT_EXT_PP_PARENTHESIZE_HPP_
#include <boost/contract/ext_/preprocessor/paren/has.hpp>
#include <boost/preprocessor/control/iif.hpp>
/* PUBLIC */

View File

@ -2,19 +2,8 @@
#ifndef BOOST_CONTRACT_EXT_PP_NIL_HPP_
#define BOOST_CONTRACT_EXT_PP_NIL_HPP_
// Adapted from "boost/contract/ext_/preprocessor/*.hpp".
#include <boost/contract/ext_/preprocessor/keyword/utility/is.hpp>
#include <boost/preprocessor/cat.hpp>
/* PRIVATE */
// Must expand to a single comma `,` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_COMMABOOST_PP_NIL ,
#define BOOST_PP_NILBOOST_CONTRACT_EXT_PP_NIL_CAT_TO_COMMA ,
// Must expand to empty `` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTYBOOST_PP_NIL
#define BOOST_PP_NILBOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTY
#include <boost/contract/ext_/preprocessor/keyword/utility/remove.hpp>
/* PUBLIC */
@ -22,7 +11,7 @@
// Boost.Preprocessor doc indicates the purpose of BOOST_PP_NIL is to NOT be
// a macro (i.e., to be #undefined, according with its usage here).
#ifdef BOOST_PP_NIL
# error "#definition of reserved macro name"
# error "reserved macro name must not be #defined"
#endif
// Precondition: tokens must start with a token concatenable to a macro name
@ -40,12 +29,23 @@
// Precondition: tokens must start with `BOOST_PP_NIL` (this can be
// checked with `..._IS_NIL_FRONT` macro above).
#define BOOST_CONTRACT_EXT_PP_NIL_REMOVE_FRONT(tokens) \
BOOST_PP_CAT(BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTY, tokens)
BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_FRONT( \
BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTY, tokens)
// Precondition: tokens must end with `BOOST_PP_NIL` (this can be
// checked with `..._IS_NIL_BACK` macro above).
#define BOOST_CONTRACT_EXT_PP_NIL_REMOVE_BACK(tokens) \
BOOST_PP_CAT(tokens, BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTY)
BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_BACK( \
BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTY, tokens)
/* PRIVATE */
// Must expand to a single comma `,` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_COMMABOOST_PP_NIL ,
#define BOOST_PP_NILBOOST_CONTRACT_EXT_PP_NIL_CAT_TO_COMMA ,
// Must expand to empty `` (not local macros, do not #undefine).
#define BOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTYBOOST_PP_NIL
#define BOOST_PP_NILBOOST_CONTRACT_EXT_PP_NIL_CAT_TO_EMPTY
#endif // #include guard

View File

@ -0,0 +1,37 @@
#ifndef BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM_HPP_
#define BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM_HPP_
#include <boost/contract/ext_/preprocessor/paren/has.hpp>
#include <boost/preprocessor/tuple/rem.hpp>
#include <boost/preprocessor/tuple/size.hpp>
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/control/expr_iif.hpp>
#include <boost/preprocessor/comparison/equal.hpp>
#include <boost/preprocessor/facilities/expand.hpp>
/* PUBLIC */
// TODO: Use this macro in all tests that need to remove type's parenthesis.
// Expand `(x)` to x, but `x` (no parenthesis) to `x` and `(x, ...)` (tuple
// size > `) to `(x, ...)`.
#define BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM(tuple) \
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_HAS_PAREN(tuple), \
BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM_ \
, \
BOOST_PP_TUPLE_REM(1) \
)(tuple)
/* PRIVATE */
#define BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM_(tuple) \
BOOST_PP_EXPAND( \
BOOST_PP_EXPR_IIF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(tuple), 1), \
BOOST_PP_TUPLE_REM(1) \
) \
tuple \
)
#endif // #include guard

View File

@ -0,0 +1,264 @@
import os
import sys
LIMIT = 64
def code():
result = ''
for n in range(1, LIMIT + 1):
result = result + '''
/* PUBLIC ({0}) */
#define BOOST_CONTRACT_TEST_AUX_PP_ASSERTIONS_S_{0}( \\
s, assertions, assertion_traits) \\
BOOST_CONTRACT_TEST_AUX_PP_ASSERTIONS_S_{0}_(s, assertions, \\
BOOST_CONTRACT_TEST_AUX_PP_ASSERTION_S_{0}_, assertion_traits)
#define BOOST_CONTRACT_TEST_AUX_PP_POST_ASSERTIONS_S_{0}( \\
s, assertions, assertion_traits) \\
BOOST_CONTRACT_TEST_AUX_PP_ASSERTIONS_S_{0}_(s, assertions, \\
BOOST_CONTRACT_TEST_AUX_PP_POST_ASSERTION_S_{0}_, assertion_traits)
/* PRIVATE ({0}) */
#define BOOST_CONTRACT_TEST_AUX_PP_ASSERTIONS_S_{0}_( \\
s, assertions, assertion_macro, assertion_traits) \\
( \\
BOOST_PP_TUPLE_REM_CTOR(assertions) \\
assertion_macro(s, assertion_traits) \\
)
#define BOOST_CONTRACT_TEST_AUX_PP_ASSERTION_S_{0}_(s, traits) \\
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_KEYWORD_IS_NAMESPACE_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_NAMESPACE_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_KEYWORD_IS_USING_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_USING_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_KEYWORD_IS_TYPEDEF_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_TYPEDEF_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_KEYWORD_IS_CONST_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_CONST_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_KEYWORD_IS_IF_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_STATIC_IF_ASSERTION_TRAITS_IS( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_STATIC_IF_ASSERTION_S_{0}_ \\
, \\
BOOST_CONTRACT_TEST_AUX_PP_BOOL_ASSERTION_S_{0}_ \\
))))))(s, traits)
#define BOOST_CONTRACT_TEST_AUX_PP_POST_ASSERTION_S_{0}_(s, traits) \\
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_KEYWORD_IS_RETURN_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_RETURN_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_OLDOF_ASSERTION_TRAITS_IS( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_OLDOF_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_KEYWORD_IS_IF_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_POST_IF_ASSERTION_S_{0}_ \\
, BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_STATIC_IF_ASSERTION_TRAITS_IS( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND(traits)), \\
BOOST_CONTRACT_TEST_AUX_PP_POST_STATIC_IF_ASSERTION_S_{0}_ \\
, \\
BOOST_CONTRACT_TEST_AUX_PP_ASSERTION_S_{0}_ \\
))))(s, traits)
#define BOOST_CONTRACT_TEST_AUX_PP_NAMESPACE_ASSERTION_S_{0}_(s, traits) \\
namespace \\
(BOOST_CONTRACT_EXT_PP_NAMESPACE_ASSERTION_TRAITS_NEW_NAME(traits)) \\
as BOOST_CONTRACT_EXT_PP_NAMESPACE_ASSERTION_TRAITS_NAME(traits) \\
,
#define BOOST_CONTRACT_TEST_AUX_PP_USING_ASSERTION_S_{0}_(s, traits) \\
BOOST_PP_EXPR_IIF( \\
BOOST_PP_COMPL(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \\
BOOST_CONTRACT_EXT_PP_USING_ASSERTION_TRAITS_TEMPLATE_PARAMS( \\
traits \\
) \\
)) \\
, \\
template \\
) \\
BOOST_CONTRACT_EXT_PP_USING_ASSERTION_TRAITS_TEMPLATE_PARAMS(traits) \\
using \\
BOOST_CONTRACT_EXT_PP_USING_ASSERTION_TRAITS_NAMESPACE(traits) \\
BOOST_PP_EXPR_IIF(BOOST_PP_COMPL(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \\
BOOST_CONTRACT_EXT_PP_USING_ASSERTION_TRAITS_NEW_NAME(traits))), \\
(BOOST_CONTRACT_EXT_PP_USING_ASSERTION_TRAITS_NEW_NAME(traits)) as \\
) \\
BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM( \\
BOOST_CONTRACT_EXT_PP_USING_ASSERTION_TRAITS_NAME(traits)) \\
,
#define BOOST_CONTRACT_TEST_AUX_PP_TYPEDEF_ASSERTION_S_{0}_(s, traits) \\
typedef \\
BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM( \\
BOOST_CONTRACT_EXT_PP_TYPEDEF_ASSERTION_TRAITS_NAME(traits)) \\
BOOST_CONTRACT_EXT_PP_TYPEDEF_ASSERTION_TRAITS_NEW_NAME(traits) \\
,
#define BOOST_CONTRACT_TEST_AUX_PP_CONST_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_CONST_ASSERTION_IMPL_S_{0}_(s, traits, 1)
#define BOOST_CONTRACT_TEST_AUX_PP_CONST_ASSERTION_IMPL_S_{0}_(s, traits, \\
has_trailing_comma) \\
const \\
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \\
BOOST_CONTRACT_EXT_PP_CONST_ASSERTION_TRAITS_CAPTURES(traits)), \\
() BOOST_PP_TUPLE_EAT(3) \\
, \\
BOOST_PP_SEQ_FOLD_LEFT_ ## s \\
)(BOOST_CONTRACT_TEST_AUX_PP_CAPTURE_S_, (), \\
BOOST_CONTRACT_EXT_PP_CONST_ASSERTION_TRAITS_CAPTURES(traits)) \\
BOOST_CONTRACT_EXT_PP_CONST_ASSERTION_TRAITS_EXPR(traits) \\
BOOST_PP_COMMA_IF(has_trailing_comma)
#define BOOST_CONTRACT_TEST_AUX_PP_BOOL_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_BOOL_ASSERTION_IMPL_S_{0}_(s, traits, 1)
#define BOOST_CONTRACT_TEST_AUX_PP_BOOL_ASSERTION_IMPL_S_{0}_(s, traits, \\
has_trailing_comma) \\
BOOST_CONTRACT_EXT_PP_BOOL_ASSERTION_TRAITS_EXPR(traits) \\
BOOST_PP_COMMA_IF(has_trailing_comma)
#define BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_IMPL_S_{0}_(s, traits, 0, \\
BOOST_CONTRACT_TEST_AUX_PP_ASSERTIONS_S_{1})
#define BOOST_CONTRACT_TEST_AUX_PP_POST_IF_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_IMPL_S_{0}_(s, traits, 0, \\
BOOST_CONTRACT_TEST_AUX_PP_POST_ASSERTIONS_S_{1})
#define BOOST_CONTRACT_TEST_AUX_PP_STATIC_IF_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_IMPL_S_{0}_(s, traits, 1, \\
BOOST_CONTRACT_TEST_AUX_PP_ASSERTIONS_S_{1})
#define BOOST_CONTRACT_TEST_AUX_PP_POST_STATIC_IF_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_IMPL_S_{0}_(s, traits, 1, \\
BOOST_CONTRACT_TEST_AUX_PP_POST_ASSERTIONS_S_{1})
#define BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_IMPL_S_{0}_(s, traits, \\
is_static, next_assertion_macro) \\
BOOST_PP_EXPR_IIF(is_static, static) \\
if( \\
BOOST_PP_IIF( \\
BOOST_CONTRACT_EXT_PP_KEYWORD_IS_CONST_FRONT( \\
BOOST_CONTRACT_EXT_PP_ASSERTION_TRAITS_KIND( \\
BOOST_CONTRACT_EXT_PP_IF_ASSERTION_TRAITS_COND( \\
traits \\
))) \\
, \\
BOOST_CONTRACT_TEST_AUX_PP_CONST_ASSERTION_IMPL_S_{1}_ \\
, \\
BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_BOOL_COND_S_{1}_ \\
)(s, BOOST_CONTRACT_EXT_PP_IF_ASSERTION_TRAITS_COND(traits), 0) \\
) \\
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \\
BOOST_CONTRACT_EXT_PP_IF_ASSERTION_TRAITS_THENS(traits)), \\
( ) BOOST_PP_TUPLE_EAT(3) \\
, \\
BOOST_PP_SEQ_FOLD_LEFT_ ## s \\
)(next_assertion_macro, (), \\
BOOST_CONTRACT_EXT_PP_IF_ASSERTION_TRAITS_THENS(traits)) \\
else \\
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \\
BOOST_CONTRACT_EXT_PP_IF_ASSERTION_TRAITS_ELSES(traits)), \\
( ) BOOST_PP_TUPLE_EAT(3) \\
, \\
BOOST_PP_SEQ_FOLD_LEFT_ ## s \\
)(next_assertion_macro, (), \\
BOOST_CONTRACT_EXT_PP_IF_ASSERTION_TRAITS_ELSES(traits))
// Extra parenthesis always internally added for if bool cond (so remove them).
#define BOOST_CONTRACT_TEST_AUX_PP_IF_ASSERTION_BOOL_COND_S_{0}_(s, \\
cond_traits, has_trailing_comma) \\
BOOST_PP_TUPLE_REM_CTOR( \
BOOST_CONTRACT_TEST_AUX_PP_BOOL_ASSERTION_IMPL_S_{0}_( \\
s, cond_traits, has_trailing_comma) \
)
#define BOOST_CONTRACT_TEST_AUX_PP_RETURN_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM( \\
BOOST_CONTRACT_EXT_PP_RETURN_ASSERTION_TRAITS_TYPE(traits)) \\
BOOST_CONTRACT_EXT_PP_RETURN_ASSERTION_TRAITS_ASSIGN(traits) \\
return \\
,
// Implementation: OLDOF_..._OPERATOR internally splits tokens into a 2-tuple.
#define BOOST_CONTRACT_TEST_AUX_PP_OLDOF_ASSERTION_S_{0}_(s, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM( \\
BOOST_CONTRACT_EXT_PP_OLDOF_ASSERTION_TRAITS_TYPE(traits)) \\
BOOST_CONTRACT_EXT_PP_OLDOF_ASSERTION_TRAITS_ASSIGN(traits) \\
BOOST_CONTRACT_EXT_PP_OLDOF_ASSERTION_TRAITS_OPERATOR \\
BOOST_CONTRACT_EXT_PP_OLDOF_ASSERTION_TRAITS_EXPR(traits) \\
,
'''.format(n, n + 1)
return result
script = os.path.basename(sys.argv[0])
path = sys.argv[0].replace('-generate.py', '', 1) + ".hpp"
file = open(path, 'w')
file.write('''
#ifndef BOOST_CONTRACT_TEST_AUX_PP_ASSERTION_HPP_
#define BOOST_CONTRACT_TEST_AUX_PP_ASSERTION_HPP_
// WARNING: FILE AUTOMATICALLY GENERATED, DO NOT MODIFY IT!
// Instead, modify and run related generation script "{0}".
#include "pp_tuple.hpp"
#include <boost/contract/ext_/preprocessor/traits/assertion.hpp>
#include <boost/contract/ext_/preprocessor/keyword/namespace.hpp>
#include <boost/contract/ext_/preprocessor/keyword/using.hpp>
#include <boost/contract/ext_/preprocessor/keyword/typedef.hpp>
#include <boost/contract/ext_/preprocessor/keyword/const.hpp>
#include <boost/contract/ext_/preprocessor/keyword/return.hpp>
#include <boost/contract/ext_/preprocessor/variadic/tuple_append.hpp>
#include <boost/contract/ext_/preprocessor/utility/empty.hpp>
#include <boost/preprocessor/seq/fold_left.hpp>
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/preprocessor/tuple/rem.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/control/expr_iif.hpp>
#include <boost/preprocessor/logical/compl.hpp>
#include <boost/preprocessor/facilities/expand.hpp>
/* PIBLIC */
// Maximum number of nested assertions that can be processed (before pp errors).
#define BOOST_CONTRACT_TEST_AUX_PP_ASSERTION_LIMIT {1}
/* PRIVATE */
#define BOOST_CONTRACT_TEST_AUX_PP_CAPTURE_S_(s, captures, traits) \\
BOOST_CONTRACT_TEST_AUX_PP_CAPTURE_PUSH_BACK_( \\
captures, \\
( \\
BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM( \\
BOOST_CONTRACT_EXT_PP_CAPTURE_TRAITS_TYPE(traits)) \\
BOOST_CONTRACT_EXT_PP_CAPTURE_TRAITS_NAME(traits) \\
) \\
)
#define BOOST_CONTRACT_TEST_AUX_PP_CAPTURE_PUSH_BACK_(captures, capture) \
( \
BOOST_PP_TUPLE_REM_CTOR(captures) \
BOOST_PP_COMMA_IF(BOOST_PP_COMPL( \
BOOST_PP_EXPAND(BOOST_CONTRACT_EXT_PP_IS_EMPTY captures))) \
BOOST_PP_TUPLE_REM_CTOR(capture) \
)
{2}
#endif // #include guard
'''.format(script, LIMIT, code()))
file.close()
print "Written:", path

12135
test/aux_/pp_assertions.hpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,70 +6,9 @@
#include <boost/contract/ext_/preprocessor/stringize.hpp>
#include <boost/preprocessor/stringize.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
#include <iostream>
#include <locale>
/* PRIVATE */
namespace boost { namespace contract { namespace test { namespace aux {
namespace pp_traits_ {
// Remove spaces not separating words, etc.
std::string trim ( std::string const& source ) {
std::locale locale;
std::string result = "";
for(std::string::size_type i = 0; i < source.size(); ++i) {
if(source[i] != ' ') {
result += source[i]; // Keep non-space char.
} else if(i == 0) {
// Skip leading space.
} else if(i == source.size() - 1) {
// Skip trailing space.
} else if(!std::isalpha(source[i - 1], locale) ||
!std::isalpha(source[i + 1], locale)) {
// Skip spaces not in between letters.
} else {
result += source[i]; // Keep separation space.
}
}
return result;
}
} } } } } // namespace
// Indirections for proper expansion of BOOST_TEST generated error message.
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_2ND_(pred) BOOST_TEST(pred);
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_(pred) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_2ND_(pred)
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_EQUAL_(left, right) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_( \
boost::contract::test::aux::pp_traits_::trim( \
BOOST_CONTRACT_EXT_PP_STRINGIZE(left BOOST_PP_EMPTY()) \
) \
== \
boost::contract::test::aux::pp_traits_::trim( \
BOOST_CONTRACT_EXT_PP_STRINGIZE(right BOOST_PP_EMPTY()) \
) \
)
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_( \
decl_traits, traits_elem_macro, parsed_trait, decl_after_trait) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_EQUAL_( \
traits_elem_macro(BOOST_PP_TUPLE_ELEM(2, 1, decl_traits)), \
parsed_trait \
) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_EQUAL_( \
BOOST_PP_TUPLE_ELEM(2, 0, decl_traits), \
decl_after_trait BOOST_PP_NIL \
)
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_DONE_(decl_traits) \
( \
BOOST_PP_TUPLE_ELEM(2, 0, decl_traits), \
BOOST_CONTRACT_EXT_PP_TRAITS_DONE(BOOST_PP_TUPLE_ELEM(2, 1, \
decl_traits)) \
)
#include <string>
/* PUBLIC */
@ -85,7 +24,7 @@ std::string trim ( std::string const& source ) {
parsed_trait \
) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_( \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_DONE_(traits_parse_macro(1, \
BOOST_CONTRACT_EXT_PP_DECL_TRAITS_DONE(traits_parse_macro(1, \
decl_before_trait decl_at_trait decl_after_trait)), \
traits_elem_macro, \
parsed_trait, \
@ -113,5 +52,92 @@ std::string trim ( std::string const& source ) {
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_REPORT_ERRORS \
boost::report_errors()
/* PRIVATE */
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_( \
decl_traits, traits_elem_macro, parsed_trait, decl_after_trait) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_EQUAL_( \
traits_elem_macro(BOOST_PP_TUPLE_ELEM(2, 1, decl_traits)), \
parsed_trait \
) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_EQUAL_( \
BOOST_CONTRACT_EXT_PP_NIL_REMOVE_BACK( \
BOOST_PP_TUPLE_ELEM(2, 0, decl_traits)), \
decl_after_trait \
)
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_EQUAL_(left, right) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_( \
boost::contract::test::aux::pp_traits_::equal( \
boost::contract::test::aux::pp_traits_::trim( \
BOOST_CONTRACT_EXT_PP_STRINGIZE(left BOOST_PP_EMPTY()) \
) \
, \
boost::contract::test::aux::pp_traits_::trim( \
BOOST_CONTRACT_EXT_PP_STRINGIZE(right BOOST_PP_EMPTY()) \
) \
) \
)
// Indirection needed for proper expansion of BOOST_TEST's error message.
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_(pred) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_2ND_(pred)
#define BOOST_CONTRACT_TEST_AUX_PP_TRAITS_TEST_2ND_(pred) BOOST_TEST(pred);
namespace boost { namespace contract { namespace test { namespace aux {
namespace pp_traits_ {
// Compare strings for equality printing informational message if they differ.
bool equal ( std::string const& left, std::string const& right ) {
std::string::size_type l = 0, r = 0;
while(l < left.size() && r < right.size()) {
if(left[l] != right[r]) break;
++l;
++r;
}
if(l != left.size() || r != right.size()) {
std::cerr <<
std::endl <<
"error: following strings differ at characters '" <<
left[l] << "' '" << right[r] <<
"' (positions indented below)" << std::endl <<
std::endl <<
left.substr(0, l) << std::endl <<
std::string(l, ' ') + left.substr(l, left.size() - 1) <<
std::endl <<
right.substr(0, r) << std::endl <<
std::string(r, ' ') + right.substr(r, right.size() - 1) <<
std::endl <<
std::endl
;
return false;
}
return true;
}
// Remove spaces not separating words, etc.
std::string trim ( std::string const& source ) {
std::locale locale;
std::string result = "";
for(std::string::size_type i = 0; i < source.size(); ++i) {
if(source[i] != ' ') {
result += source[i]; // Keep non-space char.
} else if(i == 0) {
// Skip leading space.
} else if(i == source.size() - 1) {
// Skip trailing space.
} else if(!std::isalpha(source[i - 1], locale) ||
!std::isalpha(source[i + 1], locale)) {
// Skip spaces not in between letters.
} else {
result += source[i]; // Keep separation space.
}
}
return result;
}
} } } } } // namespace
#endif // #include guard

View File

@ -7,271 +7,362 @@
#define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_POSTCONDITIONS_INDEX
#include "../aux_/pp_traits.hpp"
#include "../aux_/pp_assertions.hpp"
#include "../aux_/pp_tuple.hpp"
#include <boost/contract/oldof.hpp>
#include <boost/contract/ext_/preprocessor/traits/func.hpp>
#include <boost/contract/ext_/preprocessor/utility/empty.hpp>
#include <boost/preprocessor/seq/fold_left.hpp>
#include <boost/preprocessor/tuple/eat.hpp>
#include <boost/preprocessor/control/iif.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
#define BOOST_CONTRACT_TEST_(postconditions) \
#define BOOST_CONTRACT_TEST_POSTCONDITIONS_(func_traits) \
postcondition \
BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_POSTCONDITIONS(func_traits)), \
() BOOST_PP_TUPLE_EAT(3) \
, \
BOOST_PP_SEQ_FOLD_LEFT \
)(BOOST_CONTRACT_TEST_AUX_PP_POST_ASSERTIONS_S_1, (), \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_POSTCONDITIONS(func_traits))
#define BOOST_CONTRACT_TEST_EQUAL_(postconditions, parsed_postconditions) \
BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_POSTCONDITIONS, \
BOOST_CONTRACT_TEST_POSTCONDITIONS_, \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_PARSE_D, \
/*(std::map<int, char>&)*/ (f) ( ) \
(std::map<int, char>&) (f) ( ) \
throw(int, double) override final, \
postconditions, \
remove_this_trailing_stuff, \
postconditions \
BOOST_PP_EMPTY(), \
parsed_postconditions \
)
#define BOOST_CONTRACT_TEST_(postconditions) \
BOOST_CONTRACT_TEST_EQUAL_(postconditions, postconditions)
#define oldof BOOST_CONTRACT_OLDOF
int main ( ) {
BOOST_CONTRACT_TEST_( BOOST_PP_EMPTY() )
// Test no postconditions.
BOOST_CONTRACT_TEST_EQUAL_( BOOST_PP_EMPTY(), postcondition( ) )
// Test empty postconditions.
BOOST_CONTRACT_TEST_( postcondition( ) )
BOOST_CONTRACT_TEST_( postcondition( x >= 0, y, z ) )
BOOST_CONTRACT_TEST_(
postcondition(
first,
namespace (py) as boost::python,
// Using directives.
using namespace std,
// Using declarations.
using std::placeholders::_1,
using typename T::value_type,
using (std::map<int, char>::insert),
using (typename M<int, char>::key_type),
// Using aliases.
using (iv) as vector<int>,
using (icmap) as (map<int, char>),
template( typename T ) using (vt) as vector<T>,
template( typename T, int U ) using (xtu) as (x<T, int, U>),
typedef unsigned long ul,
typedef (map<int, char>) icmap,
auto result1 = return,
int const result2 = return,
(map<int, char> const&) result3 = return,
auto old_size = BOOST_CONTRACT_OLDOF v.size(),
unsigned int const old_capacity = oldof v.capacity(),
(map<int, char> const) old_map =
BOOST_CONTRACT_OLDOF (map<int, char>::clone(m)),
x >= 0,
x == 0 ? !result : true,
(!y),
(std::map<int, char>::key_size > 0),
const( std::cout ) !std::cout.error(),
const( std::cout, x ) std::cout.flags == x,
const( ) true,
const( int const n, x, (::std::map<int, char> const&) m )
(m.size() == map<int, char>::key_size == x),
static if(m<x, y>::value) (
u,
) else (
v,
)
if(const( int const x ) x >= 0) (
a >= 0,
typedef bool b,
auto c = return,
long long const d = BOOST_CONTRACT_OLDOF v.size(),
d >= v.size(),
) else if(x) (
x,
y,
) else (
u,
v,
)
last,
)
// Test no trailing comma.
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x >= 0, y, z ),
postcondition( x >= 0, y, z, )
)
// Test everything together.
BOOST_CONTRACT_TEST_( postcondition(
before,
namespace (py) as boost::python,
// Using directives.
using namespace std,
// Using declarations.
using std::placeholders::_1,
using typename T::value_type,
using (std::map<int, char>::insert),
using (typename M<int, char>::key_type),
// Using aliases.
using (iv) as vector<int>,
using (icmap) as (map<int, char>),
template( typename T ) using (vt) as vector<T>,
template( typename T, int U ) using (xtu) as (x<T, int, U>),
typedef unsigned long ul,
typedef (map<int, char>) icmap,
auto result1 = return,
int const result2 = return,
(map<int, char> const&) result3 = return,
auto old_size = BOOST_CONTRACT_OLDOF v.size(),
unsigned int const old_capacity = oldof v.capacity(),
(map<int, char> const) old_map =
BOOST_CONTRACT_OLDOF (map<int, char>::clone(m)),
const( std::cout ) !std::cout.error(),
const( std::cout, x ) std::cout.flags == x,
const( ) true,
const( int const n, x, (::std::map<int, char> const&) m )
(m.size() == map<int, char>::key_size == x),
x >= 0,
x == 0 ? !result : true,
(!y),
(std::map<int, char>::key_size > 0),
if(m<a, b>::value) (
a >= 0,
typedef bool b,
auto c = return,
long long const d = BOOST_CONTRACT_OLDOF v.size(),
d >= v.size(),
) else (
x,
if(const( y, z ) y >= z) (
y,
z,
) else (
u,
v,
)
w,
)
static if(is_same<X, Y>::value) (
x == y,
) else (
x,
y,
)
after,
) )
// Test if with all then statements and no else.
BOOST_CONTRACT_TEST_( postcondition( before,
if(c),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) t1,
after, ) )
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c), y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ) y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ) y, ),
postcondition( x, if(c) ( t1, t2, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ), y, ),
postcondition( x, if(c) ( t1, t2, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) t1, y, ),
postcondition( x, if(c) ( t1, ) else ( ) y, )
)
// Test if with empty then and all else statements.
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ) else,
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ) else ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ) else ( e1, e2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ) else ( e1, e2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ) else e1,
after, ) )
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ) else, y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_(
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_(
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ) else ( e1, e2, ), y, ),
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ) else e1, y, ),
postcondition( x, if(c) ( ) else ( e1, ) y, )
)
// Test if with non-empty then and all else statements.
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ) else,
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ) else ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ) else ( e1, e2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ) else ( e1, e2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ) else e1,
after, ) )
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ) else, y, ),
postcondition( x, if(c) ( t1, t2, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_(
postcondition( x, if(c) ( t1, t2, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_(
postcondition( x, if(c) ( t1, t2, ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ) else ( e1, e2, ), y, ),
postcondition( x, if(c) ( t1, t2, ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ) else e1, y, ),
postcondition( x, if(c) ( t1, t2, ) else ( e1, ) y, )
)
// Test if with no then, a comma, and all else statements (allowed in C++).
BOOST_CONTRACT_TEST_( postcondition( before,
if(c), else,
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c), else ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c), else ( e1, e2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c), else ( e1, e2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c), else e1,
after, ) )
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c), else, y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c), else ( ) y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c), else ( e1, e2, ) y, ),
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c), else ( e1, e2, ), y, ),
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c), else e1, y, ),
postcondition( x, if(c) ( ) else ( e1, ) y, )
)
// Test if with no then and all else statements (not allowed by C++ for no
// reason... so allowed by this syntax so less cryptic errors).
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) else,
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) else ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) else ( e1, e2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) else ( e1, e2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) else e1,
after, ) )
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) else, y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) else ( ) y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) else ( e1, e2, ) y, ),
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) else ( e1, e2, ), y, ),
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) else e1, y, ),
postcondition( x, if(c) ( ) else ( e1, ) y, )
)
// Test if with empty then, a comma, and all else statements (not allowed by
// C++ for no reason... so allowed by this syntax so less cryptic errors).
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ), else,
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ), else ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ), else ( e1, e2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ), else ( e1, e2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( ), else e1,
after, ) )
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ), else, y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ), else ( ) y, ),
postcondition( x, if(c) ( ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ), else ( e1, e2, ) y, ),
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ), else ( e1, e2, ), y, ),
postcondition( x, if(c) ( ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( ), else e1, y, ),
postcondition( x, if(c) ( ) else ( e1, ) y, )
)
// Test if with non-empty then, a comma, and all else statements (not
// allowed by C++ for no reason... so allowed by this syntax so less
// cryptic errors).
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ), else,
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ), else ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ), else ( e1, e2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ), else ( e1, e2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ), else e1,
after, ) )
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ), else, y, ),
postcondition( x, if(c) ( t1, t2, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ), else ( ) y, ),
postcondition( x, if(c) ( t1, t2, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ), else ( e1, e2, ) y, ),
postcondition( x, if(c) ( t1, t2, ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ), else ( e1, e2, ), y, ),
postcondition( x, if(c) ( t1, t2, ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ), else e1, y, ),
postcondition( x, if(c) ( t1, t2, ) else ( e1, ) y, )
)
// Test same as above with single then statement.
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) t1, else, y, ),
postcondition( x, if(c) ( t1, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) t1, else ( ) y, ),
postcondition( x, if(c) ( t1, ) else ( ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) t1, else ( e1, e2, ) y, ),
postcondition( x, if(c) ( t1, ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) t1, else ( e1, e2, ), y, ),
postcondition( x, if(c) ( t1, ) else ( e1, e2, ) y, )
)
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) t1, else e1, y, ),
postcondition( x, if(c) ( t1, ) else ( e1, ) y, )
)
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) t1, else,
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) t1, else ( )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) t1, else ( e1, e2, )
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) t1, else ( e1, e2, ),
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) t1, else e1,
after, ) )
// Extra else correctly threated as a boolean-assertion `bool(else e2)`.
BOOST_CONTRACT_TEST_( postcondition( before,
if(c) ( t1, t2, ), else e1, else e2,
after, ) )
// Extra else correctly treated as a boolean-assertion `bool(else e2)`.
BOOST_CONTRACT_TEST_EQUAL_(
postcondition( x, if(c) ( t1, t2, ), else e1, else e2, y, ),
postcondition( x, if(c) ( t1, t2, ) else ( e1, ) bool(else e2), y, )
)
BOOST_CONTRACT_TEST_( postcondition( before,
if(c1) (
t11,
t12,
) else if(c2) (
t21,
t22,
) else if(c3) (
t31,
t32,
) else (
e1,
e2,
BOOST_CONTRACT_TEST_EQUAL_(
postcondition(
x,
if(c) (
t1,
t2,
) else if(cc) (
tt1,
tt2,
) else if(ccc) (
ttt1,
ttt2,
) else (
e1,
e2,
)
y,
),
postcondition(
x,
if(c) (
t1,
t2,
) else (
if(cc) (
tt1,
tt2,
) else (
if(ccc) (
ttt1,
ttt2,
) else (
e1,
e2,
)
)
)
y,
)
after, ) )
BOOST_CONTRACT_TEST_( postcondition( before,
static if(c1) (
t11,
t12,
) else static if(c2) (
t21,
t22,
) else static if(c3) (
t31,
t32,
) else (
e1,
e2,
)
after, ) )
)
//
// BOOST_CONTRACT_TEST_( postcondition( before,
// static if(c1) (
// t11,
// t12,
// ) else static if(c2) (
// t21,
// t22,
// ) else static if(c3) (
// t31,
// t32,
// ) else (
// e1,
// e2,
// )
// after, ) )
return BOOST_CONTRACT_TEST_AUX_PP_TRAITS_REPORT_ERRORS;
}