1 // Copyright Louis Dionne 2013-2017
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4 
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/equal.hpp>
7 #include <boost/hana/functional/capture.hpp>
8 
9 #include <laws/base.hpp>
10 namespace hana = boost::hana;
11 using hana::test::ct_eq;
12 
13 
main()14 int main() {
15     hana::test::_injection<0> f{};
16 
17     // 0-arg capture
18     BOOST_HANA_CONSTANT_CHECK(hana::equal(
19         hana::capture()(f)(),
20         f()
21     ));
22 
23     BOOST_HANA_CONSTANT_CHECK(hana::equal(
24         hana::capture()(f)(ct_eq<0>{}),
25         f(ct_eq<0>{})
26     ));
27 
28     BOOST_HANA_CONSTANT_CHECK(hana::equal(
29         hana::capture()(f)(ct_eq<0>{}, ct_eq<1>{}),
30         f(ct_eq<0>{}, ct_eq<1>{})
31     ));
32 
33     BOOST_HANA_CONSTANT_CHECK(hana::equal(
34         hana::capture()(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
35         f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
36     ));
37 
38     // 1-arg capture
39     BOOST_HANA_CONSTANT_CHECK(hana::equal(
40         hana::capture(ct_eq<77>{})(f)(),
41         f(ct_eq<77>{})
42     ));
43 
44     BOOST_HANA_CONSTANT_CHECK(hana::equal(
45         hana::capture(ct_eq<77>{})(f)(ct_eq<0>{}),
46         f(ct_eq<77>{}, ct_eq<0>{})
47     ));
48 
49     BOOST_HANA_CONSTANT_CHECK(hana::equal(
50         hana::capture(ct_eq<77>{})(f)(ct_eq<0>{}, ct_eq<1>{}),
51         f(ct_eq<77>{}, ct_eq<0>{}, ct_eq<1>{})
52     ));
53 
54     BOOST_HANA_CONSTANT_CHECK(hana::equal(
55         hana::capture(ct_eq<77>{})(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
56         f(ct_eq<77>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
57     ));
58 
59     // 2-args capture
60     BOOST_HANA_CONSTANT_CHECK(hana::equal(
61         hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(),
62         f(ct_eq<77>{}, ct_eq<88>{})
63     ));
64 
65     BOOST_HANA_CONSTANT_CHECK(hana::equal(
66         hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(ct_eq<0>{}),
67         f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<0>{})
68     ));
69 
70     BOOST_HANA_CONSTANT_CHECK(hana::equal(
71         hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(ct_eq<0>{}, ct_eq<1>{}),
72         f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<0>{}, ct_eq<1>{})
73     ));
74 
75     BOOST_HANA_CONSTANT_CHECK(hana::equal(
76         hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
77         f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
78     ));
79 
80     // 3-args capture
81     BOOST_HANA_CONSTANT_CHECK(hana::equal(
82         hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(),
83         f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})
84     ));
85 
86     BOOST_HANA_CONSTANT_CHECK(hana::equal(
87         hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(ct_eq<0>{}),
88         f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{}, ct_eq<0>{})
89     ));
90 
91     BOOST_HANA_CONSTANT_CHECK(hana::equal(
92         hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(ct_eq<0>{}, ct_eq<1>{}),
93         f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{}, ct_eq<0>{}, ct_eq<1>{})
94     ));
95 
96     BOOST_HANA_CONSTANT_CHECK(hana::equal(
97         hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}),
98         f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})
99     ));
100 }
101