diff --git a/test/pp_func_traits/Jamfile.v2 b/test/pp_func_traits/Jamfile.v2 index 6fd7276..1b96f13 100644 --- a/test/pp_func_traits/Jamfile.v2 +++ b/test/pp_func_traits/Jamfile.v2 @@ -1,13 +1,6 @@ import testing ; -echo "Examples: - b2 - compile and run test program .cpp - b2 -pp [cxxflags=-UDEBUG] - stop after preprocessing .cpp -""" ; - rule test-pp ( filename ) { run $(filename).cpp ; preprocessed $(filename)-pp : $(filename).cpp : -DDEBUG ; @@ -22,11 +15,11 @@ test-pp classifiers ; test-pp return_ ; test-pp name ; test-pp params ; -test-pp cv_qualifiers ; +test-pp cv ; test-pp ref ; test-pp except ; test-pp trailing_return ; -test-pp virt_specifiers ; +test-pp virt ; # TODO: Try to automatically run and test wave too... Maybe something like this: # SHELL "wave access.cpp" ; diff --git a/test/pp_func_traits/access.cpp b/test/pp_func_traits/access.cpp index 08645f7..ec2e6dc 100644 --- a/test/pp_func_traits/access.cpp +++ b/test/pp_func_traits/access.cpp @@ -14,14 +14,14 @@ #include -#define BOOST_CONTRACT_TEST_(trait) \ +#define BOOST_CONTRACT_TEST_(access) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_ACCESS, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ BOOST_PP_EMPTY(), \ - trait, \ + access, \ (std::map&) (f) ( int x, (std::map&) y ), \ - trait \ + access \ ) int main ( ) { diff --git a/test/pp_func_traits/classifiers.cpp b/test/pp_func_traits/classifiers.cpp index f365f3e..1b63ef7 100644 --- a/test/pp_func_traits/classifiers.cpp +++ b/test/pp_func_traits/classifiers.cpp @@ -19,45 +19,47 @@ #include #include -#define BOOST_CONTRACT_TEST_FIND_(r, trait_id, trait) \ +#define BOOST_CONTRACT_TEST_FIND_(r, classifier_upper, classifier) \ BOOST_PP_EXPR_IIF(BOOST_PP_SEQ_CAT((BOOST_CONTRACT_EXT_PP_KEYWORD_IS_) \ - (trait_id)(_FRONT))(trait), \ - trait \ + (classifier_upper)(_FRONT))(classifier), \ + classifier \ ) -#define BOOST_CONTRACT_TEST_ELEM_(r, unused, trait) trait +#define BOOST_CONTRACT_TEST_ELEM_(r, unused, classifier) classifier -#define BOOST_CONTRACT_TEST_TRAIT_(trait_id, traits) \ +#define BOOST_CONTRACT_TEST_TRAIT_(classifier_upper, classifiers_list) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ - BOOST_PP_CAT(BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_, trait_id), \ + BOOST_PP_CAT(BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_, classifier_upper), \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ template( typename T, (std::map::value_type) V ), \ - BOOST_PP_LIST_FOR_EACH(BOOST_CONTRACT_TEST_ELEM_, ~, traits), \ + BOOST_PP_LIST_FOR_EACH(BOOST_CONTRACT_TEST_ELEM_, ~, \ + classifiers_list), \ (std::map&) (f) ( int x, (std::map&) y ), \ - BOOST_PP_LIST_FOR_EACH(BOOST_CONTRACT_TEST_FIND_, trait_id, traits) \ + BOOST_PP_LIST_FOR_EACH(BOOST_CONTRACT_TEST_FIND_, classifier_upper, \ + classifiers_list) \ ) -#define BOOST_CONTRACT_TEST_LIST_(traits) \ - BOOST_CONTRACT_TEST_TRAIT_(INLINE, traits) \ - BOOST_CONTRACT_TEST_TRAIT_(STATIC, traits) \ - BOOST_CONTRACT_TEST_TRAIT_(EXTERN, traits) \ - BOOST_CONTRACT_TEST_TRAIT_(EXPLICIT, traits) \ - BOOST_CONTRACT_TEST_TRAIT_(VIRTUAL, traits) \ - BOOST_CONTRACT_TEST_TRAIT_(FRIEND, traits) +#define BOOST_CONTRACT_TEST_LIST_(classifiers_list) \ + BOOST_CONTRACT_TEST_TRAIT_(INLINE, classifiers_list) \ + BOOST_CONTRACT_TEST_TRAIT_(STATIC, classifiers_list) \ + BOOST_CONTRACT_TEST_TRAIT_(EXTERN, classifiers_list) \ + BOOST_CONTRACT_TEST_TRAIT_(EXPLICIT, classifiers_list) \ + BOOST_CONTRACT_TEST_TRAIT_(VIRTUAL, classifiers_list) \ + BOOST_CONTRACT_TEST_TRAIT_(FRIEND, classifiers_list) -#define BOOST_CONTRACT_TEST_(traits) \ +#define BOOST_CONTRACT_TEST_(classifiers_seq) \ BOOST_CONTRACT_TEST_LIST_( \ - BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY(traits), \ + BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY(classifiers_seq), \ BOOST_PP_NIL BOOST_PP_TUPLE_EAT(1) \ , \ BOOST_PP_SEQ_TO_LIST \ - )(traits) \ + )(classifiers_seq) \ ) int main ( ) { - // Test a few combination verified to be valid C++. (Other combinations are - // also supported by the macro syntax but it would be overwhelming to test - // them all and of little use given they are not valid C++.) + // Test a few combinations verified to be valid C++. (Other combinations + // are also supported by the macro syntax but it would be overwhelming to + // test them all and of little use given they are not valid C++.) BOOST_CONTRACT_TEST_( BOOST_PP_EMPTY() ) diff --git a/test/pp_func_traits/cv.cpp b/test/pp_func_traits/cv.cpp index 2dbd98b..9370e8a 100644 --- a/test/pp_func_traits/cv.cpp +++ b/test/pp_func_traits/cv.cpp @@ -6,7 +6,7 @@ #include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ - BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_CV_QUALIFIERS_INDEX + BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_CV_INDEX #include "../aux_/pp_traits.hpp" #include @@ -14,22 +14,22 @@ #include -#define BOOST_CONTRACT_TEST_CV_QUALIFIERS_(func_traits) \ +#define BOOST_CONTRACT_TEST_CV_(func_traits) \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_CONST(func_traits) \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_VOLATILE(func_traits) -#define BOOST_CONTRACT_TEST_EQUAL_(trait, parsed) \ +#define BOOST_CONTRACT_TEST_EQUAL_(cv, parsed_cv) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ - BOOST_CONTRACT_TEST_CV_QUALIFIERS_, \ + BOOST_CONTRACT_TEST_CV_, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ (std::map&) (f) ( int x, (std::map&) y ), \ - trait, \ + cv, \ refref throw(int, double) final override, \ - parsed \ + parsed_cv \ ) -#define BOOST_CONTRACT_TEST_(trait) \ - BOOST_CONTRACT_TEST_EQUAL_(trait, trait) +#define BOOST_CONTRACT_TEST_(cv) \ + BOOST_CONTRACT_TEST_EQUAL_(cv, cv) int main ( ) { BOOST_CONTRACT_TEST_( BOOST_PP_EMPTY() ) diff --git a/test/pp_func_traits/except.cpp b/test/pp_func_traits/except.cpp index 99f626e..a71da9c 100644 --- a/test/pp_func_traits/except.cpp +++ b/test/pp_func_traits/except.cpp @@ -12,14 +12,14 @@ #include #include -#define BOOST_CONTRACT_TEST_(trait) \ +#define BOOST_CONTRACT_TEST_(except) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXCEPT, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ (std::map&) (f) ( int x, (std::map&) y ) const, \ - trait, \ + except, \ final override, \ - trait \ + except \ ) int main ( ) { diff --git a/test/pp_func_traits/export.cpp b/test/pp_func_traits/export.cpp index c787407..095eb13 100644 --- a/test/pp_func_traits/export.cpp +++ b/test/pp_func_traits/export.cpp @@ -12,15 +12,15 @@ #include #include -#define BOOST_CONTRACT_TEST_(trait) \ +#define BOOST_CONTRACT_TEST_(export_) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXPORT, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ BOOST_PP_EMPTY(), \ - trait, \ + export_, \ template( typename T, (std::map::value_type) V ) \ (std::map&) (f) ( int x, (std::map&) y ), \ - trait \ + export_ \ ) int main ( ) { diff --git a/test/pp_func_traits/name.cpp b/test/pp_func_traits/name.cpp index 8b2a251..8a4399e 100644 --- a/test/pp_func_traits/name.cpp +++ b/test/pp_func_traits/name.cpp @@ -12,22 +12,22 @@ #include #include -#define BOOST_CONTRACT_TEST_(sign_before_name, sign_at_name, \ - sign_after_name, parsed_operator_name, parsed_func_name) \ +#define BOOST_CONTRACT_TEST_(before, name, after, \ + parsed_operator_name, parsed_func_name) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_OPERATOR_NAME, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ - sign_before_name, \ - sign_at_name, \ - sign_after_name, \ + before, \ + name, \ + after, \ parsed_operator_name \ ) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_NAME, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ - sign_before_name, \ - sign_at_name, \ - sign_after_name, \ + before, \ + name, \ + after, \ parsed_func_name \ ) diff --git a/test/pp_func_traits/params.cpp b/test/pp_func_traits/params.cpp index 979d3b1..cacb952 100644 --- a/test/pp_func_traits/params.cpp +++ b/test/pp_func_traits/params.cpp @@ -19,15 +19,16 @@ #include #include -// NOTE: Some extra test macros are necessary here to regenerate the sign back +// NOTE: Some extra test macros are necessary here to regenerate the decl back // from the parsed trait to check if the parsing was correct. But, at the end // these are valuable tests also because they use the PARAM_TRAITS macros. // Assume all 1-tuple types were specified without parenthesis. This is usually // NOT true, but it is true in these tests. This is relevant only in these -// tests where generated code must match original signature and its parenthesis -// (the extra parenthesis of the original signature do not need to be -// reproduced when generating C++ code so this assumption is not necessary). +// tests where generated code must match original declaration and its +// parenthesis (the extra parenthesis of the original declaration do not need +// to be reproduced when generating C++ code so this assumption is not +// necessary). #define BOOST_CONTRACT_TEST_PARAM_REM_(type) \ BOOST_PP_EXPR_IIF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(type), 1), \ BOOST_PP_TUPLE_REM(0) \ @@ -56,12 +57,12 @@ ) // Variadic to allow to specify empty params `( )`. -#define BOOST_CONTRACT_TEST_EQUAL_(params_sign, parsed_params) \ +#define BOOST_CONTRACT_TEST_EQUAL_(params, parsed_params) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_TEST_PARAMS_, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ (std::map&) (f), \ - params_sign, \ + params, \ const volatile, \ parsed_params \ ) diff --git a/test/pp_func_traits/ref.cpp b/test/pp_func_traits/ref.cpp index 879a4d6..f9e0357 100644 --- a/test/pp_func_traits/ref.cpp +++ b/test/pp_func_traits/ref.cpp @@ -14,14 +14,14 @@ #include -#define BOOST_CONTRACT_TEST_(trait) \ +#define BOOST_CONTRACT_TEST_(ref_) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_REF, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ (std::map&) (f) ( int x, (std::map&) y ) const, \ - trait, \ + ref_, \ noexcept(my::map::key_size) final override, \ - trait \ + ref_ \ ) int main ( ) { diff --git a/test/pp_func_traits/return_.cpp b/test/pp_func_traits/return_.cpp index 4c6705e..fc86fc4 100644 --- a/test/pp_func_traits/return_.cpp +++ b/test/pp_func_traits/return_.cpp @@ -18,26 +18,26 @@ #include // Wrap with parenthesis (if no parenthesis already). -// Precondition: trait != EMPTY(). -#define BOOST_CONTRACT_TEST_PARENTHESIZE_(trait) \ - BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_HAS_PAREN(trait), \ +// Precondition: return_ != EMPTY(). +#define BOOST_CONTRACT_TEST_PARENTHESIZE_(return_) \ + BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_HAS_PAREN(return_), \ BOOST_PP_TUPLE_REM(1) \ , \ BOOST_PP_EMPTY() \ - )(trait) + )(return_) -#define BOOST_CONTRACT_TEST_(before, trait, after) \ +#define BOOST_CONTRACT_TEST_(before, return_, after) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_RETURN, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ before, \ - trait, \ + return_, \ after, \ - BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY(trait), \ + BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY(return_), \ BOOST_PP_TUPLE_EAT(1) \ , \ BOOST_CONTRACT_TEST_PARENTHESIZE_ \ - )(trait) \ + )(return_) \ ) int main ( ) { diff --git a/test/pp_func_traits/template.cpp b/test/pp_func_traits/template.cpp index 5124038..ad1c5a8 100644 --- a/test/pp_func_traits/template.cpp +++ b/test/pp_func_traits/template.cpp @@ -21,15 +21,16 @@ #include #include -// NOTE: Some extra test macros are necessary here to regenerate the sign back +// NOTE: Some extra test macros are necessary here to regenerate the decl back // from the parsed trait to check if the parsing was correct. But, at the end // these are valuable tests also because they use the PARAM_TRAITS macros. // Assume all 1-tuple types were specified without parenthesis. This is usually // NOT true, but it is true in these tests. This is relevant only in these -// tests where generated code must match original signature and its parenthesis -// (the extra parenthesis of the original signature do not need to be -// reproduced when generating C++ code so this assumption is not necessary). +// tests where generated code must match original declaration and its +// parenthesis (the extra parenthesis of the original declaration do not need +// to be reproduced when generating C++ code so this assumption is not +// necessary). #define BOOST_CONTRACT_TEST_TEMPLATE_PARAM_REM_YES_(type) \ BOOST_PP_EXPR_IIF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(type), 1), \ BOOST_PP_TUPLE_REM(0) \ @@ -72,14 +73,14 @@ template BOOST_CONTRACT_TEST_TEMPLATE_PARAMS_ \ )(func_traits) -#define BOOST_CONTRACT_TEST_(trait) \ +#define BOOST_CONTRACT_TEST_(template_params) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_TEST_TEMPLATE_, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ BOOST_PP_EMPTY(), \ - trait, \ + template_params, \ (std::map&) (f) ( int x, (std::map&) y ), \ - trait \ + template_params \ ) int main ( ) { diff --git a/test/pp_func_traits/trailing_return.cpp b/test/pp_func_traits/trailing_return.cpp index ff3290c..e435f6b 100644 --- a/test/pp_func_traits/trailing_return.cpp +++ b/test/pp_func_traits/trailing_return.cpp @@ -18,27 +18,30 @@ #include // Wrap with parenthesis (if no parenthesis already). -// Precondition: trait != EMPTY(). -#define BOOST_CONTRACT_TEST_PARENTHESIZE_(trait) \ - BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_HAS_PAREN( \ - BOOST_CONTRACT_EXT_PP_KEYWORD_RETURN_REMOVE_FRONT(trait)), \ +// Precondition: trailing_return != EMPTY(). +#define BOOST_CONTRACT_TEST_PARENTHESIZE_(trailing_return) \ + BOOST_PP_IIF( \ + BOOST_CONTRACT_EXT_PP_HAS_PAREN( \ + BOOST_CONTRACT_EXT_PP_KEYWORD_RETURN_REMOVE_FRONT(trailing_return) \ + ) \ + , \ BOOST_PP_TUPLE_REM(1) \ , \ BOOST_PP_EMPTY() \ - )(BOOST_CONTRACT_EXT_PP_KEYWORD_RETURN_REMOVE_FRONT(trait)) + )(BOOST_CONTRACT_EXT_PP_KEYWORD_RETURN_REMOVE_FRONT(trailing_return)) -#define BOOST_CONTRACT_TEST_(before, trait, after) \ +#define BOOST_CONTRACT_TEST_(before, trailing_return, after) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_TRAILING_RETURN, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ before, \ - trait, \ + trailing_return, \ after, \ - BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY(trait), \ + BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY(trailing_return), \ BOOST_PP_TUPLE_EAT(1) \ , \ BOOST_CONTRACT_TEST_PARENTHESIZE_ \ - )(trait) \ + )(trailing_return) \ ) int main ( ) { diff --git a/test/pp_func_traits/verbatim.cpp b/test/pp_func_traits/verbatim.cpp index d695661..a661abc 100644 --- a/test/pp_func_traits/verbatim.cpp +++ b/test/pp_func_traits/verbatim.cpp @@ -15,17 +15,17 @@ #include #include -#define BOOST_CONTRACT_TEST_(trait) \ +#define BOOST_CONTRACT_TEST_(verbatim_paren) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_VERBATIM, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ BOOST_PP_EMPTY(), \ BOOST_PP_EXPR_IIF(BOOST_PP_COMPL( \ - BOOST_CONTRACT_EXT_PP_IS_EMPTY(trait)), \ + BOOST_CONTRACT_EXT_PP_IS_EMPTY(verbatim_paren)), \ verbatim \ - ) trait, \ + ) verbatim_paren, \ (std::map&) (f) ( int x, (std::map&) y ), \ - trait \ + verbatim_paren \ ) int main ( ) { diff --git a/test/pp_func_traits/virt.cpp b/test/pp_func_traits/virt.cpp index 9634463..7f25739 100644 --- a/test/pp_func_traits/virt.cpp +++ b/test/pp_func_traits/virt.cpp @@ -6,7 +6,7 @@ #include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ - BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_VIRT_SPECIFIERS_INDEX + BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_VIRT_INDEX #include "../aux_/pp_traits.hpp" #include @@ -14,30 +14,30 @@ #include -#define BOOST_CONTRACT_TEST_VIRT_SPECIFIERS_(func_traits) \ +#define BOOST_CONTRACT_TEST_VIRT_(func_traits) \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_FINAL(func_traits) \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_OVERRIDE(func_traits) -#define BOOST_CONTRACT_TEST_EQUAL_(trait, parsed) \ +#define BOOST_CONTRACT_TEST_EQUAL_(virt, parsed_virt) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ - BOOST_CONTRACT_TEST_VIRT_SPECIFIERS_, \ + BOOST_CONTRACT_TEST_VIRT_, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ (std::map&) (f) ( int x, (std::map&) y ) \ throw(int, double), \ - trait, \ + virt, \ precondition(x >= 0) postcondition(x == 0 ? y.empty() : true), \ - parsed \ + parsed_virt \ ) -#define BOOST_CONTRACT_TEST_(trait) \ - BOOST_CONTRACT_TEST_EQUAL_(trait, trait) +#define BOOST_CONTRACT_TEST_(virt) \ + BOOST_CONTRACT_TEST_EQUAL_(virt, virt) int main ( ) { BOOST_CONTRACT_TEST_( BOOST_PP_EMPTY() ) BOOST_CONTRACT_TEST_( final ) BOOST_CONTRACT_TEST_( override ) BOOST_CONTRACT_TEST_( final override ) - // Same as `const volatile` once parsed (this order does not matter in C++). + // Same as `final override` once parsed (this order does not matter in C++). BOOST_CONTRACT_TEST_EQUAL_( override final, final override ) return BOOST_CONTRACT_TEST_AUX_PP_TRAITS_REPORT_ERRORS;