diff --git a/example/applicative/ap.cpp b/example/applicative.cpp similarity index 84% rename from example/applicative/ap.cpp rename to example/applicative.cpp index 4ab9e1d84..dc13d6105 100644 --- a/example/applicative/ap.cpp +++ b/example/applicative.cpp @@ -13,7 +13,7 @@ using namespace boost::hana; int main() { - //! [main] + //! [ap] BOOST_HANA_CONSTEXPR_LAMBDA auto f = _ + _; BOOST_HANA_CONSTEXPR_ASSERT( ap(lift(f), list(1, 2), list(3, 4, 5)) @@ -33,5 +33,10 @@ int main() { BOOST_HANA_CONSTANT_ASSERT( ap(lift(g), just(1), nothing, just(3)) == nothing ); - //! [main] + //! [ap] + + //! [lift] + BOOST_HANA_CONSTEXPR_ASSERT(lift('x') == list('x')); + BOOST_HANA_CONSTEXPR_ASSERT(lift('x') == just('x')); + //! [lift] } diff --git a/example/applicative/lift.cpp b/example/applicative/lift.cpp deleted file mode 100644 index 6bb685e00..000000000 --- a/example/applicative/lift.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(lift('x') == list('x')); - BOOST_HANA_CONSTEXPR_ASSERT(lift('x') == just('x')); - //! [main] -} diff --git a/example/comparable/comparing.cpp b/example/comparable.cpp similarity index 68% rename from example/comparable/comparing.cpp rename to example/comparable.cpp index 0fb96cf24..f20740dbb 100644 --- a/example/comparable/comparing.cpp +++ b/example/comparable.cpp @@ -13,7 +13,7 @@ using namespace boost::hana; int main() { - //! [main] + //! [comparing] BOOST_HANA_CONSTEXPR_LAMBDA auto grouped = group_by(comparing(length), list( list(1, 2, 3), list('x', 'y', 'z'), @@ -37,5 +37,17 @@ int main() { list(123.4, nullptr) ) )); - //! [main] + //! [comparing] + + //! [equal] + BOOST_HANA_CONSTEXPR_ASSERT(equal(list(1, 2), list(1, 2))); + BOOST_HANA_CONSTEXPR_ASSERT(!equal('x', 'y')); + BOOST_HANA_CONSTANT_ASSERT(!equal(list(1, 2), 'y')); + //! [equal] + + //! [not_equal] + BOOST_HANA_CONSTEXPR_ASSERT(not_equal(list(1, 2), list(3))); + BOOST_HANA_CONSTEXPR_ASSERT(not_equal('x', 'y')); + BOOST_HANA_CONSTANT_ASSERT(not_equal(list(1, 2), 'y')); + //! [not_equal] } diff --git a/example/comparable/equal.cpp b/example/comparable/equal.cpp deleted file mode 100644 index 48808908a..000000000 --- a/example/comparable/equal.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(equal(list(1, 2), list(1, 2))); - BOOST_HANA_CONSTEXPR_ASSERT(!equal('x', 'y')); - BOOST_HANA_CONSTANT_ASSERT(!equal(list(1, 2), 'y')); - //! [main] -} diff --git a/example/comparable/not_equal.cpp b/example/comparable/not_equal.cpp deleted file mode 100644 index c878e4996..000000000 --- a/example/comparable/not_equal.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(not_equal(list(1, 2), list(3))); - BOOST_HANA_CONSTEXPR_ASSERT(not_equal('x', 'y')); - BOOST_HANA_CONSTANT_ASSERT(not_equal(list(1, 2), 'y')); - //! [main] -} diff --git a/example/constant/comparable.cpp b/example/constant.cpp similarity index 66% rename from example/constant/comparable.cpp rename to example/constant.cpp index d2c7aaa16..ee7fa0ec0 100644 --- a/example/constant/comparable.cpp +++ b/example/constant.cpp @@ -9,15 +9,21 @@ Distributed under the Boost Software License, Version 1.0. using namespace boost::hana; -//! [main] -struct Person { - int age; - // ... -}; - int main() { + //! [comparable] + struct Person { + int age; + // ... + }; + BOOST_HANA_CONSTANT_ASSERT(integral == integral); BOOST_HANA_CONSTANT_ASSERT(integral != integral); BOOST_HANA_CONSTANT_ASSERT(integral != integral); + //! [comparable] + + //! [value] + auto i = integral; // notice no constexpr + static_assert(value(i) == 3, "value(i) is always a constant expression!"); + //! [value] } -//! [main] + diff --git a/example/constant/value.cpp b/example/constant/value.cpp deleted file mode 100644 index 522c0293d..000000000 --- a/example/constant/value.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -using namespace boost::hana; - - -int main() { - //! [main] - auto i = integral; // notice no constexpr - static_assert(value(i) == 3, "value(i) is always a constant expression!"); - //! [main] -} diff --git a/example/foldable/foldl.cpp b/example/foldable/foldl.cpp index 7fe7e27f3..018447564 100644 --- a/example/foldable/foldl.cpp +++ b/example/foldable/foldl.cpp @@ -6,7 +6,8 @@ Distributed under the Boost Software License, Version 1.0. #include -#include +#include + #include #include using namespace boost::hana; @@ -20,6 +21,6 @@ int main() { return "(" + to_string(x) + " + " + to_string(y) + ")"; }; - assert(foldl(list(2, "3", '4'), "1", show) == "(((1 + 2) + 3) + 4)"); + BOOST_HANA_RUNTIME_ASSERT(foldl(list(2, "3", '4'), "1", show) == "(((1 + 2) + 3) + 4)"); //! [main] } diff --git a/example/foldable/foldl1.cpp b/example/foldable/foldl1.cpp index 8cf736799..6c79708b5 100644 --- a/example/foldable/foldl1.cpp +++ b/example/foldable/foldl1.cpp @@ -6,7 +6,8 @@ Distributed under the Boost Software License, Version 1.0. #include -#include +#include + #include #include using namespace boost::hana; @@ -20,6 +21,6 @@ int main() { return "(" + to_string(x) + " + " + to_string(y) + ")"; }; - assert(foldl1(list(1, "2", '3'), show) == "((1 + 2) + 3)"); + BOOST_HANA_RUNTIME_ASSERT(foldl1(list(1, "2", '3'), show) == "((1 + 2) + 3)"); //! [main] } diff --git a/example/group/minus.cpp b/example/group.cpp similarity index 70% rename from example/group/minus.cpp rename to example/group.cpp index 13045c32e..5bee980b7 100644 --- a/example/group/minus.cpp +++ b/example/group.cpp @@ -10,8 +10,13 @@ using namespace boost::hana; int main() { - //! [main] + //! [minus] BOOST_HANA_CONSTANT_ASSERT(minus(int_<3>, int_<5>) == int_<-2>); BOOST_HANA_CONSTEXPR_ASSERT(minus(1, 2) == -1); - //! [main] + //! [minus] + + //! [negate] + BOOST_HANA_CONSTANT_ASSERT(negate(int_<3>) == int_<-3>); + BOOST_HANA_CONSTEXPR_ASSERT(negate(2) == -2); + //! [negate] } diff --git a/example/group/negate.cpp b/example/group/negate.cpp deleted file mode 100644 index d5fb5b6fd..000000000 --- a/example/group/negate.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTANT_ASSERT(negate(int_<3>) == int_<-3>); - BOOST_HANA_CONSTEXPR_ASSERT(negate(2) == -2); - //! [main] -} diff --git a/example/integer_list/foldable/foldr.cpp b/example/integer_list/foldable.cpp similarity index 92% rename from example/integer_list/foldable/foldr.cpp rename to example/integer_list/foldable.cpp index 5519ceb89..2a238dab8 100644 --- a/example/integer_list/foldable/foldr.cpp +++ b/example/integer_list/foldable.cpp @@ -9,11 +9,12 @@ Distributed under the Boost Software License, Version 1.0. #include #include using namespace boost::hana; -using namespace literals; int main() { - //! [main] + //! [foldr] + using namespace literals; + BOOST_HANA_CONSTEXPR_LAMBDA auto numbers = integer_list; BOOST_HANA_CONSTEXPR_LAMBDA auto negatives = integer_list; @@ -24,5 +25,5 @@ int main() { BOOST_HANA_CONSTANT_ASSERT( foldr(numbers, integer_list, keep_negatives) == negatives ); - //! [main] + //! [foldr] } diff --git a/example/integral.cpp b/example/integral.cpp new file mode 100644 index 000000000..3e6ce631b --- /dev/null +++ b/example/integral.cpp @@ -0,0 +1,43 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include +#include +#include +using namespace boost::hana; + + +int main() { + //! [comparable] + BOOST_HANA_CONSTANT_ASSERT(equal(int_<1>, int_<1>)); + BOOST_HANA_CONSTANT_ASSERT(not_equal(int_<1>, int_<2>)); + + BOOST_HANA_CONSTANT_ASSERT(equal(int_<1>, long_<1>)); + BOOST_HANA_CONSTANT_ASSERT(not_equal(int_<1>, long_<2>)); + //! [comparable] + + //! [literals] + using namespace literals; // contains the _c suffix + + BOOST_HANA_CONSTANT_ASSERT(1234_c == llong<1234>); + BOOST_HANA_CONSTANT_ASSERT(-1234_c == llong<-1234>); + BOOST_HANA_CONSTANT_ASSERT(sum(list(1_c, 2_c, 3_c, 4_c)) == 10_c); + //! [literals] + + //! [operators] + BOOST_HANA_CONSTANT_ASSERT(int_<1> + int_<3> == int_<4>); + + // Mixed-type operations are supported: + BOOST_HANA_CONSTANT_ASSERT(size_t<3> * ushort<5> == size_t<15>); + BOOST_HANA_CONSTANT_ASSERT(size_t<15> == int_<15>); + //! [operators] + + //! [orderable] + BOOST_HANA_CONSTANT_ASSERT(less(int_<-3>, int_<3>)); + BOOST_HANA_CONSTANT_ASSERT(max(int_<-3>, long_<2>) == long_<2>); + BOOST_HANA_CONSTANT_ASSERT(min(int_<-3>, long_<2>) == int_<-3>); + //! [orderable] +} diff --git a/example/integral/comparable.cpp b/example/integral/comparable.cpp deleted file mode 100644 index b936d3f97..000000000 --- a/example/integral/comparable.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTANT_ASSERT(equal(int_<1>, int_<1>)); - BOOST_HANA_CONSTANT_ASSERT(not_equal(int_<1>, int_<2>)); - - BOOST_HANA_CONSTANT_ASSERT(equal(int_<1>, long_<1>)); - BOOST_HANA_CONSTANT_ASSERT(not_equal(int_<1>, long_<2>)); - //! [main] -} diff --git a/example/integral/literals.cpp b/example/integral/literals.cpp deleted file mode 100644 index b57d24e15..000000000 --- a/example/integral/literals.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - using namespace literals; - - BOOST_HANA_CONSTANT_ASSERT(1234_c == llong<1234>); - BOOST_HANA_CONSTANT_ASSERT(-1234_c == llong<-1234>); - BOOST_HANA_CONSTANT_ASSERT(sum(list(1_c, 2_c, 3_c, 4_c)) == 10_c); - //! [main] -} diff --git a/example/integral/operators.cpp b/example/integral/operators.cpp deleted file mode 100644 index 9c30a73e1..000000000 --- a/example/integral/operators.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTANT_ASSERT(int_<1> + int_<3> == int_<4>); - - // Mixed-type operations are supported: - BOOST_HANA_CONSTANT_ASSERT(size_t<3> * ushort<5> == size_t<15>); - BOOST_HANA_CONSTANT_ASSERT(size_t<15> == int_<15>); - //! [main] -} diff --git a/example/integral/orderable.cpp b/example/integral/orderable.cpp deleted file mode 100644 index 706b706fc..000000000 --- a/example/integral/orderable.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTANT_ASSERT(less(int_<-3>, int_<3>)); - BOOST_HANA_CONSTANT_ASSERT(max(int_<-3>, long_<2>) == long_<2>); - BOOST_HANA_CONSTANT_ASSERT(min(int_<-3>, long_<2>) == int_<-3>); - //! [main] -} diff --git a/example/map/searchable.cpp b/example/map.cpp similarity index 62% rename from example/map/searchable.cpp rename to example/map.cpp index 591ec217d..b9e2d6aad 100644 --- a/example/map/searchable.cpp +++ b/example/map.cpp @@ -5,17 +5,34 @@ Distributed under the Boost Software License, Version 1.0. */ #include +#include #include #include #include #include #include + +#include using namespace boost::hana; int main() { - //! [main] - auto m = map( + //! [comparable] + BOOST_HANA_RUNTIME_ASSERT( + map( + pair(char_<'a'>, std::string{"foobar"}), + pair(type, nullptr) + ) + == + map( + pair(type, (void*)0), + pair(char_<'a'>, "foobar") + ) + ); + //! [comparable] + + //! [searchable] + BOOST_HANA_CONSTEXPR_LAMBDA auto m = map( pair(type, 'i'), pair(type, 'f') ); @@ -23,5 +40,5 @@ int main() { BOOST_HANA_CONSTEXPR_ASSERT(lookup(m, type) == just('f')); BOOST_HANA_CONSTANT_ASSERT(lookup(m, type) == nothing); BOOST_HANA_CONSTANT_ASSERT(lookup(m, int_<3>) == nothing); - //! [main] + //! [searchable] } diff --git a/example/map/comparable.cpp b/example/map/comparable.cpp deleted file mode 100644 index f1602eb58..000000000 --- a/example/map/comparable.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - assert( - map( - pair(char_<'a'>, std::string{"foobar"}), - pair(type, nullptr) - ) - == - map( - pair(type, (void*)0), - pair(char_<'a'>, "foobar") - ) - ); - //! [main] -} diff --git a/example/monoid/plus.cpp b/example/monoid.cpp similarity index 70% rename from example/monoid/plus.cpp rename to example/monoid.cpp index eb8bda854..5a671b53f 100644 --- a/example/monoid/plus.cpp +++ b/example/monoid.cpp @@ -10,8 +10,13 @@ using namespace boost::hana; int main() { - //! [main] + //! [zero] + BOOST_HANA_CONSTANT_ASSERT(zero == int_<0>); + BOOST_HANA_CONSTEXPR_ASSERT(zero == 0l); + //! [zero] + + //! [plus] BOOST_HANA_CONSTANT_ASSERT(plus(int_<3>, int_<5>) == int_<8>); BOOST_HANA_CONSTEXPR_ASSERT(plus(1, 2) == 3); - //! [main] + //! [plus] } diff --git a/example/monoid/zero.cpp b/example/monoid/zero.cpp deleted file mode 100644 index b1c321cd2..000000000 --- a/example/monoid/zero.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTANT_ASSERT(zero == int_<0>); - BOOST_HANA_CONSTEXPR_ASSERT(zero == 0l); - //! [main] -} diff --git a/example/orderable.cpp b/example/orderable.cpp new file mode 100644 index 000000000..16cee3283 --- /dev/null +++ b/example/orderable.cpp @@ -0,0 +1,62 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include +#include +#include +#include +#include +using namespace boost::hana; + + +int main() { + //! [greater] + BOOST_HANA_CONSTEXPR_ASSERT(greater(4, 1)); + BOOST_HANA_CONSTANT_ASSERT(!greater(int_<1>, int_<3>)); + //! [greater] + + //! [greater_equal] + BOOST_HANA_CONSTEXPR_ASSERT(greater_equal(4, 1)); + BOOST_HANA_CONSTEXPR_ASSERT(greater_equal(1, 1)); + BOOST_HANA_CONSTANT_ASSERT(!greater_equal(int_<1>, int_<2>)); + //! [greater_equal] + + //! [less] + BOOST_HANA_CONSTEXPR_ASSERT(less(1, 4)); + BOOST_HANA_CONSTANT_ASSERT(!less(int_<3>, int_<2>)); + //! [less] + + //! [less_equal] + BOOST_HANA_CONSTEXPR_ASSERT(less_equal(1, 4)); + BOOST_HANA_CONSTEXPR_ASSERT(less_equal(1, 1)); + BOOST_HANA_CONSTANT_ASSERT(!less_equal(int_<3>, int_<2>)); + //! [less_equal] + + //! [max] + BOOST_HANA_CONSTEXPR_ASSERT(max(1, 4) == 4); + BOOST_HANA_CONSTANT_ASSERT(max(int_<7>, int_<5>) == int_<7>); + //! [max] + + //! [min] + BOOST_HANA_CONSTEXPR_ASSERT(min(1, 4) == 1); + BOOST_HANA_CONSTANT_ASSERT(min(int_<7>, int_<5>) == int_<5>); + //! [min] + + //! [ordering] + BOOST_HANA_CONSTEXPR_LAMBDA auto sorted = sort_by(ordering(sizeof_), list( + type, + type, + type, + type + )); + BOOST_HANA_CONSTANT_ASSERT(sorted == list( + type, + type, + type, + type + )); + //! [ordering] +} diff --git a/example/orderable/greater.cpp b/example/orderable/greater.cpp deleted file mode 100644 index 39474b299..000000000 --- a/example/orderable/greater.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(greater(4, 1)); - BOOST_HANA_CONSTANT_ASSERT(!greater(int_<1>, int_<3>)); - //! [main] -} diff --git a/example/orderable/greater_equal.cpp b/example/orderable/greater_equal.cpp deleted file mode 100644 index 420f82b82..000000000 --- a/example/orderable/greater_equal.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(greater_equal(4, 1)); - BOOST_HANA_CONSTEXPR_ASSERT(greater_equal(1, 1)); - BOOST_HANA_CONSTANT_ASSERT(!greater_equal(int_<1>, int_<2>)); - //! [main] -} diff --git a/example/orderable/less.cpp b/example/orderable/less.cpp deleted file mode 100644 index 85750ff3b..000000000 --- a/example/orderable/less.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(less(1, 4)); - BOOST_HANA_CONSTANT_ASSERT(!less(int_<3>, int_<2>)); - //! [main] -} diff --git a/example/orderable/less_equal.cpp b/example/orderable/less_equal.cpp deleted file mode 100644 index d05681742..000000000 --- a/example/orderable/less_equal.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(less_equal(1, 4)); - BOOST_HANA_CONSTEXPR_ASSERT(less_equal(1, 1)); - BOOST_HANA_CONSTANT_ASSERT(!less_equal(int_<3>, int_<2>)); - //! [main] -} diff --git a/example/orderable/max.cpp b/example/orderable/max.cpp deleted file mode 100644 index d76078dac..000000000 --- a/example/orderable/max.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(max(1, 4) == 4); - BOOST_HANA_CONSTANT_ASSERT(max(int_<7>, int_<5>) == int_<7>); - //! [main] -} diff --git a/example/orderable/min.cpp b/example/orderable/min.cpp deleted file mode 100644 index a149ff238..000000000 --- a/example/orderable/min.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(min(1, 4) == 1); - BOOST_HANA_CONSTANT_ASSERT(min(int_<7>, int_<5>) == int_<5>); - //! [main] -} diff --git a/example/orderable/ordering.cpp b/example/orderable/ordering.cpp deleted file mode 100644 index bfdf7d207..000000000 --- a/example/orderable/ordering.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_LAMBDA auto sorted = sort_by(ordering(sizeof_), list( - type, - type, - type, - type - )); - BOOST_HANA_CONSTANT_ASSERT(sorted == list( - type, - type, - type, - type - )); - //! [main] -} diff --git a/example/pair/product.cpp b/example/pair.cpp similarity index 72% rename from example/pair/product.cpp rename to example/pair.cpp index dbf630738..c6b5a97ea 100644 --- a/example/pair/product.cpp +++ b/example/pair.cpp @@ -10,9 +10,14 @@ using namespace boost::hana; int main() { - //! [main] + //! [pair] + BOOST_HANA_CONSTEXPR_ASSERT(first(pair(1, 'x')) == 1); + BOOST_HANA_CONSTEXPR_ASSERT(second(pair(1, 'x')) == 'x'); + //! [pair] + + //! [product] BOOST_HANA_CONSTEXPR_ASSERT(make_product(1, 'x') == pair(1, 'x')); BOOST_HANA_CONSTEXPR_ASSERT(first(pair(1, 'x')) == 1); BOOST_HANA_CONSTEXPR_ASSERT(second(pair(1, 'x')) == 'x'); - //! [main] + //! [product] } diff --git a/example/pair/pair.cpp b/example/pair/pair.cpp deleted file mode 100644 index 988602d9d..000000000 --- a/example/pair/pair.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(first(pair(1, 'x')) == 1); - BOOST_HANA_CONSTEXPR_ASSERT(second(pair(1, 'x')) == 'x'); - //! [main] -} diff --git a/example/product/comparable.cpp b/example/product.cpp similarity index 56% rename from example/product/comparable.cpp rename to example/product.cpp index d66884572..b36d8e21a 100644 --- a/example/product/comparable.cpp +++ b/example/product.cpp @@ -12,8 +12,20 @@ using namespace boost::hana; int main() { - //! [main] + //! [comparable] BOOST_HANA_RUNTIME_ASSERT(pair(1, std::string{"234"}) == pair(1, "234")); BOOST_HANA_CONSTEXPR_ASSERT(pair('x', 2) != pair('y', 2)); - //! [main] + //! [comparable] + + //! [first] + BOOST_HANA_CONSTEXPR_ASSERT(first(pair(1, 'x')) == 1); + //! [first] + + //! [second] + BOOST_HANA_CONSTEXPR_ASSERT(second(pair(1, 'x')) == 'x'); + //! [second] + + //! [make_product] + BOOST_HANA_CONSTEXPR_ASSERT(make_product(1, 'x') == pair(1, 'x')); + //! [make_product] } diff --git a/example/product/first.cpp b/example/product/first.cpp deleted file mode 100644 index 4bf93d8ce..000000000 --- a/example/product/first.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(first(pair(1, 'x')) == 1); - //! [main] -} diff --git a/example/product/make_product.cpp b/example/product/make_product.cpp deleted file mode 100644 index 315706f05..000000000 --- a/example/product/make_product.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(make_product(1, 'x') == pair(1, 'x')); - //! [main] -} diff --git a/example/product/second.cpp b/example/product/second.cpp deleted file mode 100644 index 581772e12..000000000 --- a/example/product/second.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTEXPR_ASSERT(second(pair(1, 'x')) == 'x'); - //! [main] -} diff --git a/example/range/iterable.cpp b/example/range.cpp similarity index 53% rename from example/range/iterable.cpp rename to example/range.cpp index 88ea2229c..3b35604b9 100644 --- a/example/range/iterable.cpp +++ b/example/range.cpp @@ -12,11 +12,25 @@ using namespace boost::hana; int main() { - //! [main] + //! [range_c] + BOOST_HANA_CONSTANT_ASSERT(head(range_c) == int_<0>); + BOOST_HANA_CONSTANT_ASSERT(last(range_c) == ulong<4>); + BOOST_HANA_CONSTANT_ASSERT(tail(range_c) == range(int_<1>, int_<5>)); + //! [range_c] + + //! [iterable] BOOST_HANA_CONSTEXPR_LAMBDA auto r = range(int_<0>, int_<1000>); BOOST_HANA_CONSTANT_ASSERT(head(r) == int_<0>); BOOST_HANA_CONSTANT_ASSERT(last(r) == int_<999>); BOOST_HANA_CONSTANT_ASSERT(!is_empty(r)); BOOST_HANA_CONSTANT_ASSERT(is_empty(range(int_<3>, int_<3>))); - //! [main] + //! [iterable] + + //! [range] + using namespace literals; + + BOOST_HANA_CONSTANT_ASSERT(head(range(0_c, 5_c)) == 0_c); + BOOST_HANA_CONSTANT_ASSERT(last(range(0_c, 5_c)) == 4_c); + BOOST_HANA_CONSTANT_ASSERT(tail(range(0_c, 5_c)) == range(1_c, 5_c)); + //! [range] } diff --git a/example/range/range.cpp b/example/range/range.cpp deleted file mode 100644 index 1c1fca9ab..000000000 --- a/example/range/range.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -using namespace boost::hana; -using namespace literals; - - -//! [main] -BOOST_HANA_CONSTANT_ASSERT(head(range(0_c, 5_c)) == 0_c); -BOOST_HANA_CONSTANT_ASSERT(last(range(0_c, 5_c)) == 4_c); -BOOST_HANA_CONSTANT_ASSERT(tail(range(0_c, 5_c)) == range(1_c, 5_c)); -//! [main] - -int main() { } diff --git a/example/range/range_c.cpp b/example/range/range_c.cpp deleted file mode 100644 index 6a995f1e3..000000000 --- a/example/range/range_c.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -using namespace boost::hana; - - -//! [main] -BOOST_HANA_CONSTANT_ASSERT(head(range_c) == int_<0>); -BOOST_HANA_CONSTANT_ASSERT(last(range_c) == ulong<4>); -BOOST_HANA_CONSTANT_ASSERT(tail(range_c) == range(int_<1>, int_<5>)); -//! [main] - -int main() { } diff --git a/example/ring/mult.cpp b/example/ring.cpp similarity index 71% rename from example/ring/mult.cpp rename to example/ring.cpp index b5ab44ce7..3d4601dbe 100644 --- a/example/ring/mult.cpp +++ b/example/ring.cpp @@ -10,8 +10,13 @@ using namespace boost::hana; int main() { - //! [main] + //! [mult] BOOST_HANA_CONSTANT_ASSERT(mult(int_<3>, int_<5>) == int_<15>); BOOST_HANA_CONSTEXPR_ASSERT(mult(4, 2) == 8); - //! [main] + //! [mult] + + //! [one] + BOOST_HANA_CONSTANT_ASSERT(one == int_<1>); + BOOST_HANA_CONSTEXPR_ASSERT(one == 1l); + //! [one] } diff --git a/example/ring/one.cpp b/example/ring/one.cpp deleted file mode 100644 index df1236f6c..000000000 --- a/example/ring/one.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTANT_ASSERT(one == int_<1>); - BOOST_HANA_CONSTEXPR_ASSERT(one == 1l); - //! [main] -} diff --git a/example/set/searchable.cpp b/example/set.cpp similarity index 75% rename from example/set/searchable.cpp rename to example/set.cpp index 0c3e8b211..a19f52025 100644 --- a/example/set/searchable.cpp +++ b/example/set.cpp @@ -13,9 +13,15 @@ using namespace boost::hana; int main() { - //! [main] + //! [comparable] + BOOST_HANA_CONSTANT_ASSERT( + set(int_<0>, int_<1>, int_<2>) == set(int_<2>, int_<1>, int_<0>) + ); + //! [comparable] + + //! [searchable] BOOST_HANA_CONSTEXPR_LAMBDA auto xs = set(int_<0>, int_<1>, int_<2>); BOOST_HANA_CONSTANT_ASSERT(lookup(xs, int_<0>) == just(int_<0>)); BOOST_HANA_CONSTANT_ASSERT(lookup(xs, int_<3>) == nothing); - //! [main] + //! [searchable] } diff --git a/example/set/comparable.cpp b/example/set/comparable.cpp deleted file mode 100644 index 18b042468..000000000 --- a/example/set/comparable.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include -#include -#include -using namespace boost::hana; - - -int main() { - //! [main] - BOOST_HANA_CONSTANT_ASSERT(set(int_<0>, int_<1>, int_<2>) == set(int_<2>, int_<1>, int_<0>)); - //! [main] -} diff --git a/example/type/initializer_list.cpp b/example/type/initializer_list.cpp index e904572dd..8a0e3fd5b 100644 --- a/example/type/initializer_list.cpp +++ b/example/type/initializer_list.cpp @@ -6,7 +6,8 @@ Distributed under the Boost Software License, Version 1.0. #include -#include +#include + #include #include using namespace boost::hana; @@ -16,6 +17,6 @@ int main() { //! [main] std::vector v{1, 2, 3}; auto u = type>(std::initializer_list{1, 2, 3}); - assert(u == v); + BOOST_HANA_RUNTIME_ASSERT(u == v); //! [main] } diff --git a/example/type_list/functor/fmap.cpp b/example/type_list/functor.cpp similarity index 95% rename from example/type_list/functor/fmap.cpp rename to example/type_list/functor.cpp index 95bf2666e..f241767a1 100644 --- a/example/type_list/functor/fmap.cpp +++ b/example/type_list/functor.cpp @@ -14,10 +14,10 @@ using namespace boost::hana; int main() { - //! [main] + //! [fmap] BOOST_HANA_CONSTEXPR_LAMBDA auto types = type_list; BOOST_HANA_CONSTEXPR_LAMBDA auto pointers = fmap(template_, types); BOOST_HANA_CONSTANT_ASSERT(pointers == type_list); BOOST_HANA_CONSTANT_ASSERT(head(pointers) == type); - //! [main] + //! [fmap] } diff --git a/include/boost/hana/applicative/applicative.hpp b/include/boost/hana/applicative/applicative.hpp index 422508530..d7c1f3cf0 100644 --- a/include/boost/hana/applicative/applicative.hpp +++ b/include/boost/hana/applicative/applicative.hpp @@ -108,7 +108,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/applicative/ap.cpp main + //! @snippet example/applicative.cpp ap //! //! @todo //! Consider giving access to all the arguments to the type class @@ -131,7 +131,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/applicative/lift.cpp main + //! @snippet example/applicative.cpp lift #ifdef BOOST_HANA_DOXYGEN_INVOKED template constexpr auto lift = [](auto x) { ... }; diff --git a/include/boost/hana/comparable/detail/comparable_fwd.hpp b/include/boost/hana/comparable/detail/comparable_fwd.hpp index e1d2939c4..ee0df3daa 100644 --- a/include/boost/hana/comparable/detail/comparable_fwd.hpp +++ b/include/boost/hana/comparable/detail/comparable_fwd.hpp @@ -48,7 +48,7 @@ namespace boost { namespace hana { //! Two objects to compare for equality. //! //! ### Example - //! @snippet example/comparable/equal.cpp main + //! @snippet example/comparable.cpp equal //! //! @internal //! ### Rationale for the arity of `equal` @@ -76,7 +76,7 @@ namespace boost { namespace hana { //! Two objects to compare for inequality. //! //! ### Example - //! @snippet example/comparable/not_equal.cpp main + //! @snippet example/comparable.cpp not_equal BOOST_HANA_CONSTEXPR_LAMBDA auto not_equal = [](auto x, auto y) { return Comparable::instance< datatype_t, datatype_t @@ -94,7 +94,7 @@ namespace boost { namespace hana { //! @endcode //! //! ### Example - //! @snippet example/comparable/comparing.cpp main + //! @snippet example/comparable.cpp comparing BOOST_HANA_CONSTEXPR_LAMBDA auto comparing = [](auto f) { return [=](auto x, auto y) { return equal(f(x), f(y)); diff --git a/include/boost/hana/constant/constant.hpp b/include/boost/hana/constant/constant.hpp index 525e8a7d9..44db4f3a2 100644 --- a/include/boost/hana/constant/constant.hpp +++ b/include/boost/hana/constant/constant.hpp @@ -56,7 +56,7 @@ namespace boost { namespace hana { //! its argument at all. //! //! ### Example - //! @snippet example/constant/value.cpp main + //! @snippet example/constant.cpp value #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto value = [](auto const& c) { return Constant::instance< diff --git a/include/boost/hana/constant/mcd.hpp b/include/boost/hana/constant/mcd.hpp index 79cc1fb93..8f3333aa7 100644 --- a/include/boost/hana/constant/mcd.hpp +++ b/include/boost/hana/constant/mcd.hpp @@ -27,7 +27,7 @@ namespace boost { namespace hana { //! can be compared and are equal. //! //! ### Example - //! @snippet example/constant/comparable.cpp main + //! @snippet example/constant.cpp comparable template struct Comparable::instance() && is_a() diff --git a/include/boost/hana/detail/integral_fwd.hpp b/include/boost/hana/detail/integral_fwd.hpp index f7fd5908e..6ad157a33 100644 --- a/include/boost/hana/detail/integral_fwd.hpp +++ b/include/boost/hana/detail/integral_fwd.hpp @@ -43,7 +43,7 @@ namespace boost { namespace hana { //! - Member access: `*` (dereference) //! //! ## Example - //! @snippet example/integral/operators.cpp main + //! @snippet example/integral.cpp operators //! //! ## Instance of //! `Comparable`, `Logical`, `Orderable`, `Monoid`, `Group` diff --git a/include/boost/hana/ext/boost/fusion.hpp b/include/boost/hana/ext/boost/fusion.hpp index 88c1ea069..a883b003a 100644 --- a/include/boost/hana/ext/boost/fusion.hpp +++ b/include/boost/hana/ext/boost/fusion.hpp @@ -202,9 +202,9 @@ namespace boost { namespace hana { return Iterable::mcd::at_impl(n, std::forward(xs)); } - template - static constexpr decltype(auto) for_each_impl(Xs&& xs, F f) { - return boost::fusion::for_each(std::forward(xs), f); + template + static constexpr decltype(auto) for_each_impl(Xs&& xs, F&& f) { + return boost::fusion::for_each(std::forward(xs), std::forward(f)); } }; @@ -251,8 +251,9 @@ namespace boost { namespace hana { } template - static constexpr decltype(auto) snoc_impl(Xs&& xs, X x) { - return boost::fusion::push_back(std::forward(xs), x); + static constexpr decltype(auto) snoc_impl(Xs&& xs, X&& x) { + return boost::fusion::push_back( + std::forward(xs), std::forward(x)); } }; @@ -266,8 +267,9 @@ namespace boost { namespace hana { } template - static constexpr decltype(auto) replace_impl(Pred p, X x, Xs&& xs) { - return boost::fusion::replace_if(std::forward(xs), p, x); + static constexpr decltype(auto) replace_impl(Pred&& p, X&& x, Xs&& xs) { + return boost::fusion::replace_if( + std::forward(xs), std::forward(p), std::forward(x)); } }; }} // end namespace boost::hana diff --git a/include/boost/hana/ext/std/pair.hpp b/include/boost/hana/ext/std/pair.hpp index 8593a0483..f137d614c 100644 --- a/include/boost/hana/ext/std/pair.hpp +++ b/include/boost/hana/ext/std/pair.hpp @@ -27,7 +27,7 @@ namespace boost { namespace hana { template <> struct Product::instance : Product::mcd { template - static auto first_impl(X x, Y y) + static auto make_product_impl(X x, Y y) { return std::make_pair(x, y); } template diff --git a/include/boost/hana/group/detail/group_fwd.hpp b/include/boost/hana/group/detail/group_fwd.hpp index e7ec6a3b7..c570fda85 100644 --- a/include/boost/hana/group/detail/group_fwd.hpp +++ b/include/boost/hana/group/detail/group_fwd.hpp @@ -54,7 +54,7 @@ namespace boost { namespace hana { //! @endcode //! //! ### Example - //! @snippet example/group/minus.cpp main + //! @snippet example/group.cpp minus BOOST_HANA_CONSTEXPR_LAMBDA auto minus = [](auto x, auto y) { return Group::instance< datatype_t, datatype_t @@ -69,7 +69,7 @@ namespace boost { namespace hana { //! i.e. `Group::instance`, where `G` is the data type of `x`. //! //! ### Example - //! @snippet example/group/negate.cpp main + //! @snippet example/group.cpp negate BOOST_HANA_CONSTEXPR_LAMBDA auto negate = [](auto x) { return Group::instance< datatype_t, datatype_t diff --git a/include/boost/hana/integral.hpp b/include/boost/hana/integral.hpp index 6442ddb4a..4dea421a1 100644 --- a/include/boost/hana/integral.hpp +++ b/include/boost/hana/integral.hpp @@ -49,7 +49,7 @@ namespace boost { namespace hana { //! An `Integral` is less than another if and only if its underlying //! integral value is less than the other's. //! - //! @snippet example/integral/orderable.cpp main + //! @snippet example/integral.cpp orderable template <> struct Orderable::instance : Orderable::less_mcd { template @@ -269,7 +269,7 @@ namespace boost { namespace hana { //! like `ullong<-1>` which is actually `ullong`. //! //! ### Example - //! @snippet example/integral/literals.cpp main + //! @snippet example/integral.cpp literals //! //! @todo Add support for stuff like `0x1234_c`. template diff --git a/include/boost/hana/iterable/mcd.hpp b/include/boost/hana/iterable/mcd.hpp index 6b9bbe05b..72f84f6cf 100644 --- a/include/boost/hana/iterable/mcd.hpp +++ b/include/boost/hana/iterable/mcd.hpp @@ -146,7 +146,7 @@ namespace boost { namespace hana { //! @snippet example/list/foldable/foldl.cpp main //! //! ### Example 2 - //! @snippet example/integer_list/foldable/foldr.cpp main + //! @snippet example/integer_list/foldable.cpp foldr template struct Foldable::instance()>> : detail::FoldableFromIterable diff --git a/include/boost/hana/list/mcd.hpp b/include/boost/hana/list/mcd.hpp index 802266fc9..3c9e25896 100644 --- a/include/boost/hana/list/mcd.hpp +++ b/include/boost/hana/list/mcd.hpp @@ -312,7 +312,7 @@ namespace boost { namespace hana { //! @snippet example/list/functor/fmap.cpp main //! //! ### Example 2 - //! @snippet example/type_list/functor/fmap.cpp main + //! @snippet example/type_list/functor.cpp fmap template struct Functor::instance()>> : Functor::fmap_mcd diff --git a/include/boost/hana/map.hpp b/include/boost/hana/map.hpp index 456d6109b..ae42482e6 100644 --- a/include/boost/hana/map.hpp +++ b/include/boost/hana/map.hpp @@ -56,7 +56,7 @@ namespace boost { namespace hana { //! to equal values. //! //! ### Example - //! @snippet example/map/comparable.cpp main + //! @snippet example/map.cpp comparable template <> struct Comparable::instance : Comparable::equal_mcd { template @@ -74,7 +74,7 @@ namespace boost { namespace hana { //! `Integral`. //! //! ### Example - //! @snippet example/map/searchable.cpp main + //! @snippet example/map.cpp searchable template <> struct Searchable::instance : Searchable::mcd { template diff --git a/include/boost/hana/monad/detail/laws.hpp b/include/boost/hana/monad/detail/laws.hpp index 14328f575..d271ba393 100644 --- a/include/boost/hana/monad/detail/laws.hpp +++ b/include/boost/hana/monad/detail/laws.hpp @@ -24,7 +24,7 @@ Distributed under the Boost Software License, Version 1.0. namespace boost { namespace hana { struct Monad::laws { template - static constexpr auto check2(Monads ms, Xs xs, Fs fs, Gs gs) { + static constexpr auto check(Monads ms, Xs xs, Fs fs, Gs gs) { return all(ms, [=](auto m) { return all(xs, [=](auto x) { return all(fs, [=](auto f) { @@ -44,17 +44,6 @@ namespace boost { namespace hana { }); }); } - - template - static constexpr auto check(Monad_ monad, A a, F f, G g) { - auto lift_ = lift>; - return and_( - equal(bind(lift_(a), f), f(a)), - equal(bind(monad, lift_), monad), - equal(bind(monad, [=](auto x) { return bind(f(x), g); }), bind(bind(monad, f), g)), - equal(fmap(f, monad), bind(monad, compose(lift_, f))) - ); - } }; }} // end namespace boost::hana diff --git a/include/boost/hana/monoid/detail/monoid_fwd.hpp b/include/boost/hana/monoid/detail/monoid_fwd.hpp index e1f415e4c..85f9730cb 100644 --- a/include/boost/hana/monoid/detail/monoid_fwd.hpp +++ b/include/boost/hana/monoid/detail/monoid_fwd.hpp @@ -49,7 +49,7 @@ namespace boost { namespace hana { //! @relates Monoid //! //! ### Example - //! @snippet example/monoid/plus.cpp main + //! @snippet example/monoid.cpp plus BOOST_HANA_CONSTEXPR_LAMBDA auto plus = [](auto x, auto y) { return Monoid::instance< datatype_t, datatype_t @@ -67,7 +67,7 @@ namespace boost { namespace hana { //! The data type (a `Monoid`) of the returned identity. //! //! ### Example - //! @snippet example/monoid/zero.cpp main + //! @snippet example/monoid.cpp zero template constexpr auto zero = Monoid::instance::zero_impl(); diff --git a/include/boost/hana/orderable/detail/orderable_fwd.hpp b/include/boost/hana/orderable/detail/orderable_fwd.hpp index 7e21403d5..c8585f28f 100644 --- a/include/boost/hana/orderable/detail/orderable_fwd.hpp +++ b/include/boost/hana/orderable/detail/orderable_fwd.hpp @@ -49,7 +49,7 @@ namespace boost { namespace hana { //! @relates Orderable //! //! ### Example - //! @snippet example/orderable/less.cpp main + //! @snippet example/orderable.cpp less BOOST_HANA_CONSTEXPR_LAMBDA auto less = [](auto x, auto y) { return Orderable::instance< datatype_t, datatype_t @@ -61,7 +61,7 @@ namespace boost { namespace hana { //! @relates Orderable //! //! ### Example - //! @snippet example/orderable/less_equal.cpp main + //! @snippet example/orderable.cpp less_equal BOOST_HANA_CONSTEXPR_LAMBDA auto less_equal = [](auto x, auto y) { return Orderable::instance< datatype_t, datatype_t @@ -72,7 +72,7 @@ namespace boost { namespace hana { //! @relates Orderable //! //! ### Example - //! @snippet example/orderable/greater.cpp main + //! @snippet example/orderable.cpp greater BOOST_HANA_CONSTEXPR_LAMBDA auto greater = [](auto x, auto y) { return Orderable::instance< datatype_t, datatype_t @@ -84,7 +84,7 @@ namespace boost { namespace hana { //! @relates Orderable //! //! ### Example - //! @snippet example/orderable/greater_equal.cpp main + //! @snippet example/orderable.cpp greater_equal BOOST_HANA_CONSTEXPR_LAMBDA auto greater_equal = [](auto x, auto y) { return Orderable::instance< datatype_t, datatype_t @@ -95,7 +95,7 @@ namespace boost { namespace hana { //! @relates Orderable //! //! ### Example - //! @snippet example/orderable/min.cpp main + //! @snippet example/orderable.cpp min BOOST_HANA_CONSTEXPR_LAMBDA auto min = [](auto x, auto y) { return Orderable::instance< datatype_t, datatype_t @@ -106,7 +106,7 @@ namespace boost { namespace hana { //! @relates Orderable //! //! ### Example - //! @snippet example/orderable/max.cpp main + //! @snippet example/orderable.cpp max BOOST_HANA_CONSTEXPR_LAMBDA auto max = [](auto x, auto y) { return Orderable::instance< datatype_t, datatype_t @@ -124,7 +124,7 @@ namespace boost { namespace hana { //! @endcode //! //! ### Example - //! @snippet example/orderable/ordering.cpp main + //! @snippet example/orderable.cpp ordering BOOST_HANA_CONSTEXPR_LAMBDA auto ordering = [](auto f) { return [=](auto x, auto y) { return less(f(x), f(y)); diff --git a/include/boost/hana/pair.hpp b/include/boost/hana/pair.hpp index b274680f0..3dfb6532f 100644 --- a/include/boost/hana/pair.hpp +++ b/include/boost/hana/pair.hpp @@ -34,7 +34,7 @@ namespace boost { namespace hana { //! @relates Pair //! //! ### Example - //! @snippet example/pair/pair.cpp main + //! @snippet example/pair.cpp pair BOOST_HANA_CONSTEXPR_LAMBDA auto pair = [](auto first, auto second) { return pair_detail::pair< decltype(first), decltype(second) @@ -44,7 +44,7 @@ namespace boost { namespace hana { //! Instance of `Product` for `Pair`s. //! //! ### Example - //! @snippet example/pair/product.cpp main + //! @snippet example/pair.cpp product template <> struct Product::instance : Product::mcd { template diff --git a/include/boost/hana/product/mcd.hpp b/include/boost/hana/product/mcd.hpp index 2180bd94c..22eac3aac 100644 --- a/include/boost/hana/product/mcd.hpp +++ b/include/boost/hana/product/mcd.hpp @@ -30,7 +30,7 @@ namespace boost { namespace hana { //! @endcode //! //! ### Example - //! @snippet example/product/comparable.cpp main + //! @snippet example/product.cpp comparable template struct Comparable::instance() && is_a() diff --git a/include/boost/hana/product/product.hpp b/include/boost/hana/product/product.hpp index 2c7d56560..4f93a73d7 100644 --- a/include/boost/hana/product/product.hpp +++ b/include/boost/hana/product/product.hpp @@ -59,7 +59,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/product/make_product.cpp main + //! @snippet example/product.cpp make_product #ifdef BOOST_HANA_DOXYGEN_INVOKED template constexpr auto make_product = [](auto fst, auto snd) { @@ -88,7 +88,7 @@ namespace boost { namespace hana { //! @relates Product //! //! ### Example - //! @snippet example/product/first.cpp main + //! @snippet example/product.cpp first BOOST_HANA_CONSTEXPR_LAMBDA auto first = [](auto product) { return Product::instance< datatype_t @@ -99,7 +99,7 @@ namespace boost { namespace hana { //! @relates Product //! //! ### Example - //! @snippet example/product/second.cpp main + //! @snippet example/product.cpp second BOOST_HANA_CONSTEXPR_LAMBDA auto second = [](auto product) { return Product::instance< datatype_t diff --git a/include/boost/hana/range.hpp b/include/boost/hana/range.hpp index a5354facc..88618f611 100644 --- a/include/boost/hana/range.hpp +++ b/include/boost/hana/range.hpp @@ -47,7 +47,7 @@ namespace boost { namespace hana { //! a compilation error is triggered. //! //! ### Example - //! @snippet example/range/range.cpp main + //! @snippet example/range.cpp range BOOST_HANA_CONSTEXPR_LAMBDA auto range = [](auto from, auto to) { // For some reason, Clang 3.5 requires that we create an intermediate // variable whose type is dependent so we can use `valid_range` as a @@ -79,7 +79,7 @@ namespace boost { namespace hana { //! //! //! ### Example - //! @snippet example/range/range_c.cpp main + //! @snippet example/range.cpp range_c template BOOST_HANA_CONSTEXPR_LAMBDA auto range_c = range( integral, integral @@ -91,7 +91,7 @@ namespace boost { namespace hana { //! `from`, its tail is the range representing the `[from + 1, to)` //! interval and `r` is empty if and only if `from == to`. //! - //! @snippet example/range/iterable.cpp main + //! @snippet example/range.cpp iterable template <> struct Iterable::instance : Iterable::mcd { template diff --git a/include/boost/hana/ring/detail/ring_fwd.hpp b/include/boost/hana/ring/detail/ring_fwd.hpp index c63a5dd36..79c0edd5c 100644 --- a/include/boost/hana/ring/detail/ring_fwd.hpp +++ b/include/boost/hana/ring/detail/ring_fwd.hpp @@ -48,7 +48,7 @@ namespace boost { namespace hana { //! @relates Ring //! //! ### Example - //! @snippet example/ring/mult.cpp main + //! @snippet example/ring.cpp mult BOOST_HANA_CONSTEXPR_LAMBDA auto mult = [](auto x, auto y) { return Ring::instance< datatype_t, datatype_t @@ -66,7 +66,7 @@ namespace boost { namespace hana { //! The data type (a `Ring`) of the returned identity. //! //! ### Example - //! @snippet example/ring/one.cpp main + //! @snippet example/ring.cpp one template constexpr auto one = Ring::instance::one_impl(); diff --git a/include/boost/hana/set.hpp b/include/boost/hana/set.hpp index 194181d47..4247ef7dc 100644 --- a/include/boost/hana/set.hpp +++ b/include/boost/hana/set.hpp @@ -39,7 +39,7 @@ namespace boost { namespace hana { //! the order. //! //! ### Example - //! example/set/comparable.cpp main + //! example/set.cpp comparable template <> struct Comparable::instance : Comparable::equal_mcd { template @@ -57,7 +57,7 @@ namespace boost { namespace hana { //! instance follows naturally from that. //! //! ### Example - //! example/set/searchable.cpp main + //! example/set.cpp searchable template <> struct Searchable::instance : Searchable::mcd { template diff --git a/test/builtins/group.cpp b/test/builtins/group.cpp index d69ddfe14..c9f9c75d4 100644 --- a/test/builtins/group.cpp +++ b/test/builtins/group.cpp @@ -7,44 +7,12 @@ Distributed under the Boost Software License, Version 1.0. #include #include + +#define BOOST_HANA_TEST_GROUP +#include "integer.hpp" using namespace boost::hana; -struct integer { - int value; - constexpr explicit integer(int i) : value{i} { } -}; - -struct integer2 { - int value; - constexpr explicit integer2(int i) : value{i} { } -}; - -constexpr auto operator+(integer a, integer b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer2 a, integer b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer a, integer2 b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer2 a, integer2 b) -{ return integer2{a.value + b.value}; } - - -constexpr auto operator-(integer a, integer b) -{ return integer{a.value - b.value}; } - -constexpr auto operator-(integer2 a, integer b) -{ return integer{a.value - b.value}; } - -constexpr auto operator-(integer a, integer2 b) -{ return integer{a.value - b.value}; } - -constexpr auto operator-(integer2 a, integer2 b) -{ return integer2{a.value - b.value}; } - int main() { BOOST_HANA_CONSTEXPR_ASSERT(negate(integer{3}).value == -3); diff --git a/test/builtins/integer.hpp b/test/builtins/integer.hpp new file mode 100644 index 000000000..0a1de6bf2 --- /dev/null +++ b/test/builtins/integer.hpp @@ -0,0 +1,102 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#ifndef BOOST_HANA_TEST_BUILTINS_INTEGER_HPP +#define BOOST_HANA_TEST_BUILTINS_INTEGER_HPP + +#ifdef BOOST_HANA_TEST_INTEGRAL_DOMAIN +# define BOOST_HANA_TEST_RING +#endif + +#ifdef BOOST_HANA_TEST_RING +# define BOOST_HANA_TEST_GROUP +#endif + +#ifdef BOOST_HANA_TEST_GROUP +# define BOOST_HANA_TEST_MONOID +#endif + +struct integer { + int value; + constexpr explicit integer(int i) : value{i} { } +}; + +struct integer2 { + int value; + constexpr explicit integer2(int i) : value{i} { } +}; + + +#ifdef BOOST_HANA_TEST_MONOID + constexpr auto operator+(integer a, integer b) + { return integer{a.value + b.value}; } + + constexpr auto operator+(integer2 a, integer b) + { return integer{a.value + b.value}; } + + constexpr auto operator+(integer a, integer2 b) + { return integer{a.value + b.value}; } + + constexpr auto operator+(integer2 a, integer2 b) + { return integer2{a.value + b.value}; } +#endif + +#ifdef BOOST_HANA_TEST_GROUP + constexpr auto operator-(integer a, integer b) + { return integer{a.value - b.value}; } + + constexpr auto operator-(integer2 a, integer b) + { return integer{a.value - b.value}; } + + constexpr auto operator-(integer a, integer2 b) + { return integer{a.value - b.value}; } + + constexpr auto operator-(integer2 a, integer2 b) + { return integer2{a.value - b.value}; } +#endif + +#ifdef BOOST_HANA_TEST_RING + constexpr auto operator*(integer a, integer b) + { return integer{a.value * b.value}; } + + constexpr auto operator*(integer2 a, integer b) + { return integer{a.value * b.value}; } + + constexpr auto operator*(integer a, integer2 b) + { return integer{a.value * b.value}; } + + constexpr auto operator*(integer2 a, integer2 b) + { return integer2{a.value * b.value}; } +#endif + +#ifdef BOOST_HANA_TEST_INTEGRAL_DOMAIN + constexpr auto operator/(integer a, integer b) + { return integer{a.value / b.value}; } + + constexpr auto operator/(integer2 a, integer b) + { return integer{a.value / b.value}; } + + constexpr auto operator/(integer a, integer2 b) + { return integer{a.value / b.value}; } + + constexpr auto operator/(integer2 a, integer2 b) + { return integer2{a.value / b.value}; } + + + constexpr auto operator%(integer a, integer b) + { return integer{a.value % b.value}; } + + constexpr auto operator%(integer2 a, integer b) + { return integer{a.value % b.value}; } + + constexpr auto operator%(integer a, integer2 b) + { return integer{a.value % b.value}; } + + constexpr auto operator%(integer2 a, integer2 b) + { return integer2{a.value % b.value}; } +#endif + +#endif //! BOOST_HANA_TEST_BUILTINS_INTEGER_HPP diff --git a/test/builtins/integral_domain.cpp b/test/builtins/integral_domain.cpp index 867f52c25..6a7496fa1 100644 --- a/test/builtins/integral_domain.cpp +++ b/test/builtins/integral_domain.cpp @@ -7,44 +7,12 @@ Distributed under the Boost Software License, Version 1.0. #include #include + +#define BOOST_HANA_TEST_INTEGRAL_DOMAIN +#include "integer.hpp" using namespace boost::hana; -struct integer { - int value; - constexpr explicit integer(int i) : value{i} { } -}; - -struct integer2 { - int value; - constexpr explicit integer2(int i) : value{i} { } -}; - -constexpr auto operator/(integer a, integer b) -{ return integer{a.value / b.value}; } - -constexpr auto operator/(integer2 a, integer b) -{ return integer{a.value / b.value}; } - -constexpr auto operator/(integer a, integer2 b) -{ return integer{a.value / b.value}; } - -constexpr auto operator/(integer2 a, integer2 b) -{ return integer2{a.value / b.value}; } - - -constexpr auto operator%(integer a, integer b) -{ return integer{a.value % b.value}; } - -constexpr auto operator%(integer2 a, integer b) -{ return integer{a.value % b.value}; } - -constexpr auto operator%(integer a, integer2 b) -{ return integer{a.value % b.value}; } - -constexpr auto operator%(integer2 a, integer2 b) -{ return integer2{a.value % b.value}; } - int main() { // same type BOOST_HANA_CONSTEXPR_ASSERT(quot(integer{6}, integer{3}).value == 6 / 3); diff --git a/test/builtins/monoid.cpp b/test/builtins/monoid.cpp index be1dd9450..d3a591dca 100644 --- a/test/builtins/monoid.cpp +++ b/test/builtins/monoid.cpp @@ -8,31 +8,12 @@ Distributed under the Boost Software License, Version 1.0. #include #include + +#define BOOST_HANA_TEST_MONOID +#include "integer.hpp" using namespace boost::hana; -struct integer { - int value; - constexpr explicit integer(int i) : value{i} { } -}; - -struct integer2 { - int value; - constexpr explicit integer2(int i) : value{i} { } -}; - -constexpr auto operator+(integer a, integer b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer2 a, integer b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer a, integer2 b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer2 a, integer2 b) -{ return integer2{a.value + b.value}; } - using Integer = datatype_t; using Integer2 = datatype_t; diff --git a/test/builtins/ring.cpp b/test/builtins/ring.cpp index c0daa1704..40eb0ed8b 100644 --- a/test/builtins/ring.cpp +++ b/test/builtins/ring.cpp @@ -8,57 +8,12 @@ Distributed under the Boost Software License, Version 1.0. #include #include + +#define BOOST_HANA_TEST_RING +#include "integer.hpp" using namespace boost::hana; -struct integer { - int value; - constexpr explicit integer(int i) : value{i} { } -}; - -struct integer2 { - int value; - constexpr explicit integer2(int i) : value{i} { } -}; - -constexpr auto operator+(integer a, integer b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer2 a, integer b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer a, integer2 b) -{ return integer{a.value + b.value}; } - -constexpr auto operator+(integer2 a, integer2 b) -{ return integer2{a.value + b.value}; } - - -constexpr auto operator-(integer a, integer b) -{ return integer{a.value - b.value}; } - -constexpr auto operator-(integer2 a, integer b) -{ return integer{a.value - b.value}; } - -constexpr auto operator-(integer a, integer2 b) -{ return integer{a.value - b.value}; } - -constexpr auto operator-(integer2 a, integer2 b) -{ return integer2{a.value - b.value}; } - - -constexpr auto operator*(integer a, integer b) -{ return integer{a.value * b.value}; } - -constexpr auto operator*(integer2 a, integer b) -{ return integer{a.value * b.value}; } - -constexpr auto operator*(integer a, integer2 b) -{ return integer{a.value * b.value}; } - -constexpr auto operator*(integer2 a, integer2 b) -{ return integer2{a.value * b.value}; } - using Integer = datatype_t; using Integer2 = datatype_t; diff --git a/test/detail/identity/monad.cpp b/test/detail/identity/monad.cpp index 94fe26173..7e542af94 100644 --- a/test/detail/identity/monad.cpp +++ b/test/detail/identity/monad.cpp @@ -72,7 +72,7 @@ void test() { // laws { - BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check2( + BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check( list( monad(comparable(0)), monad(comparable(1)), diff --git a/test/ext/boost/fusion/foldable.cpp b/test/ext/boost/fusion/foldable.cpp new file mode 100644 index 000000000..7aafdfea4 --- /dev/null +++ b/test/ext/boost/fusion/foldable.cpp @@ -0,0 +1,96 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include + +#include "helper.hpp" +using namespace boost::hana; + + +BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { + return x % 2 == 0; +}; + +int main() { + with_nonassociative_forward_sequences([=](auto container) { + // all + { + BOOST_HANA_CONSTANT_ASSERT(all(container(), is_even)); + BOOST_HANA_RUNTIME_ASSERT(!all(container(1), is_even)); + BOOST_HANA_RUNTIME_ASSERT( all(container(2), is_even)); + BOOST_HANA_RUNTIME_ASSERT( all(container(2, 4), is_even)); + BOOST_HANA_RUNTIME_ASSERT(!all(container(1, 2), is_even)); + BOOST_HANA_RUNTIME_ASSERT(!all(container(1, 3), is_even)); + BOOST_HANA_RUNTIME_ASSERT(!all(container(1, 3, 4), is_even)); + } + + // any + { + BOOST_HANA_CONSTANT_ASSERT(!any(container(), is_even)); + BOOST_HANA_RUNTIME_ASSERT( !any(container(1), is_even)); + BOOST_HANA_RUNTIME_ASSERT( any(container(2), is_even)); + BOOST_HANA_RUNTIME_ASSERT( any(container(1, 2), is_even)); + BOOST_HANA_RUNTIME_ASSERT( !any(container(1, 3), is_even)); + BOOST_HANA_RUNTIME_ASSERT( any(container(1, 3, 4), is_even)); + } + + // none + { + BOOST_HANA_CONSTANT_ASSERT(none(container(), is_even)); + BOOST_HANA_RUNTIME_ASSERT( none(container(1), is_even)); + BOOST_HANA_RUNTIME_ASSERT(!none(container(2), is_even)); + BOOST_HANA_RUNTIME_ASSERT(!none(container(1, 2), is_even)); + BOOST_HANA_RUNTIME_ASSERT( none(container(1, 3), is_even)); + BOOST_HANA_RUNTIME_ASSERT(!none(container(1, 3, 4), is_even)); + } + + // count + { + BOOST_HANA_RUNTIME_ASSERT(count(container(), is_even) == 0); + BOOST_HANA_RUNTIME_ASSERT(count(container(1), is_even) == 0); + BOOST_HANA_RUNTIME_ASSERT(count(container(2), is_even) == 1); + BOOST_HANA_RUNTIME_ASSERT(count(container(1, 2), is_even) == 1); + BOOST_HANA_RUNTIME_ASSERT(count(container(1, 2, 3), is_even) == 1); + BOOST_HANA_RUNTIME_ASSERT(count(container(1, 2, 3, 4), is_even) == 2); + } + + // foldl + { + BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + constexpr auto s = detail::number<>(0); + BOOST_HANA_RUNTIME_ASSERT(equal(foldl(container(), s, f), s)); + BOOST_HANA_RUNTIME_ASSERT(equal(foldl(container(1), s, f), f(s, 1))); + BOOST_HANA_RUNTIME_ASSERT(equal(foldl(container(1, '2'), s, f), f(f(s, 1), '2'))); + BOOST_HANA_RUNTIME_ASSERT(equal(foldl(container(1, '2', 3.3), s, f), f(f(f(s, 1), '2'), 3.3))); + BOOST_HANA_RUNTIME_ASSERT(equal(foldl(container(1, '2', 3.3, 4.4f), s, f), f(f(f(f(s, 1), '2'), 3.3), 4.4f))); + } + + // foldr + { + BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + constexpr auto s = detail::number<>(0); + BOOST_HANA_RUNTIME_ASSERT(equal(foldr(container(), s, f), s)); + BOOST_HANA_RUNTIME_ASSERT(equal(foldr(container(1), s, f), f(1, s))); + BOOST_HANA_RUNTIME_ASSERT(equal(foldr(container(1, '2'), s, f), f(1, f('2', s)))); + BOOST_HANA_RUNTIME_ASSERT(equal(foldr(container(1, '2', 3.3), s, f), f(1, f('2', f(3.3, s))))); + BOOST_HANA_RUNTIME_ASSERT(equal(foldr(container(1, '2', 3.3, 4.4f), s, f), f(1, f('2', f(3.3, f(4.4f, s)))))); + } + + // length + { + BOOST_HANA_CONSTANT_ASSERT(length(container()) == size_t<0>); + BOOST_HANA_CONSTANT_ASSERT(length(container(1)) == size_t<1>); + BOOST_HANA_CONSTANT_ASSERT(length(container(1, '2')) == size_t<2>); + BOOST_HANA_CONSTANT_ASSERT(length(container(1, '2', 3.3)) == size_t<3>); + } + }); +} diff --git a/test/ext/boost/fusion/foldable/all.cpp b/test/ext/boost/fusion/foldable/all.cpp deleted file mode 100644 index f923f5e69..000000000 --- a/test/ext/boost/fusion/foldable/all.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include - -#include "../helper.hpp" -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { - return x % 2 == 0; -}; - -int main() { - with_nonassociative_forward_sequences([=](auto container) { - BOOST_HANA_CONSTANT_ASSERT(all(container(), is_even)); - BOOST_HANA_RUNTIME_ASSERT(!all(container(1), is_even)); - BOOST_HANA_RUNTIME_ASSERT( all(container(2), is_even)); - BOOST_HANA_RUNTIME_ASSERT( all(container(2, 4), is_even)); - BOOST_HANA_RUNTIME_ASSERT(!all(container(1, 2), is_even)); - BOOST_HANA_RUNTIME_ASSERT(!all(container(1, 3), is_even)); - BOOST_HANA_RUNTIME_ASSERT(!all(container(1, 3, 4), is_even)); - }); -} diff --git a/test/ext/boost/fusion/foldable/any.cpp b/test/ext/boost/fusion/foldable/any.cpp deleted file mode 100644 index 5ccd25bd8..000000000 --- a/test/ext/boost/fusion/foldable/any.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include - -#include "../helper.hpp" -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { - return x % 2 == 0; -}; - -int main() { - with_nonassociative_forward_sequences([=](auto container) { - BOOST_HANA_CONSTANT_ASSERT(!any(container(), is_even)); - BOOST_HANA_RUNTIME_ASSERT( !any(container(1), is_even)); - BOOST_HANA_RUNTIME_ASSERT( any(container(2), is_even)); - BOOST_HANA_RUNTIME_ASSERT( any(container(1, 2), is_even)); - BOOST_HANA_RUNTIME_ASSERT( !any(container(1, 3), is_even)); - BOOST_HANA_RUNTIME_ASSERT( any(container(1, 3, 4), is_even)); - }); -} diff --git a/test/ext/boost/fusion/foldable/count.cpp b/test/ext/boost/fusion/foldable/count.cpp deleted file mode 100644 index 2d56cd48d..000000000 --- a/test/ext/boost/fusion/foldable/count.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { - return x % 2 == 0; -}; - -int main() { - with_nonassociative_forward_sequences([=](auto container) { - assert(count(container(), is_even) == 0); - assert(count(container(1), is_even) == 0); - assert(count(container(2), is_even) == 1); - assert(count(container(1, 2), is_even) == 1); - assert(count(container(1, 2, 3), is_even) == 1); - assert(count(container(1, 2, 3, 4), is_even) == 2); - }); -} diff --git a/test/ext/boost/fusion/foldable/foldl.cpp b/test/ext/boost/fusion/foldable/foldl.cpp deleted file mode 100644 index f35889578..000000000 --- a/test/ext/boost/fusion/foldable/foldl.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include "../helper.hpp" -#include -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto xs, auto x) { - return std::tuple_cat(xs, std::make_tuple(x)); -}; - -int main() { - constexpr std::tuple<> s; - with_nonassociative_forward_sequences([=](auto container) { - assert(foldl(container(), s, f) == s); - assert(foldl(container(1), s, f) == f(s, 1)); - assert(foldl(container(1, '2'), s, f) == f(f(s, 1), '2')); - assert(foldl(container(1, '2', 3.3), s, f) == f(f(f(s, 1), '2'), 3.3)); - assert(foldl(container(1, '2', 3.3, 4.4f), s, f) == f(f(f(f(s, 1), '2'), 3.3), 4.4f)); - }); -} diff --git a/test/ext/boost/fusion/foldable/foldr.cpp b/test/ext/boost/fusion/foldable/foldr.cpp deleted file mode 100644 index 5ccf0392b..000000000 --- a/test/ext/boost/fusion/foldable/foldr.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include "../helper.hpp" -#include -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x, auto xs) { - return std::tuple_cat(std::make_tuple(x), xs); -}; - -int main() { - constexpr std::tuple<> s; - with_nonassociative_forward_sequences([=](auto container) { - assert(foldr(container(), s, f) == s); - assert(foldr(container(1), s, f) == f(1, s)); - assert(foldr(container(1, '2'), s, f) == f(1, f('2', s))); - assert(foldr(container(1, '2', 3.3), s, f) == f(1, f('2', f(3.3, s)))); - assert(foldr(container(1, '2', 3.3, 4.4f), s, f) == f(1, f('2', f(3.3, f(4.4f, s))))); - }); -} diff --git a/test/ext/boost/fusion/foldable/length.cpp b/test/ext/boost/fusion/foldable/length.cpp deleted file mode 100644 index 9a5bf23e3..000000000 --- a/test/ext/boost/fusion/foldable/length.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include - -#include "../helper.hpp" -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - BOOST_HANA_CONSTANT_ASSERT(length(container()) == size_t<0>); - BOOST_HANA_CONSTANT_ASSERT(length(container(1)) == size_t<1>); - BOOST_HANA_CONSTANT_ASSERT(length(container(1, '2')) == size_t<2>); - BOOST_HANA_CONSTANT_ASSERT(length(container(1, '2', 3.3)) == size_t<3>); - }); -} diff --git a/test/ext/boost/fusion/foldable/none.cpp b/test/ext/boost/fusion/foldable/none.cpp deleted file mode 100644 index 80161b311..000000000 --- a/test/ext/boost/fusion/foldable/none.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include - -#include "../helper.hpp" -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { - return x % 2 == 0; -}; - -int main() { - with_nonassociative_forward_sequences([=](auto container) { - BOOST_HANA_CONSTANT_ASSERT(none(container(), is_even)); - BOOST_HANA_RUNTIME_ASSERT( none(container(1), is_even)); - BOOST_HANA_RUNTIME_ASSERT(!none(container(2), is_even)); - BOOST_HANA_RUNTIME_ASSERT(!none(container(1, 2), is_even)); - BOOST_HANA_RUNTIME_ASSERT( none(container(1, 3), is_even)); - BOOST_HANA_RUNTIME_ASSERT(!none(container(1, 3, 4), is_even)); - }); -} diff --git a/test/ext/boost/fusion/functor.cpp b/test/ext/boost/fusion/functor.cpp new file mode 100644 index 000000000..88bf42332 --- /dev/null +++ b/test/ext/boost/fusion/functor.cpp @@ -0,0 +1,65 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include "helper.hpp" +using namespace boost::hana; + + +int main() { + with_nonassociative_forward_sequences([](auto container) { + // fmap + { + BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, container()), container())); + BOOST_HANA_RUNTIME_ASSERT(equal(fmap(f, container(1)), container(f(1)))); + BOOST_HANA_RUNTIME_ASSERT(equal(fmap(f, container(1, '2')), container(f(1), f('2')))); + BOOST_HANA_RUNTIME_ASSERT(equal(fmap(f, container(1, '2', 3.3)), container(f(1), f('2'), f(3.3)))); + } + + // replace + { + BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { + return x % 2 == 0; + }; + + BOOST_HANA_CONSTANT_ASSERT(equal(replace(is_even, 'x', container()), container())); + BOOST_HANA_RUNTIME_ASSERT( equal(replace(is_even, 'x', container(0)), container('x'))); + BOOST_HANA_RUNTIME_ASSERT( equal(replace(is_even, 'x', container(0, 1)), container('x', 1))); + BOOST_HANA_RUNTIME_ASSERT( equal(replace(is_even, 'x', container(0, 1, 2)), container('x', 1, 'x'))); + BOOST_HANA_RUNTIME_ASSERT( equal(replace(is_even, 'x', container(0, 1, 2, 3)), container('x', 1, 'x', 3))); + } + + // laws + { + constexpr auto x = detail::number<>; + BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_LAMBDA auto g = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_LAMBDA auto h = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_LAMBDA auto i = detail::injection([]{}); + + BOOST_HANA_RUNTIME_ASSERT(Functor::laws::check( + list( + container(), + container(x(0)), + container(x(0), x(1)), + container(x(0), x(1), x(2)) + ), + list(f, g), + list(h, i) + )); + } + }); +} diff --git a/test/ext/boost/fusion/functor/fmap.cpp b/test/ext/boost/fusion/functor/fmap.cpp deleted file mode 100644 index 9bfac885f..000000000 --- a/test/ext/boost/fusion/functor/fmap.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include "../helper.hpp" -#include -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x) { - return std::make_tuple(x); -}; - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(fmap(f, container()) == container()); - assert(fmap(f, container(1)) == container(f(1))); - assert(fmap(f, container(1, '2')) == container(f(1), f('2'))); - assert(fmap(f, container(1, '2', 3.3)) == container(f(1), f('2'), f(3.3))); - }); -} diff --git a/test/ext/boost/fusion/functor/laws.cpp b/test/ext/boost/fusion/functor/laws.cpp deleted file mode 100644 index aa1785d6c..000000000 --- a/test/ext/boost/fusion/functor/laws.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include "../helper.hpp" -#include -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -template -struct _f { - template - constexpr auto operator()(X x) const - { return std::make_tuple(i, j, x); } -}; - -template -constexpr _f f{}; - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(Functor::laws::check( - list( - container(), - container(x<0>), - container(x<0>, x<1>), - container(x<0>, x<1>, x<2>) - ), - list( - f<1, 1>, - f<1, 2> - ), - list( - f<2, 1>, - f<2, 2> - ) - )); - }); -} diff --git a/test/ext/boost/fusion/functor/replace.cpp b/test/ext/boost/fusion/functor/replace.cpp deleted file mode 100644 index 7d37aa29f..000000000 --- a/test/ext/boost/fusion/functor/replace.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { - return x % 2 == 0; -}; - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(replace(is_even, 'x', container()) == container()); - assert(replace(is_even, 'x', container(0)) == container('x')); - assert(replace(is_even, 'x', container(0, 1)) == container('x', 1)); - assert(replace(is_even, 'x', container(0, 1, 2)) == container('x', 1, 'x')); - assert(replace(is_even, 'x', container(0, 1, 2, 3)) == container('x', 1, 'x', 3)); - }); -} diff --git a/test/ext/boost/fusion/iterable.cpp b/test/ext/boost/fusion/iterable.cpp new file mode 100644 index 000000000..973fad940 --- /dev/null +++ b/test/ext/boost/fusion/iterable.cpp @@ -0,0 +1,79 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include + +#include + +#include "helper.hpp" +using namespace boost::hana; + + +int main() { + with_nonassociative_forward_sequences([](auto container) { + // at + { + BOOST_HANA_RUNTIME_ASSERT(at(size_t<0>, container(1)) == 1); + BOOST_HANA_RUNTIME_ASSERT(at(size_t<0>, container(1, '2')) == 1); + BOOST_HANA_RUNTIME_ASSERT(at(size_t<0>, container(1, '2', 3.3)) == 1); + + BOOST_HANA_RUNTIME_ASSERT(at(size_t<1>, container(1, '2')) == '2'); + BOOST_HANA_RUNTIME_ASSERT(at(size_t<1>, container(1, '2', 3.3)) == '2'); + + BOOST_HANA_RUNTIME_ASSERT(at(size_t<2>, container(1, '2', 3.3)) == 3.3); + } + + // head + { + BOOST_HANA_RUNTIME_ASSERT(head(container(1)) == 1); + BOOST_HANA_RUNTIME_ASSERT(head(container(1, '2')) == 1); + BOOST_HANA_RUNTIME_ASSERT(head(container(1, '2', 3.3)) == 1); + } + + // is_empty + { + BOOST_HANA_CONSTANT_ASSERT(is_empty(container())); + BOOST_HANA_CONSTANT_ASSERT(not_(is_empty(container(1)))); + BOOST_HANA_CONSTANT_ASSERT(not_(is_empty(container(1, '2')))); + BOOST_HANA_CONSTANT_ASSERT(not_(is_empty(container(1, '2', 3.3)))); + } + + // last + { + BOOST_HANA_RUNTIME_ASSERT(last(container(1)) == 1); + BOOST_HANA_RUNTIME_ASSERT(last(container(1, '2')) == '2'); + BOOST_HANA_RUNTIME_ASSERT(last(container(1, '2', 3.3)) == 3.3); + } + + // tail + { + BOOST_HANA_CONSTANT_ASSERT(equal(tail(container(1)), container())); + BOOST_HANA_RUNTIME_ASSERT(equal(tail(container(1, '2')), container('2'))); + BOOST_HANA_RUNTIME_ASSERT(equal(tail(container(1, '2', 3.3)), container('2', 3.3))); + } + + // for_each + { + auto check_with = [=](auto ...xs) { + std::vector seen{}; + for_each(container(xs...), [&](int x) { + seen.push_back(x); + }); + BOOST_HANA_RUNTIME_ASSERT(seen == std::vector{xs...}); + }; + check_with(); + check_with(0); + check_with(0, 1); + check_with(0, 1, 2); + check_with(0, 1, 2, 3); + check_with(0, 1, 2, 3, 4); + } + }); +} diff --git a/test/ext/boost/fusion/iterable/at.cpp b/test/ext/boost/fusion/iterable/at.cpp deleted file mode 100644 index 53638065f..000000000 --- a/test/ext/boost/fusion/iterable/at.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(at(size_t<0>, container(1)) == 1); - assert(at(size_t<0>, container(1, '2')) == 1); - assert(at(size_t<0>, container(1, '2', 3.3)) == 1); - - assert(at(size_t<1>, container(1, '2')) == '2'); - assert(at(size_t<1>, container(1, '2', 3.3)) == '2'); - - assert(at(size_t<2>, container(1, '2', 3.3)) == 3.3); - }); -} diff --git a/test/ext/boost/fusion/iterable/for_each.cpp b/test/ext/boost/fusion/iterable/for_each.cpp deleted file mode 100644 index 2b5c26b8c..000000000 --- a/test/ext/boost/fusion/iterable/for_each.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -#include -using namespace boost::hana; - - -auto test = [](auto ...xs) { - with_nonassociative_forward_sequences([=](auto container) { - std::vector seen{}; - for_each(container(xs...), [&](int x) { - seen.push_back(x); - }); - assert(seen == std::vector{xs...}); - }); -}; - -int main() { - test(); - test(0); - test(0, 1); - test(0, 1, 2); - test(0, 1, 2, 3); - test(0, 1, 2, 3, 4); -} diff --git a/test/ext/boost/fusion/iterable/head.cpp b/test/ext/boost/fusion/iterable/head.cpp deleted file mode 100644 index 556657b20..000000000 --- a/test/ext/boost/fusion/iterable/head.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -auto test = [](auto container) { - assert(head(container(1)) == 1); - assert(head(container(1, '2')) == 1); - assert(head(container(1, '2', 3.3)) == 1); -}; - -int main() { - with_nonassociative_forward_sequences(test); -} diff --git a/test/ext/boost/fusion/iterable/is_empty.cpp b/test/ext/boost/fusion/iterable/is_empty.cpp deleted file mode 100644 index 3f41ebefc..000000000 --- a/test/ext/boost/fusion/iterable/is_empty.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include "../helper.hpp" -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - BOOST_HANA_CONSTANT_ASSERT(is_empty(container())); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(container(1))); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(container(1, '2'))); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(container(1, '2', 3.3))); - }); -} diff --git a/test/ext/boost/fusion/iterable/last.cpp b/test/ext/boost/fusion/iterable/last.cpp deleted file mode 100644 index 7cbbc9b6c..000000000 --- a/test/ext/boost/fusion/iterable/last.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(last(container(1)) == 1); - assert(last(container(1, '2')) == '2'); - assert(last(container(1, '2', 3.3)) == 3.3); - }); -} diff --git a/test/ext/boost/fusion/iterable/tail.cpp b/test/ext/boost/fusion/iterable/tail.cpp deleted file mode 100644 index 0cf8e7ada..000000000 --- a/test/ext/boost/fusion/iterable/tail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -auto test = [](auto container) { - assert(equal(tail(container(1)), container())); - assert(equal(tail(container(1, '2')), container('2'))); - assert(equal(tail(container(1, '2', 3.3)), container('2', 3.3))); -}; - -int main() { - with_nonassociative_forward_sequences(test); -} diff --git a/test/ext/boost/fusion/list.cpp b/test/ext/boost/fusion/list.cpp new file mode 100644 index 000000000..bbceb96cd --- /dev/null +++ b/test/ext/boost/fusion/list.cpp @@ -0,0 +1,60 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include "helper.hpp" +using namespace boost::hana; + + +int main() { + with_nonassociative_forward_sequences([](auto container) { + // init + { + BOOST_HANA_CONSTANT_ASSERT(equal(init(container(1)), container())); + BOOST_HANA_RUNTIME_ASSERT(equal(init(container(1, '2')), container(1))); + BOOST_HANA_RUNTIME_ASSERT(equal(init(container(1, '2', 3.3)), container(1, '2'))); + } + + // concat + { + BOOST_HANA_CONSTANT_ASSERT(equal(concat(container(), container()), container())); + BOOST_HANA_RUNTIME_ASSERT(equal(concat(container(1), container()), container(1))); + BOOST_HANA_RUNTIME_ASSERT(equal(concat(container(), container(1)), container(1))); + BOOST_HANA_RUNTIME_ASSERT(equal(concat(container(1), container('2')), container(1, '2'))); + BOOST_HANA_RUNTIME_ASSERT(equal(concat(container(1, '2'), container(3.3)), container(1, '2', 3.3))); + } + + // cons + { + BOOST_HANA_RUNTIME_ASSERT(equal(cons(1, container()), container(1))); + BOOST_HANA_RUNTIME_ASSERT(equal(cons(1, container('2')), container(1, '2'))); + BOOST_HANA_RUNTIME_ASSERT(equal(cons(1, container('2', 3.3)), container(1, '2', 3.3))); + } + + // nil + { + BOOST_HANA_CONSTANT_ASSERT(equal(nil, container())); + } + + // reverse + { + BOOST_HANA_CONSTANT_ASSERT(equal(reverse(container()), container())); + BOOST_HANA_RUNTIME_ASSERT(equal(reverse(container(1)), container(1))); + BOOST_HANA_RUNTIME_ASSERT(equal(reverse(container(1, '2')), container('2', 1))); + BOOST_HANA_RUNTIME_ASSERT(equal(reverse(container(1, '2', 3.3)), container(3.3, '2', 1))); + } + + // snoc + { + BOOST_HANA_RUNTIME_ASSERT(equal(snoc(container(), 1), container(1))); + BOOST_HANA_RUNTIME_ASSERT(equal(snoc(container(1), '2'), container(1, '2'))); + BOOST_HANA_RUNTIME_ASSERT(equal(snoc(container(1, '2'), 3.3), container(1, '2', 3.3))); + } + }); +} diff --git a/test/ext/boost/fusion/list/concat.cpp b/test/ext/boost/fusion/list/concat.cpp deleted file mode 100644 index 650522cea..000000000 --- a/test/ext/boost/fusion/list/concat.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(concat(container(), container()) == container()); - assert(concat(container(1), container()) == container(1)); - assert(concat(container(), container(1)) == container(1)); - assert(concat(container(1), container('2')) == container(1, '2')); - assert(concat(container(1, '2'), container(3.3)) == container(1, '2', 3.3)); - }); -} diff --git a/test/ext/boost/fusion/list/cons.cpp b/test/ext/boost/fusion/list/cons.cpp deleted file mode 100644 index 4ff10ce58..000000000 --- a/test/ext/boost/fusion/list/cons.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -auto test = [](auto container) { - assert(equal(cons(1, container()), container(1))); - assert(equal(cons(1, container('2')), container(1, '2'))); - assert(equal(cons(1, container('2', 3.3)), container(1, '2', 3.3))); -}; - -int main() { - with_nonassociative_forward_sequences(test); -} diff --git a/test/ext/boost/fusion/list/init.cpp b/test/ext/boost/fusion/list/init.cpp deleted file mode 100644 index 53f0ba2c8..000000000 --- a/test/ext/boost/fusion/list/init.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(init(container(1)) == container()); - assert(init(container(1, '2')) == container(1)); - assert(init(container(1, '2', 3.3)) == container(1, '2')); - }); -} diff --git a/test/ext/boost/fusion/list/nil.cpp b/test/ext/boost/fusion/list/nil.cpp deleted file mode 100644 index 403b43d6a..000000000 --- a/test/ext/boost/fusion/list/nil.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -auto test = [](auto container) { - assert(equal(nil, container())); -}; - -int main() { - with_nonassociative_forward_sequences(test); -} diff --git a/test/ext/boost/fusion/list/reverse.cpp b/test/ext/boost/fusion/list/reverse.cpp deleted file mode 100644 index f52c52cf2..000000000 --- a/test/ext/boost/fusion/list/reverse.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(reverse(container()) == container()); - assert(reverse(container(1)) == container(1)); - assert(reverse(container(1, '2')) == container('2', 1)); - assert(reverse(container(1, '2', 3.3)) == container(3.3, '2', 1)); - }); -} diff --git a/test/ext/boost/fusion/list/snoc.cpp b/test/ext/boost/fusion/list/snoc.cpp deleted file mode 100644 index dc675cb5c..000000000 --- a/test/ext/boost/fusion/list/snoc.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include "../helper.hpp" -#include -using namespace boost::hana; - - -int main() { - with_nonassociative_forward_sequences([](auto container) { - assert(snoc(container(), 1) == container(1)); - assert(snoc(container(1), '2') == container(1, '2')); - assert(snoc(container(1, '2'), 3.3) == container(1, '2', 3.3)); - }); -} diff --git a/test/ext/boost/mpl/integral_c/constant/laws.cpp b/test/ext/boost/mpl/integral_c/constant.cpp similarity index 74% rename from test/ext/boost/mpl/integral_c/constant/laws.cpp rename to test/ext/boost/mpl/integral_c/constant.cpp index 332256014..e1624b039 100644 --- a/test/ext/boost/mpl/integral_c/constant/laws.cpp +++ b/test/ext/boost/mpl/integral_c/constant.cpp @@ -12,11 +12,14 @@ Distributed under the Boost Software License, Version 1.0. #include using namespace boost::hana; +namespace mpl = boost::mpl; template -void test() { - namespace mpl = boost::mpl; +struct test { + static_assert(value(mpl::integral_c{}) == 0, ""); + static_assert(value(mpl::integral_c{}) == 1, ""); + BOOST_HANA_CONSTANT_ASSERT(Constant::laws::check( list( mpl::integral_c{}, @@ -25,9 +28,9 @@ void test() { mpl::integral_c{} ) )); -} +}; -int main() { - test(); - test(); -} +template struct test; +template struct test; + +int main() { } diff --git a/test/ext/boost/mpl/integral_c/constant/value.cpp b/test/ext/boost/mpl/integral_c/constant/value.cpp deleted file mode 100644 index 19634dae8..000000000 --- a/test/ext/boost/mpl/integral_c/constant/value.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -using namespace boost::hana; - - -template -struct test { - static_assert(value(boost::mpl::integral_c{}) == 0, ""); - static_assert(value(boost::mpl::integral_c{}) == 1, ""); -}; - -template struct test; -template struct test; - -int main() { } diff --git a/test/ext/boost/mpl/list/comparable.cpp b/test/ext/boost/mpl/list/comparable.cpp new file mode 100644 index 000000000..ff84df054 --- /dev/null +++ b/test/ext/boost/mpl/list/comparable.cpp @@ -0,0 +1,43 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include + +#include +using namespace boost::hana; +namespace mpl = boost::mpl; + + +struct x0; struct x1; struct x2; + +int main() { + // equal + { + BOOST_HANA_CONSTANT_ASSERT(equal(mpl::list<>{}, mpl::list<>{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list{}, mpl::list<>{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list<>{}, mpl::list{})); + BOOST_HANA_CONSTANT_ASSERT(equal(mpl::list{}, mpl::list{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list{}, mpl::list{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list{}, mpl::list{})); + BOOST_HANA_CONSTANT_ASSERT(equal(mpl::list{}, mpl::list{})); + } + + // laws + { + BOOST_HANA_CONSTANT_ASSERT( + Comparable::laws::check( + list( + mpl::list<>{}, mpl::list{}, mpl::list{}, + mpl::list{}, mpl::list{} + ) + ) + ); + } +} diff --git a/test/ext/boost/mpl/list/comparable/equal.cpp b/test/ext/boost/mpl/list/comparable/equal.cpp deleted file mode 100644 index 948b873d0..000000000 --- a/test/ext/boost/mpl/list/comparable/equal.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -struct x0; struct x1; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(mpl::list<>{}, mpl::list<>{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list{}, mpl::list<>{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list<>{}, mpl::list{})); - BOOST_HANA_CONSTANT_ASSERT(equal(mpl::list{}, mpl::list{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list{}, mpl::list{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::list{}, mpl::list{})); - BOOST_HANA_CONSTANT_ASSERT(equal(mpl::list{}, mpl::list{})); -} diff --git a/test/ext/boost/mpl/list/comparable/laws.cpp b/test/ext/boost/mpl/list/comparable/laws.cpp deleted file mode 100644 index 15c03b071..000000000 --- a/test/ext/boost/mpl/list/comparable/laws.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -template struct x; - -template -constexpr boost::mpl::list...> mpl_list{}; - -int main() { - BOOST_HANA_CONSTANT_ASSERT( - Comparable::laws::check( - list( - mpl_list<>, mpl_list<0>, mpl_list<0, 1>, - mpl_list<0, 1, 2>, mpl_list<1, 0, 2> - ) - ) - ); -} diff --git a/test/ext/boost/mpl/list/functor.cpp b/test/ext/boost/mpl/list/functor.cpp new file mode 100644 index 000000000..6735f96bf --- /dev/null +++ b/test/ext/boost/mpl/list/functor.cpp @@ -0,0 +1,58 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include + +#include +using namespace boost::hana; +namespace mpl = boost::mpl; + + +template +struct f; + +template +struct result { + template + struct apply { using type = apply; }; +}; + +struct x0; struct x1; struct x2; + +int main() { + // fmap + { + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list<>{}), mpl::list<>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list{}), mpl::list>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list{}), mpl::list, f>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list{}), mpl::list, f, f>{})); + } + + // laws + { + BOOST_HANA_CONSTANT_ASSERT(Functor::laws::check( + list( + mpl::list<>{}, + mpl::list{}, + mpl::list{}, + mpl::list{} + ), + list( + metafunction_class>, + metafunction_class> + ), + list( + metafunction_class>, + metafunction_class> + ) + )); + } +} diff --git a/test/ext/boost/mpl/list/functor/fmap.cpp b/test/ext/boost/mpl/list/functor/fmap.cpp deleted file mode 100644 index 05839d12f..000000000 --- a/test/ext/boost/mpl/list/functor/fmap.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -template -struct f; - -struct x0; struct x1; struct x2; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list<>{}), mpl::list<>{})); - BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list{}), mpl::list>{})); - BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list{}), mpl::list, f>{})); - BOOST_HANA_CONSTANT_ASSERT(equal(fmap(template_, mpl::list{}), mpl::list, f, f>{})); -} diff --git a/test/ext/boost/mpl/list/functor/laws.cpp b/test/ext/boost/mpl/list/functor/laws.cpp deleted file mode 100644 index 834b3062e..000000000 --- a/test/ext/boost/mpl/list/functor/laws.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -template -struct result { - template - struct apply { using type = apply; }; -}; - -struct x0; struct x1; struct x2; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(Functor::laws::check( - list( - mpl::list<>{}, - mpl::list{}, - mpl::list{}, - mpl::list{} - ), - list( - metafunction_class>, - metafunction_class> - ), - list( - metafunction_class>, - metafunction_class> - ) - )); -} diff --git a/test/ext/boost/mpl/vector/comparable.cpp b/test/ext/boost/mpl/vector/comparable.cpp new file mode 100644 index 000000000..00412c9a2 --- /dev/null +++ b/test/ext/boost/mpl/vector/comparable.cpp @@ -0,0 +1,43 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include + +#include +using namespace boost::hana; +namespace mpl = boost::mpl; + + +struct x0; struct x1; struct x2; + +int main() { + // equal + { + BOOST_HANA_CONSTANT_ASSERT(equal(mpl::vector<>{}, mpl::vector<>{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector{}, mpl::vector<>{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector<>{}, mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(equal(mpl::vector{}, mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector{}, mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector{}, mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(equal(mpl::vector{}, mpl::vector{})); + } + + // laws + { + BOOST_HANA_CONSTANT_ASSERT( + Comparable::laws::check( + list( + mpl::vector<>{}, mpl::vector{}, mpl::vector{}, + mpl::vector{}, mpl::vector{} + ) + ) + ); + } +} diff --git a/test/ext/boost/mpl/vector/comparable/equal.cpp b/test/ext/boost/mpl/vector/comparable/equal.cpp deleted file mode 100644 index 2bfd8f01f..000000000 --- a/test/ext/boost/mpl/vector/comparable/equal.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -struct x0; struct x1; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(mpl::vector<>{}, mpl::vector<>{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector{}, mpl::vector<>{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector<>{}, mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(equal(mpl::vector{}, mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector{}, mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(mpl::vector{}, mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(equal(mpl::vector{}, mpl::vector{})); -} diff --git a/test/ext/boost/mpl/vector/comparable/laws.cpp b/test/ext/boost/mpl/vector/comparable/laws.cpp deleted file mode 100644 index 5e6ebd494..000000000 --- a/test/ext/boost/mpl/vector/comparable/laws.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -template struct x; - -template -constexpr boost::mpl::vector...> mpl_vector{}; - -int main() { - BOOST_HANA_CONSTANT_ASSERT( - Comparable::laws::check( - list( - mpl_vector<>, mpl_vector<0>, mpl_vector<0, 1>, - mpl_vector<0, 1, 2>, mpl_vector<1, 0, 2> - ) - ) - ); -} diff --git a/test/ext/boost/mpl/vector/functor.cpp b/test/ext/boost/mpl/vector/functor.cpp new file mode 100644 index 000000000..32d36ac00 --- /dev/null +++ b/test/ext/boost/mpl/vector/functor.cpp @@ -0,0 +1,71 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include + +#include +using namespace boost::hana; +namespace mpl = boost::mpl; + + +template struct F; +constexpr auto f = template_; + +BOOST_HANA_CONSTEXPR_LAMBDA auto g = [](auto t) { + return type>; +}; + +template +struct result { + template + struct apply { using type = apply; }; +}; + +struct x0; struct x1; struct x2; + + +int main() { + (void)g; + + // fmap + { + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector<>{}), mpl::vector<>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector{}), mpl::vector>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector{}), mpl::vector, F>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector{}), mpl::vector, F, F>{})); + + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector<>{}), mpl::vector<>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector{}), mpl::vector>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector{}), mpl::vector, F>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector{}), mpl::vector, F, F>{})); + } + + // laws + { + BOOST_HANA_CONSTANT_ASSERT(Functor::laws::check( + list( + mpl::vector<>{}, + mpl::vector{}, + mpl::vector{}, + mpl::vector{} + ), + list( + metafunction_class>, + metafunction_class> + ), + list( + metafunction_class>, + metafunction_class> + ) + )); + } +} diff --git a/test/ext/boost/mpl/vector/functor/fmap.cpp b/test/ext/boost/mpl/vector/functor/fmap.cpp deleted file mode 100644 index 4119550fd..000000000 --- a/test/ext/boost/mpl/vector/functor/fmap.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -template struct F; -constexpr auto f = template_; - -BOOST_HANA_CONSTEXPR_LAMBDA auto g = [](auto t) { - return type>; -}; - -struct x0; struct x1; struct x2; - -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector<>{}), mpl::vector<>{})); -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector{}), mpl::vector>{})); -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector{}), mpl::vector, F>{})); -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, mpl::vector{}), mpl::vector, F, F>{})); - -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector<>{}), mpl::vector<>{})); -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector{}), mpl::vector>{})); -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector{}), mpl::vector, F>{})); -BOOST_HANA_CONSTANT_ASSERT(equal(fmap(g, mpl::vector{}), mpl::vector, F, F>{})); - -int main() { (void)g; } diff --git a/test/ext/boost/mpl/vector/functor/laws.cpp b/test/ext/boost/mpl/vector/functor/laws.cpp deleted file mode 100644 index 055ae5a2b..000000000 --- a/test/ext/boost/mpl/vector/functor/laws.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -template -struct result { - template - struct apply { using type = apply; }; -}; - -struct x0; struct x1; struct x2; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(Functor::laws::check( - list( - mpl::vector<>{}, - mpl::vector{}, - mpl::vector{}, - mpl::vector{} - ), - list( - metafunction_class>, - metafunction_class> - ), - list( - metafunction_class>, - metafunction_class> - ) - )); -} diff --git a/test/ext/boost/mpl/vector/iterable.cpp b/test/ext/boost/mpl/vector/iterable.cpp new file mode 100644 index 000000000..062da7bc5 --- /dev/null +++ b/test/ext/boost/mpl/vector/iterable.cpp @@ -0,0 +1,45 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include + +#include +using namespace boost::hana; +namespace mpl = boost::mpl; + + +struct x1; struct x2; struct x3; + +int main() { + // head + { + BOOST_HANA_CONSTANT_ASSERT(head(mpl::vector{}) == type); + BOOST_HANA_CONSTANT_ASSERT(head(mpl::vector{}) == type); + BOOST_HANA_CONSTANT_ASSERT(head(mpl::vector{}) == type); + } + + // tail + { + BOOST_HANA_CONSTANT_ASSERT(equal(tail(mpl::vector{}), mpl::vector<>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(tail(mpl::vector{}), mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(equal(tail(mpl::vector{}), mpl::vector{})); + } + + // is_empty + { + BOOST_HANA_CONSTANT_ASSERT(is_empty(mpl::vector<>{})); + BOOST_HANA_CONSTANT_ASSERT(is_empty(mpl::vector0<>{})); + + BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector1{})); + + BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector2{})); + } +} diff --git a/test/ext/boost/mpl/vector/iterable/head.cpp b/test/ext/boost/mpl/vector/iterable/head.cpp deleted file mode 100644 index 6e6487d74..000000000 --- a/test/ext/boost/mpl/vector/iterable/head.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -struct x1; struct x2; struct x3; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(head(mpl::vector{}) == type); - BOOST_HANA_CONSTANT_ASSERT(head(mpl::vector{}) == type); - BOOST_HANA_CONSTANT_ASSERT(head(mpl::vector{}) == type); -} diff --git a/test/ext/boost/mpl/vector/iterable/is_empty.cpp b/test/ext/boost/mpl/vector/iterable/is_empty.cpp deleted file mode 100644 index 9ea14f57d..000000000 --- a/test/ext/boost/mpl/vector/iterable/is_empty.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(is_empty(mpl::vector<>{})); - BOOST_HANA_CONSTANT_ASSERT(is_empty(mpl::vector0<>{})); - - BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector1{})); - - BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(mpl::vector2{})); -} diff --git a/test/ext/boost/mpl/vector/iterable/tail.cpp b/test/ext/boost/mpl/vector/iterable/tail.cpp deleted file mode 100644 index 8420166a0..000000000 --- a/test/ext/boost/mpl/vector/iterable/tail.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -struct x0; struct x1; struct x2; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(tail(mpl::vector{}), mpl::vector<>{})); - BOOST_HANA_CONSTANT_ASSERT(equal(tail(mpl::vector{}), mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(equal(tail(mpl::vector{}), mpl::vector{})); -} diff --git a/test/ext/boost/mpl/vector/list.cpp b/test/ext/boost/mpl/vector/list.cpp new file mode 100644 index 000000000..3d79a19af --- /dev/null +++ b/test/ext/boost/mpl/vector/list.cpp @@ -0,0 +1,32 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include + +#include +using namespace boost::hana; +namespace mpl = boost::mpl; + + +struct x1; struct x2; struct x3; + +int main() { + // cons + { + BOOST_HANA_CONSTANT_ASSERT(equal(cons(type, mpl::vector<>{}), mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(equal(cons(type, mpl::vector{}), mpl::vector{})); + BOOST_HANA_CONSTANT_ASSERT(equal(cons(type, mpl::vector{}), mpl::vector{})); + } + + // nil + { + BOOST_HANA_CONSTANT_ASSERT(equal(nil, mpl::vector<>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(nil, mpl::vector0<>{})); + } +} diff --git a/test/ext/boost/mpl/vector/list/cons.cpp b/test/ext/boost/mpl/vector/list/cons.cpp deleted file mode 100644 index c3a897652..000000000 --- a/test/ext/boost/mpl/vector/list/cons.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -struct x0; struct x1; struct x2; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(cons(type, mpl::vector<>{}), mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(equal(cons(type, mpl::vector{}), mpl::vector{})); - BOOST_HANA_CONSTANT_ASSERT(equal(cons(type, mpl::vector{}), mpl::vector{})); -} diff --git a/test/ext/boost/mpl/vector/list/nil.cpp b/test/ext/boost/mpl/vector/list/nil.cpp deleted file mode 100644 index 83440ead5..000000000 --- a/test/ext/boost/mpl/vector/list/nil.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; -namespace mpl = boost::mpl; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(nil, mpl::vector<>{})); - BOOST_HANA_CONSTANT_ASSERT(equal(nil, mpl::vector0<>{})); -} diff --git a/test/ext/boost/tuple/iterable.cpp b/test/ext/boost/tuple/iterable.cpp new file mode 100644 index 000000000..858572245 --- /dev/null +++ b/test/ext/boost/tuple/iterable.cpp @@ -0,0 +1,39 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include +using namespace boost::hana; + + +int main() { + // head + { + BOOST_HANA_CONSTEXPR_ASSERT(head(boost::make_tuple(1)) == 1); + BOOST_HANA_CONSTEXPR_ASSERT(head(boost::make_tuple(1, '2')) == 1); + BOOST_HANA_CONSTEXPR_ASSERT(head(boost::make_tuple(1, '2', 3.3)) == 1); + } + + // is_empty + { + BOOST_HANA_CONSTANT_ASSERT(is_empty(boost::make_tuple())); + BOOST_HANA_CONSTANT_ASSERT(is_empty(boost::tuples::null_type{})); + + BOOST_HANA_CONSTANT_ASSERT(!is_empty(boost::make_tuple(1))); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(boost::make_tuple(1, '2'))); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(boost::make_tuple(1, '2', 3.3))); + } + + // tail + { + BOOST_HANA_CONSTANT_ASSERT(equal(tail(boost::make_tuple(1)), boost::make_tuple())); + BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(boost::make_tuple(1, '2')), boost::make_tuple('2'))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(boost::make_tuple(1, '2', 3.3)), boost::make_tuple('2', 3.3))); + } +} diff --git a/test/ext/boost/tuple/iterable/head.cpp b/test/ext/boost/tuple/iterable/head.cpp deleted file mode 100644 index cf55c4956..000000000 --- a/test/ext/boost/tuple/iterable/head.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -int main() { - assert(head(boost::make_tuple(1)) == 1); - assert(head(boost::make_tuple(1, '2')) == 1); - assert(head(boost::make_tuple(1, '2', 3.3)) == 1); -} diff --git a/test/ext/boost/tuple/iterable/is_empty.cpp b/test/ext/boost/tuple/iterable/is_empty.cpp deleted file mode 100644 index cc9ab18fd..000000000 --- a/test/ext/boost/tuple/iterable/is_empty.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(is_empty(boost::make_tuple())); - BOOST_HANA_CONSTANT_ASSERT(is_empty(boost::tuples::null_type{})); - - BOOST_HANA_CONSTANT_ASSERT(!is_empty(boost::make_tuple(1))); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(boost::make_tuple(1, '2'))); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(boost::make_tuple(1, '2', 3.3))); -} diff --git a/test/ext/boost/tuple/iterable/tail.cpp b/test/ext/boost/tuple/iterable/tail.cpp deleted file mode 100644 index bf713ddbf..000000000 --- a/test/ext/boost/tuple/iterable/tail.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -int main() { - assert(equal(tail(boost::make_tuple(1)), boost::make_tuple())); - assert(equal(tail(boost::make_tuple(1, '2')), boost::make_tuple('2'))); - assert(equal(tail(boost::make_tuple(1, '2', 3.3)), boost::make_tuple('2', 3.3))); -} diff --git a/test/ext/boost/tuple/list.cpp b/test/ext/boost/tuple/list.cpp new file mode 100644 index 000000000..cc068ae6b --- /dev/null +++ b/test/ext/boost/tuple/list.cpp @@ -0,0 +1,28 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include +using namespace boost::hana; + + +int main() { + // cons + { + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(1, boost::tuples::null_type{}), boost::make_tuple(1))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(1, cons('2', boost::tuples::null_type{})), boost::make_tuple(1, '2'))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(1, cons('2', boost::make_tuple(3.3))), boost::make_tuple(1, '2', 3.3))); + } + + // nil + { + BOOST_HANA_CONSTANT_ASSERT(equal(nil, boost::make_tuple())); + BOOST_HANA_CONSTANT_ASSERT(equal(nil, boost::tuples::null_type{})); + } +} diff --git a/test/ext/boost/tuple/list/cons.cpp b/test/ext/boost/tuple/list/cons.cpp deleted file mode 100644 index 8ec833247..000000000 --- a/test/ext/boost/tuple/list/cons.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -int main() { - assert(equal(cons(1, boost::tuples::null_type{}), boost::make_tuple(1))); - assert(equal(cons(1, cons('2', boost::tuples::null_type{})), boost::make_tuple(1, '2'))); - assert(equal(cons(1, cons('2', boost::make_tuple(3.3))), boost::make_tuple(1, '2', 3.3))); -} diff --git a/test/ext/boost/tuple/list/nil.cpp b/test/ext/boost/tuple/list/nil.cpp deleted file mode 100644 index 277181cad..000000000 --- a/test/ext/boost/tuple/list/nil.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -int main() { - assert(equal(nil, boost::make_tuple())); - assert(equal(nil, boost::tuples::null_type{})); -} diff --git a/test/ext/std/array/iterable.cpp b/test/ext/std/array/iterable.cpp new file mode 100644 index 000000000..0571c6cb0 --- /dev/null +++ b/test/ext/std/array/iterable.cpp @@ -0,0 +1,40 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include +using namespace boost::hana; + + +template +auto array = std::array{{i...}}; + +int main() { + // is_empty + { + BOOST_HANA_CONSTANT_ASSERT(is_empty(array<>)); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(array<0>)); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(array<0, 1>)); + } + + // head + { + BOOST_HANA_CONSTEXPR_ASSERT(head(array<0>) == 0); + BOOST_HANA_CONSTEXPR_ASSERT(head(array<0, 1>) == 0); + BOOST_HANA_CONSTEXPR_ASSERT(head(array<0, 1, 2>) == 0); + } + + // tail + { + BOOST_HANA_CONSTANT_ASSERT(equal(tail(array<0>), array<>)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1>), array<1>)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1, 2>), array<1, 2>)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1, 2, 3>), array<1, 2, 3>)); + } +} diff --git a/test/ext/std/array/iterable/head.cpp b/test/ext/std/array/iterable/head.cpp deleted file mode 100644 index 446085820..000000000 --- a/test/ext/std/array/iterable/head.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -template -constexpr auto array = std::array{{i...}}; - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(head(array<0>) == 0); - BOOST_HANA_CONSTEXPR_ASSERT(head(array<0, 1>) == 0); - BOOST_HANA_CONSTEXPR_ASSERT(head(array<0, 1, 2>) == 0); -} diff --git a/test/ext/std/array/iterable/is_empty.cpp b/test/ext/std/array/iterable/is_empty.cpp deleted file mode 100644 index 0ed2a8495..000000000 --- a/test/ext/std/array/iterable/is_empty.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -template - auto array = std::array{{i...}}; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(is_empty(array<>)); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(array<0>)); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(array<0, 1>)); -} diff --git a/test/ext/std/array/iterable/tail.cpp b/test/ext/std/array/iterable/tail.cpp deleted file mode 100644 index 0c38b0013..000000000 --- a/test/ext/std/array/iterable/tail.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -template -constexpr auto array = std::array{{i...}}; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(tail(array<0>), array<>)); - BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1>), array<1>)); - BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1, 2>), array<1, 2>)); - BOOST_HANA_CONSTEXPR_ASSERT(equal(tail(array<0, 1, 2, 3>), array<1, 2, 3>)); -} diff --git a/test/ext/std/array/list.cpp b/test/ext/std/array/list.cpp new file mode 100644 index 000000000..cefa3ff89 --- /dev/null +++ b/test/ext/std/array/list.cpp @@ -0,0 +1,35 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include +using namespace boost::hana; + + +template +auto array = std::array{{i...}}; + +int main() { + // nil + { + BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::array{})); + BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::array{})); + BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::array{})); + } + + // cons + { + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<>), array<0>)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<1>), array<0, 1>)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<1, 2>), array<0, 1, 2>)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<1, 2, 3>), array<0, 1, 2, 3>)); + + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, nil), array<0>)); + } +} diff --git a/test/ext/std/array/list/cons.cpp b/test/ext/std/array/list/cons.cpp deleted file mode 100644 index 6c3cfe4e1..000000000 --- a/test/ext/std/array/list/cons.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -template -constexpr auto array = std::array{{i...}}; - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<>), array<0>)); - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<1>), array<0, 1>)); - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<1, 2>), array<0, 1, 2>)); - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, array<1, 2, 3>), array<0, 1, 2, 3>)); - - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, nil), array<0>)); -} diff --git a/test/ext/std/array/list/nil.cpp b/test/ext/std/array/list/nil.cpp deleted file mode 100644 index 6c9f31acb..000000000 --- a/test/ext/std/array/list/nil.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::array{})); - BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::array{})); - BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::array{})); -} diff --git a/test/ext/std/integer_sequence/comparable.cpp b/test/ext/std/integer_sequence/comparable.cpp new file mode 100644 index 000000000..a7f59d82f --- /dev/null +++ b/test/ext/std/integer_sequence/comparable.cpp @@ -0,0 +1,60 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include + +#include +using namespace boost::hana; + + +template +void test() { + // equal + { + BOOST_HANA_CONSTANT_ASSERT(equal(std::integer_sequence{}, std::integer_sequence{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); + + BOOST_HANA_CONSTANT_ASSERT(equal(std::integer_sequence{}, std::integer_sequence{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); + + BOOST_HANA_CONSTANT_ASSERT(equal(std::integer_sequence{}, std::integer_sequence{})); + BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); + } + + // laws + { + BOOST_HANA_CONSTANT_ASSERT( + Comparable::laws::check( + list( + std::integer_sequence{}, + std::integer_sequence{}, + + std::integer_sequence{}, + std::integer_sequence{}, + + std::integer_sequence{}, + std::integer_sequence{}, + + std::integer_sequence{}, + std::integer_sequence{} + ) + ) + ); + } +} + +int main() { + test(); + test(); + test(); + test(); +} diff --git a/test/ext/std/integer_sequence/comparable/equal.cpp b/test/ext/std/integer_sequence/comparable/equal.cpp deleted file mode 100644 index e499e7e51..000000000 --- a/test/ext/std/integer_sequence/comparable/equal.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -template -void test() { - BOOST_HANA_CONSTANT_ASSERT(equal(std::integer_sequence{}, std::integer_sequence{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); - - BOOST_HANA_CONSTANT_ASSERT(equal(std::integer_sequence{}, std::integer_sequence{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); - - BOOST_HANA_CONSTANT_ASSERT(equal(std::integer_sequence{}, std::integer_sequence{})); - BOOST_HANA_CONSTANT_ASSERT(!equal(std::integer_sequence{}, std::integer_sequence{})); -} - -template -void test_partial() { - test(); - test(); - test(); - test(); - test(); - - test(); - test(); - test(); - test(); -} - -int main() { - test_partial(); - test_partial(); - test_partial(); - test_partial(); - test_partial(); - - test_partial(); - test_partial(); - test_partial(); - test_partial(); -} diff --git a/test/ext/std/integer_sequence/comparable/laws.cpp b/test/ext/std/integer_sequence/comparable/laws.cpp deleted file mode 100644 index 69b85fa93..000000000 --- a/test/ext/std/integer_sequence/comparable/laws.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -template -void test() { - BOOST_HANA_CONSTANT_ASSERT( - Comparable::laws::check( - list( - std::integer_sequence{}, - std::integer_sequence{}, - - std::integer_sequence{}, - std::integer_sequence{}, - - std::integer_sequence{}, - std::integer_sequence{}, - - std::integer_sequence{}, - std::integer_sequence{} - ) - ) - ); -} - -int main() { - test(); - test(); -} diff --git a/test/ext/std/integer_sequence/iterable.cpp b/test/ext/std/integer_sequence/iterable.cpp new file mode 100644 index 000000000..b3ce0c09c --- /dev/null +++ b/test/ext/std/integer_sequence/iterable.cpp @@ -0,0 +1,35 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include +using namespace boost::hana; + + +int main() { + // head + { + BOOST_HANA_CONSTEXPR_ASSERT(head(std::index_sequence<0>{}) == 0); + BOOST_HANA_CONSTEXPR_ASSERT(head(std::index_sequence<0, 1>{}) == 0); + } + + // is_empty + { + BOOST_HANA_CONSTANT_ASSERT(is_empty(std::index_sequence<>{})); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(std::index_sequence<0>{})); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(std::index_sequence<1>{})); + } + + // tail + { + BOOST_HANA_CONSTANT_ASSERT(equal(tail(std::index_sequence<0>{}), std::index_sequence<>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(tail(std::index_sequence<0, 1>{}), std::index_sequence<1>{})); + BOOST_HANA_CONSTANT_ASSERT(equal(tail(std::index_sequence<0, 1, 2>{}), std::index_sequence<1, 2>{})); + } +} diff --git a/test/ext/std/integer_sequence/iterable/head.cpp b/test/ext/std/integer_sequence/iterable/head.cpp deleted file mode 100644 index d6e754234..000000000 --- a/test/ext/std/integer_sequence/iterable/head.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(head(std::index_sequence<0>{}) == 0); - BOOST_HANA_CONSTEXPR_ASSERT(head(std::index_sequence<0, 1>{}) == 0); -} diff --git a/test/ext/std/integer_sequence/iterable/is_empty.cpp b/test/ext/std/integer_sequence/iterable/is_empty.cpp deleted file mode 100644 index 94e87c4f9..000000000 --- a/test/ext/std/integer_sequence/iterable/is_empty.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(is_empty(std::index_sequence<>{})); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(std::index_sequence<0>{})); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(std::index_sequence<1>{})); -} diff --git a/test/ext/std/integer_sequence/iterable/tail.cpp b/test/ext/std/integer_sequence/iterable/tail.cpp deleted file mode 100644 index f9a0a0552..000000000 --- a/test/ext/std/integer_sequence/iterable/tail.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(tail(std::index_sequence<0>{}), std::index_sequence<>{})); - BOOST_HANA_CONSTANT_ASSERT(equal(tail(std::index_sequence<0, 1>{}), std::index_sequence<1>{})); - BOOST_HANA_CONSTANT_ASSERT(equal(tail(std::index_sequence<0, 1, 2>{}), std::index_sequence<1, 2>{})); -} diff --git a/test/ext/std/pair/pair.cpp b/test/ext/std/pair/pair.cpp deleted file mode 100644 index cf5278899..000000000 --- a/test/ext/std/pair/pair.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(first(std::make_pair(1, '2')) == 1); - BOOST_HANA_CONSTEXPR_ASSERT(second(std::make_pair(1, '2')) == '2'); -} diff --git a/test/ext/std/pair/product.cpp b/test/ext/std/pair/product.cpp new file mode 100644 index 000000000..4f71b6385 --- /dev/null +++ b/test/ext/std/pair/product.cpp @@ -0,0 +1,33 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include +using namespace boost::hana; + + +int main() { + // first + { + BOOST_HANA_CONSTEXPR_ASSERT(first(std::make_pair(1, '2')) == 1); + } + + // second + { + BOOST_HANA_CONSTEXPR_ASSERT(second(std::make_pair(1, '2')) == '2'); + } + + // make_product + { + BOOST_HANA_CONSTEXPR_ASSERT(equal( + std::make_pair(1, '2'), + make_product(1, '2') + )); + } +} diff --git a/test/ext/std/tuple/functor.cpp b/test/ext/std/tuple/functor.cpp new file mode 100644 index 000000000..1f2838b79 --- /dev/null +++ b/test/ext/std/tuple/functor.cpp @@ -0,0 +1,49 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +using namespace boost::hana; + + +int main() { + // fmap + { + BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + constexpr auto x = detail::number<>; + BOOST_HANA_CONSTANT_ASSERT(equal(fmap(f, std::make_tuple()), std::make_tuple())); + BOOST_HANA_CONSTEXPR_ASSERT(equal(fmap(f, std::make_tuple(x(1))), std::make_tuple(f(x(1))))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(fmap(f, std::make_tuple(x(1), x(2))), std::make_tuple(f(x(1)), f(x(2))))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(fmap(f, std::make_tuple(x(1), x(2), x(3))), std::make_tuple(f(x(1)), f(x(2)), f(x(3))))); + } + + // laws + { + constexpr auto x = detail::number<>; + BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_LAMBDA auto g = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_LAMBDA auto h = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_LAMBDA auto i = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_ASSERT(Functor::laws::check( + list( + std::make_tuple(), + std::make_tuple(x(0)), + std::make_tuple(x(0), x(1)), + std::make_tuple(x(0), x(1), x(2)) + ), + list(f, g), + list(h, i) + )); + } +} diff --git a/test/ext/std/tuple/functor/fmap.cpp b/test/ext/std/tuple/functor/fmap.cpp deleted file mode 100644 index b596e2e3e..000000000 --- a/test/ext/std/tuple/functor/fmap.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto i) { return i + int_<1>; }; - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(fmap(f, std::make_tuple()) == std::make_tuple()); - BOOST_HANA_CONSTEXPR_ASSERT(fmap(f, std::make_tuple(int_<1>)) == std::make_tuple(f(int_<1>))); - BOOST_HANA_CONSTEXPR_ASSERT(fmap(f, std::make_tuple(int_<1>, int_<2>)) == std::make_tuple(f(int_<1>), f(int_<2>))); - BOOST_HANA_CONSTEXPR_ASSERT(fmap(f, std::make_tuple(int_<1>, int_<2>, int_<3>)) == std::make_tuple(f(int_<1>), f(int_<2>), f(int_<3>))); -} diff --git a/test/ext/std/tuple/functor/laws.cpp b/test/ext/std/tuple/functor/laws.cpp deleted file mode 100644 index 02aba8621..000000000 --- a/test/ext/std/tuple/functor/laws.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include - -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -template -struct _f { - template - constexpr auto operator()(X x) const - { return std::make_tuple(i, j, x); } -}; - -template -constexpr _f f{}; - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(Functor::laws::check( - list( - std::make_tuple(), - std::make_tuple(x<0>), - std::make_tuple(x<0>, x<1>), - std::make_tuple(x<0>, x<1>, x<2>) - ), - list( - f<1, 1>, - f<1, 2> - ), - list( - f<2, 1>, - f<2, 2> - ) - )); -} diff --git a/test/ext/std/tuple/list.cpp b/test/ext/std/tuple/list.cpp new file mode 100644 index 000000000..3638fe936 --- /dev/null +++ b/test/ext/std/tuple/list.cpp @@ -0,0 +1,28 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include + +#include +using namespace boost::hana; + + +int main() { + // cons + { + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple()), std::make_tuple(0))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple('1')), std::make_tuple(0, '1'))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple('1', 2.2)), std::make_tuple(0, '1', 2.2))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple('1', 2.2, nullptr)), std::make_tuple(0, '1', 2.2, nullptr))); + } + + // nil + { + BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::make_tuple())); + } +} diff --git a/test/ext/std/tuple/list/cons.cpp b/test/ext/std/tuple/list/cons.cpp deleted file mode 100644 index 7a900bb82..000000000 --- a/test/ext/std/tuple/list/cons.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple()), std::make_tuple(0))); - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple('1')), std::make_tuple(0, '1'))); - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple('1', 2.2)), std::make_tuple(0, '1', 2.2))); - BOOST_HANA_CONSTEXPR_ASSERT(equal(cons(0, std::make_tuple('1', 2.2, nullptr)), std::make_tuple(0, '1', 2.2, nullptr))); -} diff --git a/test/ext/std/tuple/list/nil.cpp b/test/ext/std/tuple/list/nil.cpp deleted file mode 100644 index 6a8b410cc..000000000 --- a/test/ext/std/tuple/list/nil.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(equal(nil, std::make_tuple())); -} diff --git a/test/ext/std/tuple/monad.cpp b/test/ext/std/tuple/monad.cpp new file mode 100644 index 000000000..28ccf755d --- /dev/null +++ b/test/ext/std/tuple/monad.cpp @@ -0,0 +1,68 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +using namespace boost::hana; + + +int main() { + constexpr auto x = detail::number<>; + + // flatten + { + BOOST_HANA_CONSTANT_ASSERT(equal( + flatten(std::make_tuple(std::make_tuple(), std::make_tuple())), + std::make_tuple() + )); + BOOST_HANA_CONSTEXPR_ASSERT(equal( + flatten(std::make_tuple(std::make_tuple(x(0)), std::make_tuple())), + std::make_tuple(x(0)) + )); + BOOST_HANA_CONSTEXPR_ASSERT(equal( + flatten(std::make_tuple(std::make_tuple(), std::make_tuple(x(0)))), + std::make_tuple(x(0)) + )); + BOOST_HANA_CONSTEXPR_ASSERT(equal( + flatten(std::make_tuple(std::make_tuple(x(0)), std::make_tuple(x(1)))), + std::make_tuple(x(0), x(1)) + )); + BOOST_HANA_CONSTEXPR_ASSERT(equal( + flatten(std::make_tuple(std::make_tuple(0, x(1)), std::make_tuple(), std::make_tuple('2', 3.3), std::make_tuple(x(4)))), + std::make_tuple(0, x(1), '2', 3.3, x(4)) + )); + } + + // laws + { + BOOST_HANA_CONSTEXPR_LAMBDA auto make = [](auto ...xs) + { return std::make_tuple(xs...); }; + BOOST_HANA_CONSTEXPR_LAMBDA auto f = compose(make, detail::injection([]{})); + BOOST_HANA_CONSTEXPR_LAMBDA auto g = compose(make, detail::injection([]{})); + BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check( + list( + std::make_tuple(), + std::make_tuple(x(1)), + std::make_tuple(x(1), x(2)), + std::make_tuple(1, 2, 3, 4) + ), + list( + x(1), x(2), x(3) + ), + list(f), + list(g) + )); + } +} diff --git a/test/ext/std/tuple/monad/flatten.cpp b/test/ext/std/tuple/monad/flatten.cpp deleted file mode 100644 index 260ffaabb..000000000 --- a/test/ext/std/tuple/monad/flatten.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto tuple = [](auto ...xs) { - return std::make_tuple(xs...); -}; - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(flatten(tuple(tuple(), tuple())) == tuple()); - BOOST_HANA_CONSTEXPR_ASSERT(flatten(tuple(tuple(int_<0>), tuple())) == tuple(int_<0>)); - BOOST_HANA_CONSTEXPR_ASSERT(flatten(tuple(tuple(), tuple(int_<0>))) == tuple(int_<0>)); - BOOST_HANA_CONSTEXPR_ASSERT(flatten(tuple(tuple(int_<0>), tuple(int_<1>))) == tuple(int_<0>, int_<1>)); - BOOST_HANA_CONSTEXPR_ASSERT( - flatten(tuple(tuple(0, int_<1>), tuple(), tuple('2', 3.3), tuple(int_<4>))) - == - tuple(0, int_<1>, '2', 3.3, int_<4>) - ); -} diff --git a/test/ext/std/tuple/monad/laws.cpp b/test/ext/std/tuple/monad/laws.cpp deleted file mode 100644 index 0247a58ed..000000000 --- a/test/ext/std/tuple/monad/laws.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include - -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x) { - return std::make_tuple(x + int_<1>); -}; - -BOOST_HANA_CONSTEXPR_LAMBDA auto g = [](auto x) { - return std::make_tuple(x * int_<3>); -}; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(Monad::laws::check(std::make_tuple(), int_<1>, f, g)); - BOOST_HANA_CONSTANT_ASSERT(Monad::laws::check(std::make_tuple(int_<1>), int_<1>, f, g)); - BOOST_HANA_CONSTANT_ASSERT(Monad::laws::check(std::make_tuple(int_<1>, int_<2>), int_<1>, f, g)); - BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check(std::make_tuple(1, 2, 3, 4), int_<1>, f, g)); -} diff --git a/test/integer_list/iterable.cpp b/test/integer_list/iterable.cpp new file mode 100644 index 000000000..3520b8160 --- /dev/null +++ b/test/integer_list/iterable.cpp @@ -0,0 +1,36 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +using namespace boost::hana; + + +int main() { + // head + { + BOOST_HANA_CONSTANT_ASSERT(head(integer_list) == int_<0>); + BOOST_HANA_CONSTANT_ASSERT(head(integer_list) == int_<0>); + BOOST_HANA_CONSTANT_ASSERT(head(integer_list) == int_<0>); + } + + // is_empty + { + BOOST_HANA_CONSTANT_ASSERT(is_empty(integer_list)); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(integer_list)); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(integer_list)); + BOOST_HANA_CONSTANT_ASSERT(!is_empty(integer_list)); + } + + // tail + { + BOOST_HANA_CONSTANT_ASSERT(tail(integer_list) == integer_list); + BOOST_HANA_CONSTANT_ASSERT(tail(integer_list) == integer_list); + BOOST_HANA_CONSTANT_ASSERT(tail(integer_list) == integer_list); + } +} diff --git a/test/integer_list/iterable/head.cpp b/test/integer_list/iterable/head.cpp deleted file mode 100644 index d3c4d9626..000000000 --- a/test/integer_list/iterable/head.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(head(integer_list) == int_<0>); - BOOST_HANA_CONSTANT_ASSERT(head(integer_list) == int_<0>); - BOOST_HANA_CONSTANT_ASSERT(head(integer_list) == int_<0>); -} diff --git a/test/integer_list/iterable/is_empty.cpp b/test/integer_list/iterable/is_empty.cpp deleted file mode 100644 index bb54bc2ef..000000000 --- a/test/integer_list/iterable/is_empty.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(is_empty(integer_list)); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(integer_list)); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(integer_list)); - BOOST_HANA_CONSTANT_ASSERT(!is_empty(integer_list)); -} diff --git a/test/integer_list/iterable/tail.cpp b/test/integer_list/iterable/tail.cpp deleted file mode 100644 index 8018201db..000000000 --- a/test/integer_list/iterable/tail.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(tail(integer_list) == integer_list); - BOOST_HANA_CONSTANT_ASSERT(tail(integer_list) == integer_list); - BOOST_HANA_CONSTANT_ASSERT(tail(integer_list) == integer_list); -} diff --git a/test/integer_list/list.cpp b/test/integer_list/list.cpp new file mode 100644 index 000000000..c3cbe9fdf --- /dev/null +++ b/test/integer_list/list.cpp @@ -0,0 +1,38 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +using namespace boost::hana; + + +template +void test() { + // cons + { + BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); + BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); + BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); + BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); + } + + // nil + { + BOOST_HANA_CONSTANT_ASSERT(nil == integer_list); + BOOST_HANA_CONSTANT_ASSERT(nil == integer_list); + BOOST_HANA_CONSTANT_ASSERT(nil == integer_list); + } +} + +int main() { + test(); + test(); + + test(); + test(); +} diff --git a/test/integer_list/list/cons.cpp b/test/integer_list/list/cons.cpp deleted file mode 100644 index 05d587b2f..000000000 --- a/test/integer_list/list/cons.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -template -void test() { - BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); - BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); - BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); - BOOST_HANA_CONSTANT_ASSERT(cons(integral, integer_list) == integer_list); -} - -int main() { - test(); - test(); - - test(); - test(); -} diff --git a/test/integer_list/list/nil.cpp b/test/integer_list/list/nil.cpp deleted file mode 100644 index b023cfee7..000000000 --- a/test/integer_list/list/nil.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(nil == integer_list); - BOOST_HANA_CONSTANT_ASSERT(nil == integer_list); - BOOST_HANA_CONSTANT_ASSERT(nil == integer_list); -} diff --git a/test/iterable/for_each.cpp b/test/iterable/for_each.cpp index 5be59bffe..322265401 100644 --- a/test/iterable/for_each.cpp +++ b/test/iterable/for_each.cpp @@ -6,9 +6,9 @@ Distributed under the Boost Software License, Version 1.0. #include +#include #include -#include #include using namespace boost::hana; @@ -22,7 +22,7 @@ void test() { for_each(iterable(xs...), [&](int x) { seen.push_back(x); }); - assert(seen == std::vector{xs...}); + BOOST_HANA_RUNTIME_ASSERT(seen == std::vector{xs...}); }; check(); check(0); diff --git a/test/lazy/monad/evaluation_order.cpp b/test/lazy/monad/evaluation_order.cpp index f135bf613..ff9e3f8da 100644 --- a/test/lazy/monad/evaluation_order.cpp +++ b/test/lazy/monad/evaluation_order.cpp @@ -6,8 +6,9 @@ Distributed under the Boost Software License, Version 1.0. #include +#include + #include -#include #include using namespace boost::hana; @@ -22,23 +23,23 @@ int main() { | [&](int dummy) { std::cerr << "executing the first computation...\n"; executed[0] = true; - assert((executed == std::array{{true, false, false}})); + BOOST_HANA_RUNTIME_ASSERT(executed == std::array{{true, false, false}}); return lazy(dummy); } | [&](int dummy) { std::cerr << "executing the second computation...\n"; executed[1] = true; - assert((executed == std::array{{true, true, false}})); + BOOST_HANA_RUNTIME_ASSERT(executed == std::array{{true, true, false}}); return lazy(dummy); } | [&](int dummy) { std::cerr << "executing the third computation...\n"; executed[2] = true; - assert((executed == std::array{{true, true, true}})); + BOOST_HANA_RUNTIME_ASSERT(executed == std::array{{true, true, true}}); return lazy(dummy); }; - assert((executed == std::array{{false, false, false}})); + BOOST_HANA_RUNTIME_ASSERT(executed == std::array{{false, false, false}}); std::cerr << "evaluating the chain...\n"; eval(chain); diff --git a/test/list/typeclass/monad.cpp b/test/list/typeclass/monad.cpp new file mode 100644 index 000000000..b301f0ffb --- /dev/null +++ b/test/list/typeclass/monad.cpp @@ -0,0 +1,61 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +using namespace boost::hana; + + +template +void test() { + BOOST_HANA_CONSTEXPR_LAMBDA auto list = detail::minimal::list; + constexpr auto x = detail::number<>; + + // flatten + { + BOOST_HANA_CONSTANT_ASSERT(flatten(list(list(), list())) == list()); + BOOST_HANA_CONSTEXPR_ASSERT(flatten(list(list(x(0)), list())) == list(x(0))); + BOOST_HANA_CONSTEXPR_ASSERT(flatten(list(list(), list(x(0)))) == list(x(0))); + BOOST_HANA_CONSTEXPR_ASSERT(flatten(list(list(x(0)), list(x(1)))) == list(x(0), x(1))); + BOOST_HANA_CONSTEXPR_ASSERT( + flatten(list(list(x(0), x(1)), list(), list(x(2), x(3)), list(x(4)))) + == + list(x(0), x(1), x(2), x(3), x(4)) + ); + } + + // laws + { + BOOST_HANA_CONSTEXPR_LAMBDA auto f = compose(list, detail::injection([]{})); + BOOST_HANA_CONSTEXPR_LAMBDA auto g = compose(list, detail::injection([]{})); + + BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check( + boost::hana::list( + list(), + list(x(0)), + list(x(0), x(1)), + list(x(0), x(1), x(2)) + ), + boost::hana::list( + x(0), x(1), x(2), x(3) + ), + boost::hana::list(f), + boost::hana::list(g) + )); + } +} + +int main() { + test>(); +} diff --git a/test/list/typeclass/monad/flatten.cpp b/test/list/typeclass/monad/flatten.cpp deleted file mode 100644 index 2fe587704..000000000 --- a/test/list/typeclass/monad/flatten.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -template -void test() { - BOOST_HANA_CONSTEXPR_LAMBDA auto list = detail::minimal::list; - - BOOST_HANA_CONSTANT_ASSERT(flatten(list(list(), list())) == list()); - BOOST_HANA_CONSTEXPR_ASSERT(flatten(list(list(x<0>), list())) == list(x<0>)); - BOOST_HANA_CONSTEXPR_ASSERT(flatten(list(list(), list(x<0>))) == list(x<0>)); - BOOST_HANA_CONSTEXPR_ASSERT(flatten(list(list(x<0>), list(x<1>))) == list(x<0>, x<1>)); - BOOST_HANA_CONSTEXPR_ASSERT( - flatten(list(list(x<0>, x<1>), list(), list(x<2>, x<3>), list(x<4>))) - == - list(x<0>, x<1>, x<2>, x<3>, x<4>) - ); -} - -int main() { - test>(); -} diff --git a/test/list/typeclass/monad/laws.cpp b/test/list/typeclass/monad/laws.cpp deleted file mode 100644 index d189c8de8..000000000 --- a/test/list/typeclass/monad/laws.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include -#include - -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -template -void test() { - BOOST_HANA_CONSTEXPR_LAMBDA auto list = detail::minimal::list; - - BOOST_HANA_CONSTEXPR_LAMBDA auto f = [=](auto x) { - return list(std::make_tuple(x)); - }; - - BOOST_HANA_CONSTEXPR_LAMBDA auto g = f; - - BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check(list(), x<0>, f, g)); - BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check(list(x<0>), x<1>, f, g)); - BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check(list(x<0>, x<1>), x<2>, f, g)); - BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check(list(x<0>, x<1>, x<2>), x<3>, f, g)); -} - -int main() { - test>(); -} diff --git a/test/maybe/applicative.cpp b/test/maybe/applicative.cpp new file mode 100644 index 000000000..bbfbab017 --- /dev/null +++ b/test/maybe/applicative.cpp @@ -0,0 +1,32 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +using namespace boost::hana; + + +BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); +constexpr auto x = detail::number<>(0); + +int main() { + // ap + { + BOOST_HANA_CONSTANT_ASSERT( equal(ap(nothing, nothing), nothing)); + BOOST_HANA_CONSTANT_ASSERT( equal(ap(just(f), nothing), nothing)); + BOOST_HANA_CONSTANT_ASSERT( equal(ap(nothing, just(x)), nothing)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(ap(just(f), just(x)), just(f(x)))); + } + + // lift + { + BOOST_HANA_CONSTEXPR_ASSERT(lift(x) == just(x)); + } +} diff --git a/test/maybe/applicative/ap.cpp b/test/maybe/applicative/ap.cpp deleted file mode 100644 index d5680e034..000000000 --- a/test/maybe/applicative/ap.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x) { - return std::make_tuple(x); -}; - -template -constexpr auto x = detail::minimal::comparable<>(i); - -int main() { - BOOST_HANA_CONSTANT_ASSERT(ap(nothing, nothing) == nothing); - BOOST_HANA_CONSTANT_ASSERT(ap(just(f), nothing) == nothing); - BOOST_HANA_CONSTANT_ASSERT(ap(nothing, just(x<0>)) == nothing); - BOOST_HANA_CONSTEXPR_ASSERT(ap(just(f), just(x<0>)) == just(f(x<0>))); -} diff --git a/test/maybe/applicative/lift.cpp b/test/maybe/applicative/lift.cpp deleted file mode 100644 index d34b420fe..000000000 --- a/test/maybe/applicative/lift.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(lift(x<0>) == just(x<0>)); -} diff --git a/test/maybe/comparable.cpp b/test/maybe/comparable.cpp new file mode 100644 index 000000000..0d7cbe95d --- /dev/null +++ b/test/maybe/comparable.cpp @@ -0,0 +1,35 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +using namespace boost::hana; + + +constexpr auto x = detail::number<>(0); +constexpr auto y = detail::number<>(1); + +int main() { + // equal + { + BOOST_HANA_CONSTANT_ASSERT( equal(nothing, nothing)); + BOOST_HANA_CONSTANT_ASSERT(!equal(nothing, just(x))); + BOOST_HANA_CONSTANT_ASSERT(!equal(just(x), nothing)); + BOOST_HANA_CONSTEXPR_ASSERT( equal(just(x), just(x))); + BOOST_HANA_CONSTEXPR_ASSERT(!equal(just(x), just(y))); + } + + // laws + { + BOOST_HANA_CONSTEXPR_ASSERT(Comparable::laws::check( + list(nothing, just(x), just(y)) + )); + } +} diff --git a/test/maybe/comparable/equal.cpp b/test/maybe/comparable/equal.cpp deleted file mode 100644 index 818bde31e..000000000 --- a/test/maybe/comparable/equal.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -int main() { - BOOST_HANA_CONSTANT_ASSERT( equal(nothing, nothing)); - BOOST_HANA_CONSTANT_ASSERT(!equal(nothing, just(x<0>))); - BOOST_HANA_CONSTANT_ASSERT(!equal(just(x<0>), nothing)); - BOOST_HANA_CONSTEXPR_ASSERT( equal(just(x<0>), just(x<0>))); - BOOST_HANA_CONSTEXPR_ASSERT(!equal(just(x<0>), just(x<1>))); -} diff --git a/test/maybe/comparable/laws.cpp b/test/maybe/comparable/laws.cpp deleted file mode 100644 index e295a9708..000000000 --- a/test/maybe/comparable/laws.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(Comparable::laws::check( - list( - nothing, - just(x<0>), - just(x<1>), - just(x<2>) - ) - )); -} diff --git a/test/maybe/foldable.cpp b/test/maybe/foldable.cpp new file mode 100644 index 000000000..11b7b0ca8 --- /dev/null +++ b/test/maybe/foldable.cpp @@ -0,0 +1,32 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +using namespace boost::hana; + + +constexpr auto x = detail::number<>(0); +constexpr auto s = detail::number<>(1); +BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + +int main() { + // foldl + { + BOOST_HANA_CONSTEXPR_ASSERT(equal(foldl(just(x), s, f), f(s, x))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(foldl(nothing, s, f), s)); + } + + // foldr + { + BOOST_HANA_CONSTEXPR_ASSERT(equal(foldr(just(x), s, f), f(x, s))); + BOOST_HANA_CONSTEXPR_ASSERT(equal(foldr(nothing, s, f), s)); + } +} diff --git a/test/maybe/foldable/foldl.cpp b/test/maybe/foldable/foldl.cpp deleted file mode 100644 index 35d821128..000000000 --- a/test/maybe/foldable/foldl.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto s, auto x) { - return std::make_tuple(s, x); -}; - -int main() { - constexpr auto s = x<999>; - BOOST_HANA_CONSTEXPR_ASSERT(foldl(just(x<0>), s, f) == f(s, x<0>)); - BOOST_HANA_CONSTEXPR_ASSERT(foldl(nothing, s, f) == s); -} diff --git a/test/maybe/foldable/foldr.cpp b/test/maybe/foldable/foldr.cpp deleted file mode 100644 index b31e4afb6..000000000 --- a/test/maybe/foldable/foldr.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include - -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x, auto s) { - return std::make_tuple(x, s); -}; - -int main() { - constexpr auto s = x<999>; - BOOST_HANA_CONSTEXPR_ASSERT(foldr(just(x<0>), s, f) == f(x<0>, s)); - BOOST_HANA_CONSTEXPR_ASSERT(foldr(nothing, s, f) == s); -} diff --git a/test/maybe/functor.cpp b/test/maybe/functor.cpp new file mode 100644 index 000000000..588a56d38 --- /dev/null +++ b/test/maybe/functor.cpp @@ -0,0 +1,37 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include +#include +using namespace boost::hana; + + +int main() { + constexpr auto x = detail::number<>; + BOOST_HANA_CONSTEXPR_LAMBDA auto f = detail::injection([]{}); + BOOST_HANA_CONSTEXPR_LAMBDA auto g = detail::injection([]{}); + + // fmap + { + BOOST_HANA_CONSTANT_ASSERT( equal(fmap(f, nothing), nothing)); + BOOST_HANA_CONSTEXPR_ASSERT(equal(fmap(f, just(x(0))), just(f(x(0))))); + } + + // laws + { + BOOST_HANA_CONSTEXPR_ASSERT(Functor::laws::check( + list(nothing, just(x(0))), + list(f), + list(g) + )); + } +} diff --git a/test/maybe/functor/fmap.cpp b/test/maybe/functor/fmap.cpp deleted file mode 100644 index 399807e78..000000000 --- a/test/maybe/functor/fmap.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x) { return x + int_<1>; }; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(fmap(f, nothing) == nothing); - BOOST_HANA_CONSTEXPR_ASSERT(fmap(f, just(1)) == just(2)); - BOOST_HANA_CONSTANT_ASSERT(fmap(f, just(int_<1>)) == just(int_<2>)); -} diff --git a/test/maybe/functor/laws.cpp b/test/maybe/functor/laws.cpp deleted file mode 100644 index 629bf80cc..000000000 --- a/test/maybe/functor/laws.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include -#include - -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x) { - return std::make_tuple(1, x); -}; - -BOOST_HANA_CONSTEXPR_LAMBDA auto g = [](auto x) { - return std::make_tuple(2, x); -}; - -int main() { - BOOST_HANA_CONSTEXPR_ASSERT(Functor::laws::check( - list(nothing, just(x<0>)), - list(f), - list(g) - )); -} diff --git a/test/maybe/monad.cpp b/test/maybe/monad.cpp new file mode 100644 index 000000000..fa8b16db5 --- /dev/null +++ b/test/maybe/monad.cpp @@ -0,0 +1,46 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +#include +#include +#include +using namespace boost::hana; + + +constexpr auto x = detail::number<>; + +int main() { + // flatten + { + BOOST_HANA_CONSTANT_ASSERT(flatten(nothing) == nothing); + BOOST_HANA_CONSTANT_ASSERT(flatten(just(nothing)) == nothing); + BOOST_HANA_CONSTEXPR_ASSERT(flatten(just(just(x(0)))) == just(x(0))); + } + + // laws + { + BOOST_HANA_CONSTEXPR_LAMBDA auto f = compose(just, detail::injection([]{})); + BOOST_HANA_CONSTEXPR_LAMBDA auto g = compose(just, detail::injection([]{})); + BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check( + list( + nothing, + just(x(0)), + just(x(1)) + ), + list( + x(0), x(1) + ), + list(f), + list(g) + )); + } +} diff --git a/test/maybe/monad/flatten.cpp b/test/maybe/monad/flatten.cpp deleted file mode 100644 index 7d579d163..000000000 --- a/test/maybe/monad/flatten.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -template -constexpr auto x = detail::minimal::comparable<>(i); - -int main() { - BOOST_HANA_CONSTANT_ASSERT(flatten(nothing) == nothing); - BOOST_HANA_CONSTANT_ASSERT(flatten(just(nothing)) == nothing); - BOOST_HANA_CONSTEXPR_ASSERT(flatten(just(just(x<0>))) == just(x<0>)); -} diff --git a/test/maybe/monad/laws.cpp b/test/maybe/monad/laws.cpp deleted file mode 100644 index 8c488926d..000000000 --- a/test/maybe/monad/laws.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include -using namespace boost::hana; - - -BOOST_HANA_CONSTEXPR_LAMBDA auto f = [](auto x) { - return just(x + int_<1>); -}; - -BOOST_HANA_CONSTEXPR_LAMBDA auto g = [](auto x) { - return just(x * int_<3>); -}; - -int main() { - BOOST_HANA_CONSTANT_ASSERT(Monad::laws::check(nothing, int_<1>, f, g)); - BOOST_HANA_CONSTANT_ASSERT(Monad::laws::check(just(int_<1>), int_<1>, f, g)); - BOOST_HANA_CONSTEXPR_ASSERT(Monad::laws::check(just(1), int_<1>, f, g)); -} diff --git a/test/range/comparable.cpp b/test/range/comparable.cpp new file mode 100644 index 000000000..40cb77d5d --- /dev/null +++ b/test/range/comparable.cpp @@ -0,0 +1,47 @@ +/* +@copyright Louis Dionne 2014 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + */ + +#include + +#include +#include +#include +#include +using namespace boost::hana; + + +int main() { + // equal + { + BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<0>), range(int_<0>, int_<0>))); + BOOST_HANA_CONSTANT_ASSERT(!equal(range(int_<0>, int_<0>), range(int_<0>, int_<1>))); + BOOST_HANA_CONSTANT_ASSERT(!equal(range(int_<0>, int_<1>), range(int_<0>, int_<0>))); + BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<1>), range(int_<0>, int_<1>))); + BOOST_HANA_CONSTANT_ASSERT(!equal(range(int_<0>, int_<2>), range(int_<0>, int_<1>))); + BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<2>), range(int_<0>, int_<2>))); + BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<0>), range(int_<2>, int_<2>))); + + BOOST_HANA_CONSTANT_ASSERT(equal(range(int_<2>, int_<4>), range(int_<2>, int_<4>))); + BOOST_HANA_CONSTANT_ASSERT(equal(range(int_<-4>, int_<-3>), range(int_<-4>, int_<-3>))); + BOOST_HANA_CONSTANT_ASSERT(equal(range(int_<-4>, int_<2>), range(int_<-4>, int_<2>))); + } + + // laws + { + BOOST_HANA_CONSTANT_ASSERT(Comparable::laws::check( + list( + range(int_<0>, int_<0>), + range(int_<1>, int_<1>), + + range(int_<0>, int_<1>), + range(long_<0>, long_<1>), + range(long_<0>, int_<1>), + + range(int_<3>, int_<6>) + ) + )); + } +} diff --git a/test/range/comparable/equal.cpp b/test/range/comparable/equal.cpp deleted file mode 100644 index e4a5f43e8..000000000 --- a/test/range/comparable/equal.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<0>), range(int_<0>, int_<0>))); - BOOST_HANA_CONSTANT_ASSERT(!equal(range(int_<0>, int_<0>), range(int_<0>, int_<1>))); - BOOST_HANA_CONSTANT_ASSERT(!equal(range(int_<0>, int_<1>), range(int_<0>, int_<0>))); - BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<1>), range(int_<0>, int_<1>))); - BOOST_HANA_CONSTANT_ASSERT(!equal(range(int_<0>, int_<2>), range(int_<0>, int_<1>))); - BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<2>), range(int_<0>, int_<2>))); - BOOST_HANA_CONSTANT_ASSERT( equal(range(int_<0>, int_<0>), range(int_<2>, int_<2>))); - - BOOST_HANA_CONSTANT_ASSERT(equal(range(int_<2>, int_<4>), range(int_<2>, int_<4>))); - BOOST_HANA_CONSTANT_ASSERT(equal(range(int_<-4>, int_<-3>), range(int_<-4>, int_<-3>))); - BOOST_HANA_CONSTANT_ASSERT(equal(range(int_<-4>, int_<2>), range(int_<-4>, int_<2>))); -} diff --git a/test/range/comparable/laws.cpp b/test/range/comparable/laws.cpp deleted file mode 100644 index 8696c838d..000000000 --- a/test/range/comparable/laws.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -@copyright Louis Dionne 2014 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) - */ - -#include - -#include -#include -#include -#include -using namespace boost::hana; - - -int main() { - BOOST_HANA_CONSTANT_ASSERT(Comparable::laws::check( - list( - range(int_<0>, int_<0>), - range(int_<1>, int_<1>), - - range(int_<0>, int_<1>), - range(long_<0>, long_<1>), - range(long_<0>, int_<1>), - - range(int_<3>, int_<6>) - ) - )); -}