1 //////////////////////////////////////////////////////////////////
2 //
3 // lazy_thunk_tests.cpp
4 //
5 // Tests for thunk functions.
6 //
7 //
8 /*=============================================================================
9     Copyright (c) 2000-2003 Brian McNamara and Yannis Smaragdakis
10     Copyright (c) 2001-2007 Joel de Guzman
11     Copyright (c) 2015 John Fletcher
12 
13     Distributed under the Boost Software License, Version 1.0. (See accompanying
14     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
15 ==============================================================================*/
16 
17 #include <iostream>
18 #include <boost/phoenix/core.hpp>
19 #include <boost/phoenix/function.hpp>
20 #include <boost/shared_ptr.hpp>
21 #include <boost/phoenix/function/lazy_prelude.hpp>
22 
23 #include <boost/detail/lightweight_test.hpp>
24 
25 using namespace boost::phoenix;
26 
27 using std::cout;
28 using std::endl;
29 
30 
31 
main()32 int main() {
33    using boost::phoenix::arg_names::arg1;
34    using boost::phoenix::arg_names::arg2;
35 
36    BOOST_TEST( thunk1(inc,1)()()             == 2);
37    BOOST_TEST( thunk1(inc,arg1)(1)()         == 2);
38    BOOST_TEST( thunk2(plus,1,2)()()          == 3);
39    BOOST_TEST( thunk2(plus,arg1,arg2)(1,2)() == 3);
40 
41    list<int> l  = enum_from_to(1,5);
42    list<int> l4 = take(4,l)();
43    BOOST_TEST( foldl(plus,0,l4)()              == 10);
44    BOOST_TEST( thunk3(foldl,plus,0,l4)()()     == 10);
45    BOOST_TEST( thunk3(foldl,plus,arg1,l4)(0)() == 10);
46 
47    return boost::report_errors();
48 }
49