]>
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/bool.hpp> | |
6 | #include <boost/hana/equal.hpp> | |
7 | #include <boost/hana/functional/always.hpp> | |
8 | #include <boost/hana/tuple.hpp> | |
9 | ||
10 | #include <laws/applicative.hpp> | |
11 | #include <laws/base.hpp> | |
12 | #include <laws/comparable.hpp> | |
13 | #include <laws/foldable.hpp> | |
14 | #include <laws/functor.hpp> | |
15 | #include <laws/iterable.hpp> | |
16 | #include <laws/monad.hpp> | |
17 | #include <laws/monad_plus.hpp> | |
18 | #include <laws/orderable.hpp> | |
19 | #include <laws/searchable.hpp> | |
20 | #include <laws/sequence.hpp> | |
21 | #include <support/seq.hpp> | |
22 | namespace hana = boost::hana; | |
23 | using hana::test::ct_eq; | |
24 | using hana::test::ct_ord; | |
25 | ||
26 | ||
27 | int main() { | |
28 | auto eqs = hana::make_tuple( | |
29 | ::seq() | |
30 | , ::seq(ct_eq<0>{}) | |
31 | , ::seq(ct_eq<0>{}, ct_eq<1>{}) | |
32 | , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) | |
33 | , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) | |
34 | ); | |
35 | (void)eqs; | |
36 | ||
37 | auto nested_eqs = hana::make_tuple( | |
38 | ::seq() | |
39 | , ::seq( | |
40 | ::seq(ct_eq<0>{})) | |
41 | , ::seq( | |
42 | ::seq(ct_eq<0>{}), | |
43 | ::seq(ct_eq<1>{}, ct_eq<2>{})) | |
44 | , ::seq( | |
45 | ::seq(ct_eq<0>{}), | |
46 | ::seq(ct_eq<1>{}, ct_eq<2>{}), | |
47 | ::seq(ct_eq<3>{}, ct_eq<4>{})) | |
48 | ); | |
49 | (void)nested_eqs; | |
50 | ||
51 | auto eq_keys = hana::make_tuple(ct_eq<0>{}, ct_eq<3>{}, ct_eq<10>{}); | |
52 | (void)eq_keys; | |
53 | ||
54 | auto predicates = hana::make_tuple( | |
55 | hana::equal.to(ct_eq<0>{}), hana::equal.to(ct_eq<3>{}), hana::equal.to(ct_eq<10>{}), | |
56 | hana::always(hana::true_c), hana::always(hana::false_c) | |
57 | ); | |
58 | (void)predicates; | |
59 | ||
60 | auto ords = hana::make_tuple( | |
61 | ::seq() | |
62 | , ::seq(ct_ord<0>{}) | |
63 | , ::seq(ct_ord<0>{}, ct_ord<1>{}) | |
64 | , ::seq(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) | |
65 | , ::seq(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}) | |
66 | ); | |
67 | (void)ords; | |
68 | ||
69 | ////////////////////////////////////////////////////////////////////////// | |
70 | // Comparable, Orderable | |
71 | ////////////////////////////////////////////////////////////////////////// | |
72 | #ifdef BOOST_HANA_TEST_ORDERABLE | |
73 | hana::test::TestComparable<::Seq>{eqs}; | |
74 | hana::test::TestOrderable<::Seq>{ords}; | |
75 | #endif | |
76 | ||
77 | #ifdef BOOST_HANA_TEST_ITERABLE | |
78 | ////////////////////////////////////////////////////////////////////////// | |
79 | // Foldable | |
80 | ////////////////////////////////////////////////////////////////////////// | |
81 | hana::test::TestFoldable<::Seq>{eqs}; | |
82 | ||
83 | ////////////////////////////////////////////////////////////////////////// | |
84 | // Iterable | |
85 | ////////////////////////////////////////////////////////////////////////// | |
86 | { | |
87 | hana::test::TestIterable<::Seq>{eqs}; | |
88 | } | |
89 | #endif | |
90 | ||
91 | ////////////////////////////////////////////////////////////////////////// | |
92 | // Searchable | |
93 | ////////////////////////////////////////////////////////////////////////// | |
94 | #ifdef BOOST_HANA_TEST_SEARCHABLE | |
95 | { | |
96 | hana::test::TestSearchable<::Seq>{eqs, eq_keys}; | |
97 | ||
98 | auto bools = hana::make_tuple( | |
99 | ::seq(hana::true_c) | |
100 | , ::seq(hana::false_c) | |
101 | , ::seq(hana::true_c, hana::true_c) | |
102 | , ::seq(hana::true_c, hana::false_c) | |
103 | , ::seq(hana::false_c, hana::true_c) | |
104 | , ::seq(hana::false_c, hana::false_c) | |
105 | ); | |
106 | hana::test::TestSearchable<::Seq>{bools, hana::make_tuple(hana::true_c, hana::false_c)}; | |
107 | } | |
108 | #endif | |
109 | ||
110 | ////////////////////////////////////////////////////////////////////////// | |
111 | // Functor, Applicative, Monad | |
112 | ////////////////////////////////////////////////////////////////////////// | |
113 | #ifdef BOOST_HANA_TEST_MONAD | |
114 | hana::test::TestFunctor<::Seq>{eqs, eq_keys}; | |
115 | hana::test::TestApplicative<::Seq>{eqs}; | |
116 | hana::test::TestMonad<::Seq>{eqs, nested_eqs}; | |
117 | #endif | |
118 | ||
119 | ////////////////////////////////////////////////////////////////////////// | |
120 | // MonadPlus | |
121 | ////////////////////////////////////////////////////////////////////////// | |
122 | #ifdef BOOST_HANA_TEST_MONAD_PLUS | |
123 | hana::test::TestMonadPlus<::Seq>{eqs, predicates, eq_keys}; | |
124 | #endif | |
125 | ||
126 | ////////////////////////////////////////////////////////////////////////// | |
127 | // Sequence | |
128 | ////////////////////////////////////////////////////////////////////////// | |
129 | #ifdef BOOST_HANA_TEST_SEQUENCE | |
130 | hana::test::TestSequence<::Seq>{}; | |
131 | #endif | |
132 | } |