diff --git a/test/pp_func_traits/Jamfile.v2 b/test/pp_func_traits/Jamfile.v2 index 2e378a8..93ca9d0 100644 --- a/test/pp_func_traits/Jamfile.v2 +++ b/test/pp_func_traits/Jamfile.v2 @@ -10,8 +10,8 @@ rule test-pp ( filestem ) { alias $(filestem)-pp.ii : $(filestem)-pp ; explicit $(filestem)-pp $(filestem)-pp.ii ; - # This is "good enough"... but it'd be better is wave was ran by something - # like `bjam ... toolset=wave`. + # TODO: This is "good enough"... but it'd be better is wave was ran by + # something like `bjam ... toolset=wave`. make $(filestem)-wave.ii : $(filestem).cpp : @wave ; alias $(filestem)-wave : $(filestem)-wave.ii ; } @@ -29,5 +29,5 @@ test-pp ref ; test-pp except ; test-pp trailing_return ; test-pp virt ; -#test-pp postconditions ; +test-pp postconditions ; diff --git a/test/pp_func_traits/access.cpp b/test/pp_func_traits/access.cpp index bf4ad9c..4bcff1a 100644 --- a/test/pp_func_traits/access.cpp +++ b/test/pp_func_traits/access.cpp @@ -4,16 +4,12 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_ACCESS_INDEX - #include "../aux_/pp_traits.hpp" #include #include -#include - #define BOOST_CONTRACT_TEST_(access) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_ACCESS, \ diff --git a/test/pp_func_traits/classifiers.cpp b/test/pp_func_traits/classifiers.cpp index b7103ff..5ab655c 100644 --- a/test/pp_func_traits/classifiers.cpp +++ b/test/pp_func_traits/classifiers.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_CLASSIFIERS_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/cv.cpp b/test/pp_func_traits/cv.cpp index 02e611b..cf62958 100644 --- a/test/pp_func_traits/cv.cpp +++ b/test/pp_func_traits/cv.cpp @@ -4,16 +4,12 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_CV_INDEX - #include "../aux_/pp_traits.hpp" #include #include -#include - #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) diff --git a/test/pp_func_traits/except.cpp b/test/pp_func_traits/except.cpp index 1576478..3e599a4 100644 --- a/test/pp_func_traits/except.cpp +++ b/test/pp_func_traits/except.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_EXCEPT_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/export.cpp b/test/pp_func_traits/export.cpp index 5eaa19d..f41aa48 100644 --- a/test/pp_func_traits/export.cpp +++ b/test/pp_func_traits/export.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_EXPORT_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/name.cpp b/test/pp_func_traits/name.cpp index 95bd42d..b5cb01e 100644 --- a/test/pp_func_traits/name.cpp +++ b/test/pp_func_traits/name.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_NAME_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/params.cpp b/test/pp_func_traits/params.cpp index 7b7ab34..8964655 100644 --- a/test/pp_func_traits/params.cpp +++ b/test/pp_func_traits/params.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_PARAMS_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/postconditions.cpp b/test/pp_func_traits/postconditions.cpp index c34ab4c..b31443c 100644 --- a/test/pp_func_traits/postconditions.cpp +++ b/test/pp_func_traits/postconditions.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #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 #include @@ -17,26 +15,14 @@ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_POSTCONDITIONS, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_PARSE_D, \ - (std::map&) (f) ( int x, (std::map&) y ) \ + /*(std::map&)*/ (f) ( ) \ throw(int, double) override final, \ postconditions, \ remove_this_trailing_stuff, \ postconditions \ ) -#define Z(z) BOOST_PP_EXPAND(BOOST_CONTRACT_EXT_PP_IS_EMPTY z) - -#define X(x) Z(BOOST_PP_TUPLE_ELEM(2, 1, x)) - -#define Y(y) Z(BOOST_PP_SEQ_HEAD(BOOST_PP_TUPLE_ELEM(2, 1, y))) - -X(BOOST_CONTRACT_EXT_PP_TRAITS_TYPE_PARSE_D(1, int const n BOOST_PP_NIL)) -X(BOOST_CONTRACT_EXT_PP_TRAITS_TYPE_PARSE_D(1, (::map) n BOOST_PP_NIL)) -X(BOOST_CONTRACT_EXT_PP_TRAITS_TYPE_PARSE_D(1, n BOOST_PP_NIL)) - -Y(BOOST_CONTRACT_EXT_PP_TRAITS_TYPE_SEQ_PARSE_D(1, int const n BOOST_PP_NIL)) -Y(BOOST_CONTRACT_EXT_PP_TRAITS_TYPE_SEQ_PARSE_D(1, (::map) n BOOST_PP_NIL)) -Y(BOOST_CONTRACT_EXT_PP_TRAITS_TYPE_SEQ_PARSE_D(1, n BOOST_PP_NIL)) +#define oldof BOOST_CONTRACT_OLDOF int main ( ) { BOOST_CONTRACT_TEST_( BOOST_PP_EMPTY() ) @@ -47,47 +33,207 @@ int main ( ) { BOOST_CONTRACT_TEST_( postcondition( - namespace (py) as boost::python, - - // Using directives. - using namespace std, - // Using declarations. - using std::placeholders::_1, - using typename T::value_type, - using (std::map::insert), - using (typename M::key_type), - // Using aliases. - using (iv) as vector, - using (icmap) as (map), - template( typename T ) using (vt) as vector, - template( typename T, int U ) using (xtu) as (x), - - typedef unsigned long ul, - typedef (map) icmap, - - auto result1 = return, - int const result2 = return, - (map const&) result3 = return, - +// namespace (py) as boost::python, +// +// // Using directives. +// using namespace std, +// // Using declarations. +// using std::placeholders::_1, +// using typename T::value_type, +// using (std::map::insert), +// using (typename M::key_type), +// // Using aliases. +// using (iv) as vector, +// using (icmap) as (map), +// template( typename T ) using (vt) as vector, +// template( typename T, int U ) using (xtu) as (x), +// +// typedef unsigned long ul, +// typedef (map) icmap, +// +// auto result1 = return, +// int const result2 = return, +// (map const&) result3 = return, +// auto old_size = BOOST_CONTRACT_OLDOF v.size(), - unsigned int const old_capacity = - BOOST_CONTRACT_OLDOF v.capacity(), + unsigned int const old_capacity = oldof v.capacity(), (map const) old_map = BOOST_CONTRACT_OLDOF (map::clone(m)), +// +// x >= 0, +// x == 0 ? !result : true, +// (!y), +// (std::map::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 const&) m ) +// (m.size() == map::key_size == x), - x >= 0, - x == 0 ? !result : true, - (!y), - (std::map::key_size > 0), + 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 ( + x, + y, + z, + ) + u, v, w, - const( std::cout ) !std::cout.error(), - const( std::cout, x ) std::cout.flags == x, - const( ) true, - const( int const n, x, (::std::map const&) m ) - (m.size() == map::key_size == x), ) ) + + // 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, ) ) + + // 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, ) ) + // 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, ) ) + + // 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, ) ) + + // 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, ) ) + + // 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, ) ) + + // 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_( 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, ) ) + + // TODO: Test `if ... else if ...` and `static if ... else if ...` (note + // that static-if's else-if does NOT repeat static but it is still static). + return BOOST_CONTRACT_TEST_AUX_PP_TRAITS_REPORT_ERRORS; } diff --git a/test/pp_func_traits/ref.cpp b/test/pp_func_traits/ref.cpp index 96f8137..b8832d2 100644 --- a/test/pp_func_traits/ref.cpp +++ b/test/pp_func_traits/ref.cpp @@ -4,16 +4,12 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_REF_INDEX - #include "../aux_/pp_traits.hpp" #include #include -#include - #define BOOST_CONTRACT_TEST_(ref_) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_REF, \ diff --git a/test/pp_func_traits/return_.cpp b/test/pp_func_traits/return_.cpp index dbd2ed0..48325a0 100644 --- a/test/pp_func_traits/return_.cpp +++ b/test/pp_func_traits/return_.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_RETURN_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/template.cpp b/test/pp_func_traits/template.cpp index 774e4eb..9ae4aba 100644 --- a/test/pp_func_traits/template.cpp +++ b/test/pp_func_traits/template.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_TEMPLATE_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/trailing_return.cpp b/test/pp_func_traits/trailing_return.cpp index d60a6f5..1bffab0 100644 --- a/test/pp_func_traits/trailing_return.cpp +++ b/test/pp_func_traits/trailing_return.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_TRAILING_RETURN_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/verbatim.cpp b/test/pp_func_traits/verbatim.cpp index acc9bdc..415150f 100644 --- a/test/pp_func_traits/verbatim.cpp +++ b/test/pp_func_traits/verbatim.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_VERBATIM_INDEX - #include "../aux_/pp_traits.hpp" #include #include diff --git a/test/pp_func_traits/virt.cpp b/test/pp_func_traits/virt.cpp index 054d119..a0e68b8 100644 --- a/test/pp_func_traits/virt.cpp +++ b/test/pp_func_traits/virt.cpp @@ -4,10 +4,8 @@ # error "this compiler does not support variadic macros" #else -#include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_VIRT_INDEX - #include "../aux_/pp_traits.hpp" #include #include