]>
Commit | Line | Data |
---|---|---|
b32b8144 | 1 | // Copyright Louis Dionne 2013-2017 |
7c673cae FG |
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/ap.hpp> | |
6 | #include <boost/hana/assert.hpp> | |
7 | #include <boost/hana/equal.hpp> | |
8 | #include <boost/hana/experimental/view.hpp> | |
9 | #include <boost/hana/functional/id.hpp> | |
10 | ||
11 | #include <laws/base.hpp> | |
12 | #include <support/seq.hpp> | |
13 | namespace hana = boost::hana; | |
14 | using hana::test::_injection; | |
15 | using hana::test::ct_eq; | |
16 | ||
17 | ||
18 | int main() { | |
19 | auto container = ::seq; | |
20 | auto f = hana::test::_injection<99>{}; | |
21 | ||
22 | { | |
23 | auto storage = container(); | |
24 | auto functions = container(); | |
25 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
26 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
27 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
28 | hana::ap(transformed_functions, transformed_storage), | |
29 | container() | |
30 | )); | |
31 | }{ | |
32 | auto storage = container(ct_eq<0>{}); | |
33 | auto functions = container(); | |
34 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
35 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
36 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
37 | hana::ap(transformed_functions, transformed_storage), | |
38 | container() | |
39 | )); | |
40 | }{ | |
41 | auto storage = container(); | |
42 | auto functions = container(ct_eq<0>{}); | |
43 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
44 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
45 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
46 | hana::ap(transformed_functions, transformed_storage), | |
47 | container() | |
48 | )); | |
49 | } | |
50 | ||
51 | { | |
52 | auto storage = container(ct_eq<0>{}); | |
53 | auto functions = container(_injection<0>{}); | |
54 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
55 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
56 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
57 | hana::ap(transformed_functions, transformed_storage), | |
58 | container(_injection<0>{}(f(ct_eq<0>{}))) | |
59 | )); | |
60 | }{ | |
61 | auto storage = container(ct_eq<0>{}); | |
62 | auto functions = container(_injection<0>{}, _injection<1>{}); | |
63 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
64 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
65 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
66 | hana::ap(transformed_functions, transformed_storage), | |
67 | container(_injection<0>{}(f(ct_eq<0>{})), | |
68 | _injection<1>{}(f(ct_eq<0>{}))) | |
69 | )); | |
70 | }{ | |
71 | auto storage = container(ct_eq<0>{}); | |
72 | auto functions = container(_injection<0>{}, _injection<1>{}, _injection<2>{}); | |
73 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
74 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
75 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
76 | hana::ap(transformed_functions, transformed_storage), | |
77 | container(_injection<0>{}(f(ct_eq<0>{})), | |
78 | _injection<1>{}(f(ct_eq<0>{})), | |
79 | _injection<2>{}(f(ct_eq<0>{}))) | |
80 | )); | |
81 | } | |
82 | ||
83 | { | |
84 | auto storage = container(ct_eq<0>{}, ct_eq<1>{}); | |
85 | auto functions = container(_injection<0>{}); | |
86 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
87 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
88 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
89 | hana::ap(transformed_functions, transformed_storage), | |
90 | container(_injection<0>{}(f(ct_eq<0>{})), | |
91 | _injection<0>{}(f(ct_eq<1>{}))) | |
92 | )); | |
93 | }{ | |
94 | auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); | |
95 | auto functions = container(_injection<0>{}); | |
96 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
97 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
98 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
99 | hana::ap(transformed_functions, transformed_storage), | |
100 | container(_injection<0>{}(f(ct_eq<0>{})), | |
101 | _injection<0>{}(f(ct_eq<1>{})), | |
102 | _injection<0>{}(f(ct_eq<2>{}))) | |
103 | )); | |
104 | } | |
105 | ||
106 | { | |
107 | auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); | |
108 | auto functions = container(_injection<0>{}, _injection<1>{}); | |
109 | auto transformed_storage = hana::experimental::transformed(storage, f); | |
110 | auto transformed_functions = hana::experimental::transformed(functions, hana::id); | |
111 | BOOST_HANA_CONSTANT_CHECK(hana::equal( | |
112 | hana::ap(transformed_functions, transformed_storage), | |
113 | container(_injection<0>{}(f(ct_eq<0>{})), | |
114 | _injection<0>{}(f(ct_eq<1>{})), | |
115 | _injection<0>{}(f(ct_eq<2>{})), | |
116 | ||
117 | _injection<1>{}(f(ct_eq<0>{})), | |
118 | _injection<1>{}(f(ct_eq<1>{})), | |
119 | _injection<1>{}(f(ct_eq<2>{}))) | |
120 | )); | |
121 | } | |
122 | } |