diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2015-04-08 03:09:47 +0000 |
---|---|---|
committer | <> | 2015-05-05 14:37:32 +0000 |
commit | f2541bb90af059680aa7036f315f052175999355 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /libs/phoenix/test/scope | |
parent | ed232fdd34968697a68783b3195b1da4226915b5 (diff) | |
download | boost-tarball-master.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_58_0.tar.bz2.HEADboost_1_58_0master
Diffstat (limited to 'libs/phoenix/test/scope')
33 files changed, 3041 insertions, 24 deletions
diff --git a/libs/phoenix/test/scope/bug_000008.cpp b/libs/phoenix/test/scope/bug_000008.cpp index de39398c5..58adf4171 100644 --- a/libs/phoenix/test/scope/bug_000008.cpp +++ b/libs/phoenix/test/scope/bug_000008.cpp @@ -1,8 +1,9 @@ /*============================================================================= Copyright (c) 2003 Martin Wille Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ @@ -17,6 +18,10 @@ #include <boost/config.hpp> #include <boost/assert.hpp> #include <boost/detail/lightweight_test.hpp> + // Testing problems in thread/future +//#include <boost/move/move.hpp> +//#include <boost/move/detail/type_traits.hpp> +//using boost::move_detail::is_copy_constructible; #include <boost/phoenix/scope/dynamic.hpp> #if defined(DONT_HAVE_BOOST) \ diff --git a/libs/phoenix/test/scope/lambda_tests.cpp b/libs/phoenix/test/scope/lambda_tests.cpp index ef28ba049..fea7d3132 100644 --- a/libs/phoenix/test/scope/lambda_tests.cpp +++ b/libs/phoenix/test/scope/lambda_tests.cpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -15,7 +16,7 @@ #include <boost/phoenix/core.hpp> #include <boost/phoenix/operator.hpp> #include <boost/phoenix/function.hpp> -#include <boost/phoenix/bind.hpp> +//#include <boost/phoenix/bind.hpp> #include <boost/phoenix/scope.hpp> namespace boost { namespace phoenix @@ -148,27 +149,29 @@ main() { using boost::phoenix::for_each; - +#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800)) int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; std::vector<int> v(init, init+10); int x = 0; for_each(_1, lambda(_a = _2)[_a += _1])(v, x); BOOST_TEST(x == 55); +#endif } { using boost::phoenix::for_each; using boost::phoenix::push_back; +#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800)) int x = 10; std::vector<std::vector<int> > v(10); - for_each(_1, lambda(_a = _2)[push_back(_1, _a)])(v, x); int y = 0; for_each(arg1, lambda[ref(y) += _1[0]])(v); BOOST_TEST(y == 100); +#endif } { diff --git a/libs/phoenix/test/scope/lambda_tests1.cpp b/libs/phoenix/test/scope/lambda_tests1.cpp new file mode 100644 index 000000000..c9fdde168 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1.cpp @@ -0,0 +1,108 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + { + int x = 1; + int y = lambda[_1]()(x); + BOOST_TEST(x == y); + } + + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda[_1 + 2])(x)(y) == 1+10+2 + ); + BOOST_TEST( + (_1 + lambda[-_1])(x)(y) == 1+-10 + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + lambda(_a = _1, _b = _2) + [ + _1 + _a + _b + ] + (x, z)(y) == x + y + z + ); + } + + { + int x = 4; + int y = 5; + lambda(_a = _1)[_a = 555](x)(); + BOOST_TEST(x == 555); + (void)y; + } + + { + int x = 1; + long x2 = 2; + short x3 = 3; + char const* y = "hello"; + zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1a.cpp b/libs/phoenix/test/scope/lambda_tests1a.cpp new file mode 100644 index 000000000..938ba5bcc --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1a.cpp @@ -0,0 +1,71 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + { + int x = 1; + int y = lambda[_1]()(x); + BOOST_TEST(x == y); + } + + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda[_1 + 2])(x)(y) == 1+10+2 + ); + BOOST_TEST( + (_1 + lambda[-_1])(x)(y) == 1+-10 + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + lambda(_a = _1, _b = _2) + [ + _1 + _a + _b + ] + (x, z)(y) == x + y + z + ); + } + + { + int x = 4; + int y = 5; + lambda(_a = _1)[_a = 555](x)(); + BOOST_TEST(x == 555); + (void)y; + } + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b.cpp b/libs/phoenix/test/scope/lambda_tests1b.cpp new file mode 100644 index 000000000..1c906c4f5 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b.cpp @@ -0,0 +1,74 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1; + long x2 = 2; + short x3 = 3; + char const* y = "hello"; + zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b1.cpp b/libs/phoenix/test/scope/lambda_tests1b1.cpp new file mode 100644 index 000000000..615110054 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b1.cpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1; + long x2 = 2; + short x3 = 3; + char const* y = "hello"; + zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + /* + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b1p.cpp b/libs/phoenix/test/scope/lambda_tests1b1p.cpp new file mode 100644 index 000000000..34e139cd6 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b1p.cpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + //using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1; + //long x2 = 2; + //short x3 = 3; + char const* y = "hello"; + //zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + //BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + //BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + //BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + //BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + /* + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b1q.cpp b/libs/phoenix/test/scope/lambda_tests1b1q.cpp new file mode 100644 index 000000000..b4634e102 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b1q.cpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1; + //long x2 = 2; + //short x3 = 3; + char const* y = "hello"; + //zzz z; + + //BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + //BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + //BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + //BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + /* + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b1r.cpp b/libs/phoenix/test/scope/lambda_tests1b1r.cpp new file mode 100644 index 000000000..22c10e84d --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b1r.cpp @@ -0,0 +1,79 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1; + //long x2 = 2; + //short x3 = 3; + char const* y = "hello"; + zzz z; + //BOOST_TEST(lambda[_1](x)(y) == y); + //BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700) + int xx = x; + BOOST_TEST(lambda(_a = _1)[_1 = lambda[_a + 0]](x)(y)() == xx); +#else + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); +#endif + //BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + //BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + /* + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b1s.cpp b/libs/phoenix/test/scope/lambda_tests1b1s.cpp new file mode 100644 index 000000000..ee13e9f31 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b1s.cpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1; + //long x2 = 2; + //short x3 = 3; + char const* y = "hello"; + //zzz z; + + //BOOST_TEST(lambda[_1](x)(y) == y); + //BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + //BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + //BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + /* + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b1t.cpp b/libs/phoenix/test/scope/lambda_tests1b1t.cpp new file mode 100644 index 000000000..48fc753ff --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b1t.cpp @@ -0,0 +1,75 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1; + long x2 = 2; + short x3 = 3; + //char const* y = "hello"; + //zzz z; + + //BOOST_TEST(lambda[_1](x)(y) == y); + //BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + //BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + //BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + + /* + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b2.cpp b/libs/phoenix/test/scope/lambda_tests1b2.cpp new file mode 100644 index 000000000..d79468d2e --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b2.cpp @@ -0,0 +1,74 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + /* + { + int x = 1; + long x2 = 2; + short x3 = 3; + char const* y = "hello"; + zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + */ + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b2p.cpp b/libs/phoenix/test/scope/lambda_tests1b2p.cpp new file mode 100644 index 000000000..8600bc271 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b2p.cpp @@ -0,0 +1,74 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + /* + { + int x = 1; + long x2 = 2; + short x3 = 3; + char const* y = "hello"; + zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + */ + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + _1 + lambda[_1 + 2])(x)(y) == 1+1+10+2 + ); + } + /* + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b2q.cpp b/libs/phoenix/test/scope/lambda_tests1b2q.cpp new file mode 100644 index 000000000..f610a1f35 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b2q.cpp @@ -0,0 +1,74 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + /* + { + int x = 1; + long x2 = 2; + short x3 = 3; + char const* y = "hello"; + zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + */ + { + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + /* + { + int x = 1, y = 10; + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); + } + */ + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests1b2r.cpp b/libs/phoenix/test/scope/lambda_tests1b2r.cpp new file mode 100644 index 000000000..45056284d --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests1b2r.cpp @@ -0,0 +1,89 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +struct zzz {}; + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + /* + { + int x = 1; + long x2 = 2; + short x3 = 3; + char const* y = "hello"; + zzz z; + + BOOST_TEST(lambda[_1](x)(y) == y); + BOOST_TEST(lambda(_a = _1)[_a](x)(y) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a]](x)(y)(z) == x); + BOOST_TEST(lambda(_a = _1)[lambda[_a + _1]](x)(y)(x) == 2); + BOOST_TEST(lambda(_a = _1)[lambda(_b = _1)[_a + _b + _1]](x)(x2)(x3) == 6); + } + */ + /*{ + int x = 1, y = 10; + BOOST_TEST( + (_1 + lambda(_a = _1)[_a + _1 + 2])(x)(y) == 1+1+10+2 + ); + } + */ + { + int x = 1, y = 10; +#if defined(BOOST_MSVC) && (BOOST_MSVC >= 1700) + int z; + BOOST_TEST( + ( + _3 = _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(z) == 1+1+1+2 + ); +#else + BOOST_TEST( + ( + _1 + + lambda(_a = _1) + [ + _a + lambda[_a + 2] + ] + ) + (x)(y)(y) == 1+1+1+2 + ); +#endif + } + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests2.cpp b/libs/phoenix/test/scope/lambda_tests2.cpp new file mode 100644 index 000000000..2f80b0f73 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests2.cpp @@ -0,0 +1,107 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +namespace boost { namespace phoenix +{ + struct for_each_impl + { + template <typename Sig> + struct result; + + template <typename This, typename C, typename F> + struct result<This(C,F)> + { + typedef void type; + }; + + template <typename C, typename F> + void operator()(C& c, F f) const + { + std::for_each(c.begin(), c.end(), f); + } + }; + + function<for_each_impl> const for_each = for_each_impl(); + + struct push_back_impl + { + template <typename Sig> + struct result; + + template <typename This, typename C, typename T> + struct result<This(C,T)> + { + typedef void type; + }; + + template <typename C, typename T> + void operator()(C& c, T& x) const + { + c.push_back(x); + } + }; + + function<push_back_impl> const push_back = push_back_impl(); +}} + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + // using boost::phoenix::local_names::_b; + using boost::phoenix::placeholders::arg1; + + { + using boost::phoenix::for_each; + //#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800)) + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + std::vector<int> v(init, init+10); + + int x = 0; + for_each(_1, lambda(_a = _2)[_a += _1])(v, x); + BOOST_TEST(x == 55); + //#endif + } + + { + using boost::phoenix::for_each; + using boost::phoenix::push_back; + + //#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800)) + int x = 10; + std::vector<std::vector<int> > v(10); + for_each(_1, lambda(_a = _2)[push_back(_1, _a)])(v, x); + + int y = 0; + for_each(arg1, lambda[ref(y) += _1[0]])(v); + BOOST_TEST(y == 100); + //#endif + } + + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/lambda_tests2a.cpp b/libs/phoenix/test/scope/lambda_tests2a.cpp new file mode 100644 index 000000000..c8b8fb516 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests2a.cpp @@ -0,0 +1,66 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +//#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> +#include <boost/phoenix/stl/algorithm.hpp> +#include <boost/phoenix/stl/container.hpp> + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + // using boost::phoenix::local_names::_b; + using boost::phoenix::placeholders::arg1; + + { + using boost::phoenix::for_each; + //#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800)) + int init[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + std::vector<int> v(init, init+10); + + int x = 0; + for_each(_1, lambda(_a = _2)[_a += _1])(v, x); + BOOST_TEST(x == 55); + //#endif + } + + { + using boost::phoenix::for_each; + using boost::phoenix::push_back; + + //#if (!defined(BOOST_MSVC) || (BOOST_MSVC < 1800)) + int x = 10; + std::vector<std::vector<int> > v(10); + for_each(_1, lambda(_a = _2)[push_back(_1, _a)])(v, x); + + int y = 0; + for_each(arg1, lambda[ref(y) += _1[0]])(v); + BOOST_TEST(y == 100); + //#endif + } + + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/lambda_tests3.cpp b/libs/phoenix/test/scope/lambda_tests3.cpp new file mode 100644 index 000000000..0e7df7699 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests3.cpp @@ -0,0 +1,71 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + + { + int x = 1, y = 10, z = 13; + + BOOST_TEST( + lambda(_a = _1, _b = _2) + [ + _1 + _a + _b + ] + (x, z)(y) == x + y + z + ); + } + + { + { + // $$$ Fixme. This should not be failing $$$ + //int x = (let(_a = lambda[val(1)])[_a])()(); + //BOOST_TEST(x == 1); + } + + { + // int x = (let(_a = lambda[val(1)])[bind(_a)])(); + // BOOST_TEST(x == 1); + // Take this out too, I am not sure about this. + } + } + + { + int i = 0; + int j = 2; + BOOST_TEST(lambda[let(_a = _1)[_a = _2]]()(i, j) == j); + BOOST_TEST(i == j); + } + + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests3a.cpp b/libs/phoenix/test/scope/lambda_tests3a.cpp new file mode 100644 index 000000000..ce9846fe9 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests3a.cpp @@ -0,0 +1,76 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + /* + { + int x = 1, y = 10, z = 13; + + BOOST_TEST( + lambda(_a = _1, _b = _2) + [ + _1 + _a + _b + ] + (x, z)(y) == x + y + z + ); + } + */ + { + { + // $$$ Fixme. This should not be failing $$$ + //int x = (let(_a = lambda[val(1)])[_a])()(); + //BOOST_TEST(x == 1); + } + + { +//#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ +#if defined(__OPTIMIZE__) && __OPTIMIZE__ + int x = (let(_a = _1)[bind(_a)])(lambda[val(1)]()); +#else + int x = (let(_a = lambda[val(1)])[bind(_a)])(); +#endif + BOOST_TEST(x == 1); + // Take this out too, I am not sure about this. + } + } + /* + { + int i = 0; + int j = 2; + BOOST_TEST(lambda[let(_a = _1)[_a = _2]]()(i, j) == j); + BOOST_TEST(i == j); + } + */ + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests3a1.cpp b/libs/phoenix/test/scope/lambda_tests3a1.cpp new file mode 100644 index 000000000..69525e3d4 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests3a1.cpp @@ -0,0 +1,71 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + /* + { + int x = 1, y = 10, z = 13; + + BOOST_TEST( + lambda(_a = _1, _b = _2) + [ + _1 + _a + _b + ] + (x, z)(y) == x + y + z + ); + } + */ + { + { + // $$$ Fixme. This should not be failing $$$ + //int x = (let(_a = lambda[val(1)])[_a])()(); + //BOOST_TEST(x == 1); + } + + { + int x = (let(_a = _1)[bind(_a)])(lambda[val(1)]()); + BOOST_TEST(x == 1); + // Take this out too, I am not sure about this. + } + } + /* + { + int i = 0; + int j = 2; + BOOST_TEST(lambda[let(_a = _1)[_a = _2]]()(i, j) == j); + BOOST_TEST(i == j); + } + */ + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/lambda_tests3b.cpp b/libs/phoenix/test/scope/lambda_tests3b.cpp new file mode 100644 index 000000000..1d60580d7 --- /dev/null +++ b/libs/phoenix/test/scope/lambda_tests3b.cpp @@ -0,0 +1,72 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2014 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <typeinfo> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/bind.hpp> +#include <boost/phoenix/scope.hpp> + +int +main() +{ + using boost::phoenix::lambda; + using boost::phoenix::let; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + // using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + // using boost::phoenix::placeholders::arg1; + + /* + { + int x = 1, y = 10, z = 13; + + BOOST_TEST( + lambda(_a = _1, _b = _2) + [ + _1 + _a + _b + ] + (x, z)(y) == x + y + z + ); + } + */ + { + { + // $$$ Fixme. This should not be failing $$$ + //int x = (let(_a = lambda[val(1)])[_a])()(); + //BOOST_TEST(x == 1); + } + + { + //int x = (let(_a = lambda[val(1)])[bind(_a)])(); + int x = (let(_a = _1)[bind(_a)])(lambda[val(1)]()); + BOOST_TEST(x == 1); + // Take this out too, I am not sure about this. + } + } + /* + { + int i = 0; + int j = 2; + BOOST_TEST(lambda[let(_a = _1)[_a = _2]]()(i, j) == j); + BOOST_TEST(i == j); + } + */ + + return boost::report_errors(); +} diff --git a/libs/phoenix/test/scope/let_tests.cpp b/libs/phoenix/test/scope/let_tests.cpp index 89170418b..34350ea7c 100644 --- a/libs/phoenix/test/scope/let_tests.cpp +++ b/libs/phoenix/test/scope/let_tests.cpp @@ -109,9 +109,9 @@ main() { int x = 999; - + /* BOOST_TEST( - let(_x = val(_1)) // _x holds x by value + let(_x = val(_1)) // _x holds x by value [ _x += 888 ] @@ -119,9 +119,9 @@ main() ); BOOST_TEST(x == 999); - + */ BOOST_TEST( - let(_x = val(_1)) // _x holds x by value + let(_x = val(_1)) // _x holds x by value [ val(_x += 888) ] @@ -152,8 +152,11 @@ main() { // show that we can return a local from an outer scope int y = 0; +#if defined(__OPTIMIZE__) && __OPTIMIZE__ + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); +#else int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); - +#endif BOOST_TEST(x == 1); } diff --git a/libs/phoenix/test/scope/let_tests_113.cpp b/libs/phoenix/test/scope/let_tests_113.cpp new file mode 100644 index 000000000..c8ebea171 --- /dev/null +++ b/libs/phoenix/test/scope/let_tests_113.cpp @@ -0,0 +1,204 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::ref; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + //using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + */ + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) // so use value here too. + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + /* + BOOST_TEST( + let(_x = ref(_1)) // _x holds x by reference + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + */ + + BOOST_TEST( + let( _x = _1 ) // _x holds x by reference + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + /* + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/let_tests_113a.cpp b/libs/phoenix/test/scope/let_tests_113a.cpp new file mode 100644 index 000000000..6d84e4848 --- /dev/null +++ b/libs/phoenix/test/scope/let_tests_113a.cpp @@ -0,0 +1,192 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + //using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + //using boost::phoenix::local_names::_a; + //using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + */ + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + /* + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); */ + } + /* + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/let_tests_157.cpp b/libs/phoenix/test/scope/let_tests_157.cpp new file mode 100644 index 000000000..7979cea4f --- /dev/null +++ b/libs/phoenix/test/scope/let_tests_157.cpp @@ -0,0 +1,194 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + //using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + } + + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + */ + { + // show that we can return a local from an outer scope + int y = 0; +#if defined(__OPTIMIZE__) && __OPTIMIZE__ + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); +#else + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); +#endif + BOOST_TEST(x == 1); + } + /* + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/let_tests_157a.cpp b/libs/phoenix/test/scope/let_tests_157a.cpp new file mode 100644 index 000000000..83dd33ac8 --- /dev/null +++ b/libs/phoenix/test/scope/let_tests_157a.cpp @@ -0,0 +1,191 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + //using boost::phoenix::local_names::_c; + //using boost::phoenix::local_names::_d; + //using boost::phoenix::local_names::_e; + //using boost::phoenix::local_names::_x; + //using boost::phoenix::local_names::_y; + //using boost::phoenix::local_names::_z; + //using boost::phoenix::placeholders::arg1; + /* + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + } + + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + */ + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); + + BOOST_TEST(x == 1); + } + /* + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + */ + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/let_tests_rest.cpp b/libs/phoenix/test/scope/let_tests_rest.cpp new file mode 100644 index 000000000..9200d31d9 --- /dev/null +++ b/libs/phoenix/test/scope/let_tests_rest.cpp @@ -0,0 +1,192 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::arg_names::_3; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + using boost::phoenix::local_names::_c; + using boost::phoenix::local_names::_d; + using boost::phoenix::local_names::_e; + using boost::phoenix::local_names::_x; + using boost::phoenix::local_names::_y; + using boost::phoenix::local_names::_z; + using boost::phoenix::placeholders::arg1; + + { + int x = 1; + BOOST_TEST( + let(_a = _1) + [ + _a + ] + (x) == x + ) + ; + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_a = _1, _b = _2) + [ + _a + _b + ] + (x, y) == x + y + ); + } + + { + int x = 1, y = 10, z = 13; + BOOST_TEST( + let(_x = _1, _y = _2) + [ + let(_z = _3) + [ + _x + _y + _z + ] + ] + (x, y, z) == x + y + z + ); + } + + { + int x = 1, y = 10; + BOOST_TEST( + let(_x = _1) + [ + _x + + let(_x = _2) + [ + -_x + ] + ] + (x, y) == x + -y + ); + } + + { + int x = 999; + BOOST_TEST( + let(_x = _1) // _x is a reference to x + [ + _x += 888 + ] + (x) == 999 + 888 + ); + + BOOST_TEST(x == 888 + 999); + } + /* + { + int x = 999; + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + _x += 888 + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + + BOOST_TEST( + let(_x = val(_1)) // _x holds x by value + [ + val(_x += 888) + ] + (x) == x + 888 + ); + + BOOST_TEST(x == 999); + } + */ + { + BOOST_TEST( + let(_a = 1, _b = 2, _c = 3, _d = 4, _e = 5) + [ + _a + _b + _c + _d + _e + ] + () == 1 + 2 + 3 + 4 + 5 + ); + } + +#ifdef PHOENIX_SHOULD_NOT_COMPILE_TEST + { + // disallow this: + int i; + (_a + _b)(i); + } +#endif + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + */ + { + // show that this code returns an lvalue + int i = 1; + let(_a = arg1)[ _a ](i)++; + BOOST_TEST(i == 2); + } + + { + // show that what you put in is what you get out + int i = 1; + int& j = let(_a = arg1)[_a](i); + BOOST_TEST(&i == &j); + } + + { + using boost::phoenix::at_c; + + boost::fusion::tuple<int, int> t = boost::fusion::make_tuple(0, 1); + int i = let(_a = at_c<0>(_1))[_a](t); + + BOOST_TEST( i == 0 ); + } + + { + int i = 0; + let(_a = _1)[_a = _2](i, 2); + BOOST_TEST(i == 2); + } + + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/more_lambda_tests.cpp b/libs/phoenix/test/scope/more_lambda_tests.cpp index 3f5302773..ea9209dc7 100644 --- a/libs/phoenix/test/scope/more_lambda_tests.cpp +++ b/libs/phoenix/test/scope/more_lambda_tests.cpp @@ -22,10 +22,10 @@ main() using boost::phoenix::ref; using boost::phoenix::val; using boost::phoenix::arg_names::_1; - using boost::phoenix::arg_names::_2; + //using boost::phoenix::arg_names::_2; using boost::phoenix::local_names::_a; - using boost::phoenix::local_names::_b; - using boost::phoenix::placeholders::arg1; + // using boost::phoenix::local_names::_b; + //using boost::phoenix::placeholders::arg1; { int x = 1; @@ -39,4 +39,10 @@ main() BOOST_TEST(x+1 == y); } + { + int x = lambda[val(1)]()(); + BOOST_TEST(x == 1); + } + + return boost::report_errors(); } diff --git a/libs/phoenix/test/scope/more_let_tests.cpp b/libs/phoenix/test/scope/more_let_tests.cpp index cfc5b11ec..5950e6ef1 100644 --- a/libs/phoenix/test/scope/more_let_tests.cpp +++ b/libs/phoenix/test/scope/more_let_tests.cpp @@ -1,7 +1,8 @@ /*============================================================================= Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher - Distributed under the Boost Software License, Version 1.0. (See accompanying + Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #include <iostream> @@ -31,22 +32,17 @@ main() using boost::phoenix::val; using boost::phoenix::arg_names::_1; using boost::phoenix::arg_names::_2; - using boost::phoenix::arg_names::_3; using boost::phoenix::local_names::_a; using boost::phoenix::local_names::_b; - using boost::phoenix::local_names::_c; - using boost::phoenix::local_names::_d; - using boost::phoenix::local_names::_e; - using boost::phoenix::local_names::_x; - using boost::phoenix::local_names::_y; - using boost::phoenix::local_names::_z; - using boost::phoenix::placeholders::arg1; { // show that we can return a local from an outer scope int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _1)[ _a + 0 ]])(y); +#else int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); - +#endif BOOST_TEST(x == 1); } { @@ -59,15 +55,21 @@ main() { // show that we can return a local from an outer scope //int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _a)[ _a + 0 ]])(); +#else int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); - +#endif BOOST_TEST(x == 1); } { // show that we can return a local from an inner scope //int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _a)[ _b + 0 ]])(); +#else int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); - +#endif BOOST_TEST(x == 1); } { @@ -92,24 +94,41 @@ main() //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ { int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a + 0 ]])(y); +#else int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); +#endif //std::cout << x << " P1A "; //clang - empty memory BOOST_TEST(x == 1); } { int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b + 0 ]])(y); +#else int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); +#endif //std::cout << x << " P1B "; //clang - 42 value- one step better BOOST_TEST(x == 1); } { int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ val(_a) ]])(y); +#else int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); +#endif //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); } { int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ val(_b) ]])(y); +#else int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); +#endif //std::cout << x << " P2B "; //clang - 42 value - one step better BOOST_TEST(x == 1); } @@ -122,7 +141,11 @@ main() { int y = 0; +#ifdef __OPTIMIZE__ + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a + 0 ]])(y); +#else int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); +#endif // std::cout << x << " Q "; // clang 4201472 BOOST_TEST(x == 1); } diff --git a/libs/phoenix/test/scope/more_let_tests1.cpp b/libs/phoenix/test/scope/more_let_tests1.cpp new file mode 100644 index 000000000..d4dddf1e4 --- /dev/null +++ b/libs/phoenix/test/scope/more_let_tests1.cpp @@ -0,0 +1,136 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + + { + // show that we can return a local from an outer scope + int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int x = (let(_a = _2)[let(_b = _1)[ _a ]])(y,1); +#else + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); +#else + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(1); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(1); +#else + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); +#endif + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /* { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + */ + + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/more_let_tests2.cpp b/libs/phoenix/test/scope/more_let_tests2.cpp new file mode 100644 index 000000000..fb3fff8c1 --- /dev/null +++ b/libs/phoenix/test/scope/more_let_tests2.cpp @@ -0,0 +1,125 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + */ + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + + + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/more_let_tests2a.cpp b/libs/phoenix/test/scope/more_let_tests2a.cpp new file mode 100644 index 000000000..9a4aca716 --- /dev/null +++ b/libs/phoenix/test/scope/more_let_tests2a.cpp @@ -0,0 +1,126 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + */ + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + /* { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + */ + + return boost::report_errors(); +} + diff --git a/libs/phoenix/test/scope/more_let_tests2b.cpp b/libs/phoenix/test/scope/more_let_tests2b.cpp new file mode 100644 index 000000000..b6039f8f1 --- /dev/null +++ b/libs/phoenix/test/scope/more_let_tests2b.cpp @@ -0,0 +1,136 @@ +/*============================================================================= + Copyright (c) 2001-2007 Joel de Guzman + Copyright (c) 2015 John Fletcher + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <iostream> +#include <cmath> +#include <algorithm> +#include <vector> + +#include <boost/phoenix/core/limits.hpp> + +#include <boost/detail/lightweight_test.hpp> +#include <boost/fusion/tuple.hpp> +#include <boost/phoenix/core.hpp> +#include <boost/phoenix/operator.hpp> +#include <boost/phoenix/function.hpp> +#include <boost/phoenix/fusion.hpp> +#include <boost/phoenix/scope.hpp> + +#include <typeinfo> + +namespace fusion = boost::fusion; +namespace mpl = boost::mpl; + +int +main() +{ + using boost::phoenix::let; + using boost::phoenix::val; + using boost::phoenix::arg_names::_1; + using boost::phoenix::arg_names::_2; + using boost::phoenix::local_names::_a; + using boost::phoenix::local_names::_b; + /* + { + // show that we can return a local from an outer scope + int y = 0; + int x = (let(_a = 1)[let(_b = _1)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = 0)[let(_b = _1)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _a ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + //int y = 0; + int x = (let(_a = 1)[let(_b = _a)[ _b ]])(); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an outer scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _a ]])(y); + + BOOST_TEST(x == 1); + } + { + // show that we can return a local from an inner scope + int y = 1; + int x = (let(_a = _1)[let(_b = _a)[ _b ]])(y); + + BOOST_TEST(x == 1); + } + */ + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + // Be very careful. Some of these cases give a silly answer + // with clang 3.4 with C++03 and work for C++11. + // gcc 4.8.2 seems O.K. both ways. Oh dear. + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + /*{ + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P1A "; //clang - empty memory + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = 1, _b = 2)[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P1B "; //clang - 42 value- one step better + BOOST_TEST(x == 1); + } + { + int y = 0; + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P2A "; //clang - 42 value - one step better + BOOST_TEST(x == 1); + }*/ + { + int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + //int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); +#else + int x = (let(_a = val(1), _b = val(2))[let(_b = _a)[ _b ]])(y); + //std::cout << x << " P2B "; //clang - 42 value - one step better + BOOST_TEST(x == 1); +#endif + } + { + int y = 1; + int x = (let(_a = _1, _b = val(2))[let(_b = _a)[ _a ]])(y); + //std::cout << x << " P3 "; //clang - OK - one step better still + BOOST_TEST(x == 1); + } + + { + int y = 0; +#if defined(BOOST_GCC_VERSION) && (BOOST_GCC_VERSION >= 50000) && __OPTIMIZE__ + int z = 2; + int x = (let(_a = _1, _b = _2)[let(_b = _1)[ _a ]])(y,z); +#else + int x = (let(_a = 1, _b = 2)[let(_b = _1)[ _a ]])(y); +#endif + // std::cout << x << " Q "; // clang 4201472 + BOOST_TEST(x == 1); + } + + + return boost::report_errors(); +} + |