1 /*==============================================================================
2 Copyright (c) 2005, 2008 Peter Dimov
3 Copyright (c) 2005-2010 Joel de Guzman
4 Copyright (c) 2010 Thomas Heller
5
6 Distributed under the Boost Software License, Version 1.0. (See accompanying
7 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9
10 #include <boost/config.hpp>
11
12 #if defined(BOOST_MSVC)
13 #pragma warning(disable: 4786) // identifier truncated in debug info
14 #pragma warning(disable: 4710) // function not inlined
15 #pragma warning(disable: 4711) // function selected for automatic inline expansion
16 #pragma warning(disable: 4514) // unreferenced inline removed
17 #endif
18
19 #include <boost/phoenix/core.hpp>
20 #include <boost/phoenix/bind.hpp>
21
22 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
23 #pragma warning(push, 3)
24 #endif
25
26 #include <iostream>
27
28 #if defined(BOOST_MSVC) && (BOOST_MSVC < 1300)
29 #pragma warning(pop)
30 #endif
31
32 #include <boost/detail/lightweight_test.hpp>
33
34 long global_result;
35
36 // long
37
f_0()38 long f_0()
39 {
40 return global_result = 17041L;
41 }
42
f_1(long a)43 long f_1(long a)
44 {
45 return global_result = a;
46 }
47
f_2(long a,long b)48 long f_2(long a, long b)
49 {
50 return global_result = a + 10 * b;
51 }
52
f_3(long a,long b,long c)53 long f_3(long a, long b, long c)
54 {
55 return global_result = a + 10 * b + 100 * c;
56 }
57
f_4(long a,long b,long c,long d)58 long f_4(long a, long b, long c, long d)
59 {
60 return global_result = a + 10 * b + 100 * c + 1000 * d;
61 }
62
f_5(long a,long b,long c,long d,long e)63 long f_5(long a, long b, long c, long d, long e)
64 {
65 return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
66 }
67
f_6(long a,long b,long c,long d,long e,long f)68 long f_6(long a, long b, long c, long d, long e, long f)
69 {
70 return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
71 }
72
f_7(long a,long b,long c,long d,long e,long f,long g)73 long f_7(long a, long b, long c, long d, long e, long f, long g)
74 {
75 return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
76 }
77
f_8(long a,long b,long c,long d,long e,long f,long g,long h)78 long f_8(long a, long b, long c, long d, long e, long f, long g, long h)
79 {
80 return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
81 }
82
f_9(long a,long b,long c,long d,long e,long f,long g,long h,long i)83 long f_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
84 {
85 return global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
86 }
87
88 // void
89
fv_0()90 void fv_0()
91 {
92 global_result = 17041L;
93 }
94
fv_1(long a)95 void fv_1(long a)
96 {
97 global_result = a;
98 }
99
fv_2(long a,long b)100 void fv_2(long a, long b)
101 {
102 global_result = a + 10 * b;
103 }
104
fv_3(long a,long b,long c)105 void fv_3(long a, long b, long c)
106 {
107 global_result = a + 10 * b + 100 * c;
108 }
109
fv_4(long a,long b,long c,long d)110 void fv_4(long a, long b, long c, long d)
111 {
112 global_result = a + 10 * b + 100 * c + 1000 * d;
113 }
114
fv_5(long a,long b,long c,long d,long e)115 void fv_5(long a, long b, long c, long d, long e)
116 {
117 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e;
118 }
119
fv_6(long a,long b,long c,long d,long e,long f)120 void fv_6(long a, long b, long c, long d, long e, long f)
121 {
122 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f;
123 }
124
fv_7(long a,long b,long c,long d,long e,long f,long g)125 void fv_7(long a, long b, long c, long d, long e, long f, long g)
126 {
127 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g;
128 }
129
fv_8(long a,long b,long c,long d,long e,long f,long g,long h)130 void fv_8(long a, long b, long c, long d, long e, long f, long g, long h)
131 {
132 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h;
133 }
134
fv_9(long a,long b,long c,long d,long e,long f,long g,long h,long i)135 void fv_9(long a, long b, long c, long d, long e, long f, long g, long h, long i)
136 {
137 global_result = a + 10 * b + 100 * c + 1000 * d + 10000 * e + 100000 * f + 1000000 * g + 10000000 * h + 100000000 * i;
138 }
139
function_test()140 void function_test()
141 {
142 using boost::phoenix::bind;
143
144 bind( f_0 )(); BOOST_TEST( global_result == 17041L );
145 bind( f_1, 1 )(); BOOST_TEST( global_result == 1L );
146 bind( f_2, 1, 2 )(); BOOST_TEST( global_result == 21L );
147 bind( f_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L );
148 bind( f_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L );
149 bind( f_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L );
150 bind( f_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L );
151 bind( f_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L );
152 bind( f_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L );
153 bind( f_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L );
154
155 bind( fv_0 )(); BOOST_TEST( global_result == 17041L );
156 bind( fv_1, 1 )(); BOOST_TEST( global_result == 1L );
157 bind( fv_2, 1, 2 )(); BOOST_TEST( global_result == 21L );
158 bind( fv_3, 1, 2, 3 )(); BOOST_TEST( global_result == 321L );
159 bind( fv_4, 1, 2, 3, 4 )(); BOOST_TEST( global_result == 4321L );
160 bind( fv_5, 1, 2, 3, 4, 5 )(); BOOST_TEST( global_result == 54321L );
161 bind( fv_6, 1, 2, 3, 4, 5, 6 )(); BOOST_TEST( global_result == 654321L );
162 bind( fv_7, 1, 2, 3, 4, 5, 6, 7 )(); BOOST_TEST( global_result == 7654321L );
163 bind( fv_8, 1, 2, 3, 4, 5, 6, 7, 8 )(); BOOST_TEST( global_result == 87654321L );
164 bind( fv_9, 1, 2, 3, 4, 5, 6, 7, 8, 9 )(); BOOST_TEST( global_result == 987654321L );
165 }
166
main()167 int main()
168 {
169 function_test();
170 return boost::report_errors();
171 }
172