diff options
Diffstat (limited to 'src/boost/libs/hana/test/detail')
22 files changed, 1887 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/detail/algorithm.cpp b/src/boost/libs/hana/test/detail/algorithm.cpp new file mode 100644 index 000000000..af885ceaf --- /dev/null +++ b/src/boost/libs/hana/test/detail/algorithm.cpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/algorithm.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/less.hpp> +#include <boost/hana/mult.hpp> +namespace hana = boost::hana; + + +// The algorithms are taken from the suggested implementations on cppreference. +// Hence, we assume them to be correct and we only make sure they compile, to +// avoid stupid mistakes I could have made when copy/pasting and editing. +// +// Oh, and we also make sure they can be used in a constexpr context. +constexpr bool constexpr_context() { + int x = 0, y = 1; + hana::detail::constexpr_swap(x, y); + + int array[6] = {1, 2, 3, 4, 5, 6}; + int* first = array; + int* last = array + 6; + + hana::detail::reverse(first, last); + + hana::detail::next_permutation(first, last, hana::less); + hana::detail::next_permutation(first, last); + + hana::detail::lexicographical_compare(first, last, first, last, hana::less); + hana::detail::lexicographical_compare(first, last, first, last); + + hana::detail::equal(first, last, first, last, hana::equal); + hana::detail::equal(first, last, first, last); + + hana::detail::sort(first, last, hana::equal); + hana::detail::sort(first, last); + + hana::detail::find(first, last, 3); + hana::detail::find_if(first, last, hana::equal.to(3)); + + hana::detail::iota(first, last, 0); + + hana::detail::count(first, last, 2); + + hana::detail::accumulate(first, last, 0); + hana::detail::accumulate(first, last, 1, hana::mult); + + hana::detail::min_element(first, last); + + return true; +} + +static_assert(constexpr_context(), ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/any_of.cpp b/src/boost/libs/hana/test/detail/any_of.cpp new file mode 100644 index 000000000..3d71cc29e --- /dev/null +++ b/src/boost/libs/hana/test/detail/any_of.cpp @@ -0,0 +1,45 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/any_of.hpp> +#include <boost/hana/detail/wrong.hpp> +#include <boost/hana/integral_constant.hpp> +namespace hana = boost::hana; + + +template <typename I> +struct is_even { + static constexpr bool value = I::value % 2 == 0; +}; + + +static_assert(!hana::detail::any_of<is_even>::value, ""); +static_assert(!hana::detail::any_of<is_even, hana::int_<1>>::value, ""); +static_assert(!hana::detail::any_of<is_even, hana::int_<1>, hana::int_<3>>::value, ""); +static_assert(!hana::detail::any_of<is_even, hana::int_<1>, hana::int_<3>, hana::int_<5>>::value, ""); +static_assert(!hana::detail::any_of<is_even, hana::int_<1>, hana::int_<3>, hana::int_<5>, hana::int_<7>>::value, ""); + +static_assert(hana::detail::any_of<is_even, hana::int_<0>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<0>, hana::int_<2>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<0>, hana::int_<2>, hana::int_<4>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<0>, hana::int_<2>, hana::int_<4>, hana::int_<6>>::value, ""); + +static_assert(hana::detail::any_of<is_even, hana::int_<0>, hana::int_<1>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<0>, hana::int_<1>, hana::int_<2>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<3>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<3>, hana::int_<4>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<1>, hana::int_<3>, hana::int_<5>, hana::int_<8>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<1>, hana::int_<8>, hana::int_<5>, hana::int_<7>>::value, ""); + +// Make sure we short-circuit properly +template <typename ...Dummy> +struct fail { + static_assert(hana::detail::wrong<Dummy...>::value, + "this must never be instantiated"); +}; +static_assert(hana::detail::any_of<is_even, hana::int_<1>, hana::int_<2>, fail<>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<1>, hana::int_<2>, fail<>, hana::int_<3>>::value, ""); +static_assert(hana::detail::any_of<is_even, hana::int_<1>, hana::int_<2>, fail<>, hana::int_<4>>::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp b/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp new file mode 100644 index 000000000..9dffcb526 --- /dev/null +++ b/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/canonical_constant.hpp> +#include <boost/hana/tuple.hpp> + +#include <laws/comparable.hpp> +#include <laws/constant.hpp> +#include <laws/euclidean_ring.hpp> +#include <laws/group.hpp> +#include <laws/logical.hpp> +#include <laws/monoid.hpp> +#include <laws/orderable.hpp> +#include <laws/ring.hpp> +namespace hana = boost::hana; + + +template <typename T, T v> +struct canonical { + static constexpr T value = v; + using hana_tag = hana::detail::CanonicalConstant<T>; +}; + +int main() { + auto ints = hana::make_tuple( + canonical<int, -10>{}, canonical<int, -2>{}, canonical<int, 0>{}, + canonical<int, 1>{}, canonical<int, 3>{}, canonical<int, 4>{} + ); + + auto bools = hana::make_tuple(canonical<bool, true>{}, canonical<bool, false>{}); + + // Constant + hana::test::TestConstant<hana::detail::CanonicalConstant<int>>{ints, hana::tuple_t<int, long, long long>}; + hana::test::TestConstant<hana::detail::CanonicalConstant<bool>>{bools, hana::tuple_t<bool>}; + + // Monoid, Group, Ring, EuclideanRing + hana::test::TestMonoid<hana::detail::CanonicalConstant<int>>{ints}; + hana::test::TestGroup<hana::detail::CanonicalConstant<int>>{ints}; + hana::test::TestRing<hana::detail::CanonicalConstant<int>>{ints}; + hana::test::TestEuclideanRing<hana::detail::CanonicalConstant<int>>{ints}; + + // Logical + { + auto ints = hana::make_tuple( + canonical<int, -2>{}, canonical<int, 0>{}, + canonical<int, 1>{}, canonical<int, 3>{} + ); + hana::test::TestLogical<hana::detail::CanonicalConstant<int>>{ints}; + hana::test::TestLogical<hana::detail::CanonicalConstant<bool>>{bools}; + } + + // Comparable and Orderable + hana::test::TestComparable<hana::detail::CanonicalConstant<int>>{ints}; + hana::test::TestOrderable<hana::detail::CanonicalConstant<int>>{ints}; +} diff --git a/src/boost/libs/hana/test/detail/create.cpp b/src/boost/libs/hana/test/detail/create.cpp new file mode 100644 index 000000000..e17002f10 --- /dev/null +++ b/src/boost/libs/hana/test/detail/create.cpp @@ -0,0 +1,38 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/config.hpp> +#include <boost/hana/detail/create.hpp> + +#include <utility> +#include <tuple> +namespace hana = boost::hana; + + +constexpr hana::detail::create<std::tuple> make_tuple{}; +constexpr hana::detail::create<std::pair> make_pair{}; + +template <typename ...> +struct empty { }; + +template <typename T> +struct single_holder { T x; }; + +template <typename T> +struct identity { using type = T; }; + +template <typename ...T> +using identity_t = typename identity<T...>::type; + +int main() { + static_assert(make_tuple(1, '2', 3.3) == std::make_tuple(1, '2', 3.3), ""); + static_assert(make_pair(1, '2') == std::make_pair(1, '2'), ""); + + // should work + hana::detail::create<empty>{}(); + hana::detail::create<single_holder>{}(1); + hana::detail::create<single_holder>{}([]{}); + hana::detail::create<identity_t>{}(1); + hana::detail::create<identity_t>{}([]{}); +} diff --git a/src/boost/libs/hana/test/detail/decay.cpp b/src/boost/libs/hana/test/detail/decay.cpp new file mode 100644 index 000000000..bc1ec5b60 --- /dev/null +++ b/src/boost/libs/hana/test/detail/decay.cpp @@ -0,0 +1,54 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/decay.hpp> + +#include <type_traits> +namespace hana = boost::hana; + + +template <typename T, typename Decayed> +void check() { + static_assert(std::is_same< + typename hana::detail::decay<T>::type, + Decayed + >::value, ""); +} + +int main() { + // void is untouched + check<void, void>(); + + // normal types lose cv-qualifiers + check<int, int>(); + check<int const, int>(); + check<int const volatile, int>(); + + // [cv-qualified] references are stripped + check<int&, int>(); + check<int const&, int>(); + check<int&&, int>(); + check<int const&&, int>(); + + // pointers are untouched + check<int*, int*>(); + check<int const*, int const*>(); + check<int volatile*, int volatile*>(); + check<int const volatile*, int const volatile*>(); + + // arrays decay to pointers + check<int[], int*>(); + check<int[10], int*>(); + check<int const[10], int const*>(); + check<int volatile[10], int volatile*>(); + check<int const volatile[10], int const volatile*>(); + + // functions decay to function pointers + check<void(), void(*)()>(); + check<void(...), void (*)(...)>(); + check<void(int), void(*)(int)>(); + check<void(int, ...), void(*)(int, ...)>(); + check<void(int, float), void(*)(int, float)>(); + check<void(int, float, ...), void(*)(int, float, ...)>(); +} diff --git a/src/boost/libs/hana/test/detail/ebo.cpp b/src/boost/libs/hana/test/detail/ebo.cpp new file mode 100644 index 000000000..6f174be40 --- /dev/null +++ b/src/boost/libs/hana/test/detail/ebo.cpp @@ -0,0 +1,95 @@ +// Copyright Louis Dionne 2013-2016 +// 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 <boost/hana/detail/ebo.hpp> + +#include <boost/hana/assert.hpp> + +#include <string> +#include <type_traits> +#include <utility> +namespace hana = boost::hana; +using hana::detail::ebo; + + +template <int> struct empty { }; +template <int> struct idx; +#ifdef BOOST_HANA_WORKAROUND_MSVC_EMPTYBASE +template <typename ...Bases> struct __declspec(empty_bases) inherit : Bases... { }; +#else +template <typename ...Bases> struct inherit : Bases... { }; +#endif + +static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>>), ""); +static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>, ebo<idx<1>, empty<1>>>), ""); +static_assert(sizeof(inherit<>) == sizeof(inherit<ebo<idx<0>, empty<0>>, ebo<idx<1>, empty<1>>, ebo<idx<2>, empty<2>>>), ""); + + +int main() { + // Test default-construction + { + constexpr ebo<idx<0>, int> e; + static_assert(hana::detail::ebo_get<idx<0>>(e) == 0, ""); + } + + // Test construction of a non-empty object + { + ebo<idx<0>, std::string> e{"foobar"}; + BOOST_HANA_RUNTIME_CHECK(hana::detail::ebo_get<idx<0>>(e) == "foobar"); + } + + { + ebo<idx<0>, std::string> e{}; + BOOST_HANA_RUNTIME_CHECK(hana::detail::ebo_get<idx<0>>(e) == ""); + } + + // Test construction of a non default-constructible type + { + struct nodefault { + nodefault() = delete; + explicit nodefault(char const*) { } + }; + ebo<idx<0>, nodefault> e{"foobar"}; + } + + // Get lvalue, const lvalue and rvalue with a non-empty type + { + ebo<idx<0>, std::string> e{"foobar"}; + std::string& s = hana::detail::ebo_get<idx<0>>(e); + BOOST_HANA_RUNTIME_CHECK(s == "foobar"); + s = "foobaz"; + BOOST_HANA_RUNTIME_CHECK(hana::detail::ebo_get<idx<0>>(e) == "foobaz"); + } + + { + ebo<idx<0>, std::string> const e{"foobar"}; + std::string const& s = hana::detail::ebo_get<idx<0>>(e); + BOOST_HANA_RUNTIME_CHECK(s == "foobar"); + } + + { + ebo<idx<0>, std::string> e{"foobar"}; + std::string&& s = hana::detail::ebo_get<idx<0>>(std::move(e)); + BOOST_HANA_RUNTIME_CHECK(s == "foobar"); + } + + // Get lvalue, const lvalue and rvalue with an empty type + { + ebo<idx<0>, empty<0>> e{}; + empty<0>& s = hana::detail::ebo_get<idx<0>>(e); + (void)s; + } + + { + ebo<idx<0>, empty<0>> const e{}; + empty<0> const& s = hana::detail::ebo_get<idx<0>>(e); + (void)s; + } + + { + ebo<idx<0>, empty<0>> e{}; + empty<0>&& s = hana::detail::ebo_get<idx<0>>(std::move(e)); + (void)s; + } +} diff --git a/src/boost/libs/hana/test/detail/fast_and.cpp b/src/boost/libs/hana/test/detail/fast_and.cpp new file mode 100644 index 000000000..fadb168f7 --- /dev/null +++ b/src/boost/libs/hana/test/detail/fast_and.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/fast_and.hpp> +namespace hana = boost::hana; + + +static_assert(hana::detail::fast_and<>::value, ""); +static_assert(hana::detail::fast_and<true>::value, ""); +static_assert(!hana::detail::fast_and<false>::value, ""); + +static_assert(hana::detail::fast_and<true, true>::value, ""); +static_assert(!hana::detail::fast_and<true, false>::value, ""); +static_assert(!hana::detail::fast_and<false, true>::value, ""); +static_assert(!hana::detail::fast_and<false, false>::value, ""); + +static_assert(hana::detail::fast_and<true, true, true>::value, ""); +static_assert(!hana::detail::fast_and<true, true, false>::value, ""); +static_assert(!hana::detail::fast_and<true, false, true>::value, ""); +static_assert(!hana::detail::fast_and<true, false, false>::value, ""); +static_assert(!hana::detail::fast_and<false, true, true>::value, ""); +static_assert(!hana::detail::fast_and<false, true, false>::value, ""); +static_assert(!hana::detail::fast_and<false, false, true>::value, ""); +static_assert(!hana::detail::fast_and<false, false, false>::value, ""); + +static_assert(hana::detail::fast_and<true, true, true, true, true, true>::value, ""); +static_assert(!hana::detail::fast_and<true, true, true, false, true, true>::value, ""); +static_assert(!hana::detail::fast_and<true, true, true, true, true, false>::value, ""); +static_assert(!hana::detail::fast_and<false, true, true, true, true, true>::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp b/src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp new file mode 100644 index 000000000..dd2eff55d --- /dev/null +++ b/src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp @@ -0,0 +1,47 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/first_unsatisfied_index.hpp> + +#include <boost/hana/not_equal.hpp> +#include <laws/base.hpp> + +#include <type_traits> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct poison { + poison() = default; + poison(poison const&) = delete; +}; + +int main() { + auto predicate = [](auto x) { + static_assert(!std::is_same<poison, decltype(x)>::value, ""); + return hana::not_equal(x, ct_eq<9>{}); + }; + + using Find = hana::detail::first_unsatisfied_index<decltype(predicate)>; + + static_assert(decltype(Find{}())::value == 0, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}))::value == 1, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}, poison{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}))::value == 1, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}))::value == 2, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}, poison{}, poison{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}, poison{}))::value == 1, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<9>{}))::value == 2, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}))::value == 3, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}, poison{}, poison{}, poison{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}, poison{}, poison{}))::value == 1, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<9>{}, poison{}))::value == 2, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<9>{}))::value == 3, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}))::value == 4, ""); +} diff --git a/src/boost/libs/hana/test/detail/has_duplicates.cpp b/src/boost/libs/hana/test/detail/has_duplicates.cpp new file mode 100644 index 000000000..fab5d7df6 --- /dev/null +++ b/src/boost/libs/hana/test/detail/has_duplicates.cpp @@ -0,0 +1,57 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/has_duplicates.hpp> +#include <boost/hana/integral_constant.hpp> +namespace hana = boost::hana; + + +static_assert(!hana::detail::has_duplicates<>::value, ""); + +static_assert(!hana::detail::has_duplicates< + hana::int_<0> +>::value, ""); + +static_assert(!hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1> +>::value, ""); + +static_assert(!hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<0>, hana::int_<2> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<0> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<1> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<2> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<1>, hana::int_<1> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<1>, hana::int_<2> +>::value, ""); + +// Make sure it uses deep equality +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::long_<0>, hana::int_<2>, hana::int_<3> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::long_<1> +>::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/preprocessor.cpp b/src/boost/libs/hana/test/detail/preprocessor.cpp new file mode 100644 index 000000000..0ce69549f --- /dev/null +++ b/src/boost/libs/hana/test/detail/preprocessor.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/assert.hpp> +#include <boost/hana/detail/preprocessor.hpp> + +#include <string> +#include <vector> + + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_CONCAT +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_CONCAT(1, 2) == 12, ""); + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_FRONT +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_FRONT(0) == 0, ""); +static_assert(BOOST_HANA_PP_FRONT(0, 1) == 0, ""); +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2) == 0, ""); +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2, 3) == 0, ""); + +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2, 3, 4, 5, 6, 6, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 16, 18) == 0, ""); + +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2, 3, 4, 5, 6, 6, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 16, 18, 19) == 0, ""); + + +int main() { + using Vector = std::vector<int>; + + ////////////////////////////////////////////////////////////////////////// + // BOOST_HANA_PP_STRINGIZE + ////////////////////////////////////////////////////////////////////////// + { + constexpr char const* xyz = BOOST_HANA_PP_STRINGIZE(xyz); + BOOST_HANA_RUNTIME_CHECK(std::string{xyz} == "xyz"); + }{ + constexpr char const* xyz = BOOST_HANA_PP_STRINGIZE(foo{bar, baz}); + BOOST_HANA_RUNTIME_CHECK(std::string{xyz} == "foo{bar, baz}"); + }{ + constexpr char const* xyz = BOOST_HANA_PP_STRINGIZE(foo, bar, baz); + BOOST_HANA_RUNTIME_CHECK(std::string{xyz} == "foo, bar, baz"); + } + + ////////////////////////////////////////////////////////////////////////// + // BOOST_HANA_PP_DROP_FRONT + ////////////////////////////////////////////////////////////////////////// + { + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1}); + }{ + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1, 2)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2}); + }{ + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1, 2, 3)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3}); + }{ + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1, 2, 3, 4)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3, 4}); + } +} diff --git a/src/boost/libs/hana/test/detail/struct_macros.cpp b/src/boost/libs/hana/test/detail/struct_macros.cpp new file mode 100644 index 000000000..71904ac49 --- /dev/null +++ b/src/boost/libs/hana/test/detail/struct_macros.cpp @@ -0,0 +1,108 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/assert.hpp> +#include <boost/hana/detail/struct_macros.hpp> + +#include <string> +#include <vector> + + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_NARG +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_NARG(x) == 1, ""); +static_assert(BOOST_HANA_PP_NARG(x, x) == 2, ""); +static_assert(BOOST_HANA_PP_NARG(x, x, x) == 3, ""); +static_assert(BOOST_HANA_PP_NARG(x, x, x, x) == 4, ""); +static_assert(BOOST_HANA_PP_NARG( + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x) == 38, ""); +static_assert(BOOST_HANA_PP_NARG( + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x) == 39, ""); +static_assert(BOOST_HANA_PP_NARG( + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x) == 40, ""); + + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_BACK +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_BACK(1) == 1, ""); +static_assert(BOOST_HANA_PP_BACK(1, 2) == 2, ""); +static_assert(BOOST_HANA_PP_BACK(1, 2, 3) == 3, ""); +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4) == 4, ""); + +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39) == 39, ""); + +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38) == 38, ""); + +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40) == 40, ""); + + +int main() { + using Vector = std::vector<int>; + + ////////////////////////////////////////////////////////////////////////// + // BOOST_HANA_PP_DROP_BACK + ////////////////////////////////////////////////////////////////////////// + { + Vector args = {BOOST_HANA_PP_DROP_BACK(1)}; + BOOST_HANA_RUNTIME_CHECK(args.empty()); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3, 4)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3, 4, 5)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3, 4}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39 + )}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38 + }); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 + )}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39 + }); + } +} diff --git a/src/boost/libs/hana/test/detail/type_at.cpp b/src/boost/libs/hana/test/detail/type_at.cpp new file mode 100644 index 000000000..3297a55ed --- /dev/null +++ b/src/boost/libs/hana/test/detail/type_at.cpp @@ -0,0 +1,102 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/type_at.hpp> + +#include <type_traits> +namespace hana = boost::hana; + + +template <int> +struct x; + +static_assert(std::is_same< + hana::detail::type_at<0, x<0>>::type, + x<0> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<0, x<0>, x<1>>::type, + x<0> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<0, x<0>, x<1>, x<2>>::type, + x<0> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<1, x<0>, x<1>>::type, + x<1> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<1, x<0>, x<1>, x<2>>::type, + x<1> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<1, x<0>, x<1>, x<2>, x<3>>::type, + x<1> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<2, x<0>, x<1>, x<2>>::type, + x<2> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<2, x<0>, x<1>, x<2>, x<3>>::type, + x<2> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<2, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + x<2> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<3, x<0>, x<1>, x<2>, x<3>>::type, + x<3> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<3, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + x<3> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<3, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + x<3> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<4, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + x<4> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<4, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + x<4> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<4, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + x<4> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<5, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + x<5> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<5, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + x<5> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<5, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + x<5> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<6, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + x<6> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<7, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + x<7> +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/type_foldl1.cpp b/src/boost/libs/hana/test/detail/type_foldl1.cpp new file mode 100644 index 000000000..47c58572f --- /dev/null +++ b/src/boost/libs/hana/test/detail/type_foldl1.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/type_foldl1.hpp> + +#include <type_traits> +namespace hana = boost::hana; + + +template <typename state, typename x> +struct f { + struct type; +}; + +template <int> +struct x; + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>>::type, + x<0> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>>::type, + f<x<0>, x<1>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>, x<2>>::type, + f<f<x<0>, x<1>>::type, x<2>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>, x<2>, x<3>>::type, + f<f<f<x<0>, x<1>>::type, x<2>>::type, x<3>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + f<f<f<f<x<0>, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + f<f<f<f<f<x<0>, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + f<f<f<f<f<f<x<0>, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type, x<6>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + f<f<f<f<f<f<f<x<0>, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type, x<6>>::type, x<7>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>>::type, + f<f<f<f<f<f<f<f<x<0>, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type, x<6>>::type, x<7>>::type, x<8>>::type +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/type_foldr1.cpp b/src/boost/libs/hana/test/detail/type_foldr1.cpp new file mode 100644 index 000000000..eefa6a99f --- /dev/null +++ b/src/boost/libs/hana/test/detail/type_foldr1.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/type_foldr1.hpp> + +#include <type_traits> +namespace hana = boost::hana; + + +template <typename x, typename state> +struct f { + struct type; +}; + +template <int> +struct x; + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>>::type, + x<0> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>>::type, + f<x<0>, x<1>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>, x<2>>::type, + f<x<0>, f<x<1>, x<2>>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>, x<2>, x<3>>::type, + f<x<0>, f<x<1>, f<x<2>, x<3>>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + f<x<0>, f<x<1>, f<x<2>, f<x<3>, x<4>>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + f<x<0>, f<x<1>, f<x<2>, f<x<3>, f<x<4>, x<5>>::type>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + f<x<0>, f<x<1>, f<x<2>, f<x<3>, f<x<4>, f<x<5>, x<6>>::type>::type>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + f<x<0>, f<x<1>, f<x<2>, f<x<3>, f<x<4>, f<x<5>, f<x<6>, x<7>>::type>::type>::type>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1<f, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>>::type, + f<x<0>, f<x<1>, f<x<2>, f<x<3>, f<x<4>, f<x<5>, f<x<6>, f<x<7>, x<8>>::type>::type>::type>::type>::type>::type>::type>::type +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/unpack_flatten.cpp b/src/boost/libs/hana/test/detail/unpack_flatten.cpp new file mode 100644 index 000000000..d6002c964 --- /dev/null +++ b/src/boost/libs/hana/test/detail/unpack_flatten.cpp @@ -0,0 +1,114 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/assert.hpp> +#include <boost/hana/detail/unpack_flatten.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/tuple.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + constexpr auto f = hana::test::_injection<0>{}; + + { + auto tuples = hana::make_tuple(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple()); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), hana::make_tuple()); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), + hana::make_tuple(), + hana::make_tuple()); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), + hana::make_tuple(ct_eq<0>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), + hana::make_tuple(ct_eq<0>{}, ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}, ct_eq<3>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } +} diff --git a/src/boost/libs/hana/test/detail/variadic/at.cpp b/src/boost/libs/hana/test/detail/variadic/at.cpp new file mode 100644 index 000000000..ddb4bddc4 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/at.cpp @@ -0,0 +1,93 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/variadic/at.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +struct non_pod { virtual ~non_pod() { } }; + +template <int i> struct y { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, ct_eq<1>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}), + ct_eq<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}), + ct_eq<2>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}, y<3>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}, y<3>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}, y<3>{}), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<3>(y<0>{}, y<1>{}, y<2>{}, ct_eq<3>{}), + ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}, y<3>{}, y<4>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}, y<3>{}, y<4>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}, y<3>{}, y<4>{}), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<3>(y<0>{}, y<1>{}, y<2>{}, ct_eq<3>{}, y<4>{}), + ct_eq<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<4>(y<0>{}, y<1>{}, y<2>{}, y<3>{}, ct_eq<4>{}), + ct_eq<4>{} + )); + + // make sure we can use non-pods on both side of the fetched object + vd::at<0>(ct_eq<0>{}, non_pod{}); + vd::at<1>(non_pod{}, ct_eq<1>{}); + + // make sure it works with const objects + int const i = 1; + vd::at<0>(i); +} diff --git a/src/boost/libs/hana/test/detail/variadic/drop_into.cpp b/src/boost/libs/hana/test/detail/variadic/drop_into.cpp new file mode 100644 index 000000000..8c4aecb5d --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/drop_into.cpp @@ -0,0 +1,78 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/variadic/drop_into.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +struct non_pod { virtual ~non_pod() { } }; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(ct_eq<0>{}), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + f(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + + // make sure we can use non-pods + vd::drop_into<1>(f)(ct_eq<0>{}, non_pod{}); + vd::drop_into<1>(f)(non_pod{}, ct_eq<1>{}); +} diff --git a/src/boost/libs/hana/test/detail/variadic/foldl1.cpp b/src/boost/libs/hana/test/detail/variadic/foldl1.cpp new file mode 100644 index 000000000..e0ded2c88 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/foldl1.cpp @@ -0,0 +1,212 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/variadic/foldl1.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; + + +struct undefined { }; + +template <int i> +using x = hana::test::ct_eq<i>; + +int main() { + using hana::detail::variadic::foldl1; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(undefined{}, x<1>{}), + x<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}), + f(x<1>{}, x<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}), + f(f(x<1>{}, x<2>{}), x<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}), + f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), + f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}), + f(f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}), + f(f(f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, x<8>{}), + f(f(f(f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), x<8>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{} + ), + f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}), x<30>{}), x<31>{}), x<32>{}), x<33>{}), x<34>{}), x<35>{}), + x<36>{}), x<37>{}), x<38>{}), x<39>{}), x<40>{}), x<41>{}), x<42>{}), + x<43>{}), x<44>{}), x<45>{}), x<46>{}), x<47>{}), x<48>{}), x<49>{}), + x<50>{}), x<51>{}), x<52>{}), x<53>{}), x<54>{}), x<55>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}), x<30>{}), x<31>{}), x<32>{}), x<33>{}), x<34>{}), x<35>{}), + x<36>{}), x<37>{}), x<38>{}), x<39>{}), x<40>{}), x<41>{}), x<42>{}), + x<43>{}), x<44>{}), x<45>{}), x<46>{}), x<47>{}), x<48>{}), x<49>{}), + x<50>{}), x<51>{}), x<52>{}), x<53>{}), x<54>{}), x<55>{}), x<56>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}, + x<57>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}), x<30>{}), x<31>{}), x<32>{}), x<33>{}), x<34>{}), x<35>{}), + x<36>{}), x<37>{}), x<38>{}), x<39>{}), x<40>{}), x<41>{}), x<42>{}), + x<43>{}), x<44>{}), x<45>{}), x<46>{}), x<47>{}), x<48>{}), x<49>{}), + x<50>{}), x<51>{}), x<52>{}), x<53>{}), x<54>{}), x<55>{}), x<56>{}), + x<57>{}) + )); +} diff --git a/src/boost/libs/hana/test/detail/variadic/foldr1.cpp b/src/boost/libs/hana/test/detail/variadic/foldr1.cpp new file mode 100644 index 000000000..1d7d91ed6 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/foldr1.cpp @@ -0,0 +1,207 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/variadic/foldr1.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/value.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; + + +struct undefined { }; + +template <int i> +using x = hana::test::ct_eq<i>; + +// We do not use test::_injection here because comparing the result would +// blow away the template recursion limit. +struct f_t { + template <typename X, typename Y> + constexpr auto operator()(X const&, Y const&) { + return x<hana::value<X>() - hana::value<Y>()>{}; + } +}; + +int main() { + using hana::detail::variadic::foldr1; + f_t f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(undefined{}, x<0>{}), + x<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}), + f(x<0>{}, x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}), + f(x<0>{}, f(x<1>{}, x<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, x<3>{}))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, x<4>{})))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, x<5>{}))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, x<6>{})))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, x<7>{} + ))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, x<8>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, x<8>{} + )))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, x<13>{} + )))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, x<14>{} + ))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, x<15>{} + )))))))))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, x<27>{} + )))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, x<28>{} + ))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + x<29>{} + )))))))))))))))))))))))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, x<55>{} + )))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, f(x<55>{}, x<56>{} + ))))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}, + x<57>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, f(x<55>{}, f(x<56>{}, + x<57>{} + )))))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); +} diff --git a/src/boost/libs/hana/test/detail/variadic/reverse_apply.cpp b/src/boost/libs/hana/test/detail/variadic/reverse_apply.cpp new file mode 100644 index 000000000..60305f3a7 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/reverse_apply.cpp @@ -0,0 +1,70 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/variadic/reverse_apply.hpp> +#include <boost/hana/detail/variadic/reverse_apply/flat.hpp> +#include <boost/hana/detail/variadic/reverse_apply/unrolled.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +auto check = [](auto reverse_apply) { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + f(ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}), + f(ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}), + f(ct_eq<6>{}, ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + f(ct_eq<7>{}, ct_eq<6>{}, ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + f(ct_eq<8>{}, ct_eq<7>{}, ct_eq<6>{}, ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); +}; + +int main() { + check(hana::detail::variadic::reverse_apply); + check([](auto f, auto ...x) { + return hana::detail::variadic::reverse_apply_flat(f, x...); + }); + check([](auto f, auto ...x) { + return hana::detail::variadic::reverse_apply_unrolled(f, x...); + }); +} diff --git a/src/boost/libs/hana/test/detail/variadic/split_at.cpp b/src/boost/libs/hana/test/detail/variadic/split_at.cpp new file mode 100644 index 000000000..e33872a5b --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/split_at.cpp @@ -0,0 +1,168 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/variadic/split_at.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/tuple.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +auto check = [](auto split, auto xs, auto ys) { + auto result = split([](auto ...xs) { + return [=](auto ...ys) { + return hana::make_pair(hana::make_tuple(xs...), hana::make_tuple(ys...)); + }; + }); + + BOOST_HANA_CONSTANT_CHECK(hana::equal(xs, hana::first(result))); + BOOST_HANA_CONSTANT_CHECK(hana::equal(ys, hana::second(result))); +}; + +int main() { + { + check( + vd::split_at<0>(), + hana::make_tuple(), + hana::make_tuple() + ); + + check( + vd::split_at<0>(ct_eq<1>{}), + hana::make_tuple(), + hana::make_tuple(ct_eq<1>{}) + ); + + check( + vd::split_at<0>(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}) + ); + + check( + vd::split_at<0>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_tuple(), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + ); + } + { + check( + vd::split_at<1>(ct_eq<1>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple() + ); + + check( + vd::split_at<1>(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}) + ); + + check( + vd::split_at<1>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}, ct_eq<3>{}) + ); + + check( + vd::split_at<1>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + ); + } + { + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple() + ); + + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}) + ); + + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}) + ); + + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + ); + } + { + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple() + ); + + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<8>{}) + ); + + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<8>{}, ct_eq<9>{}) + ); + + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}) + ); + } + { + check( + vd::split_at<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple() + ); + + check( + vd::split_at<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<9>{}) + ); + + check( + vd::split_at<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<9>{}, ct_eq<10>{}) + ); + } + { + check( + vd::split_at<9>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple() + ); + + check( + vd::split_at<9>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<10>{}) + ); + + check( + vd::split_at<9>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}, ct_eq<11>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<10>{}, ct_eq<11>{}) + ); + } +} diff --git a/src/boost/libs/hana/test/detail/variadic/take.cpp b/src/boost/libs/hana/test/detail/variadic/take.cpp new file mode 100644 index 000000000..031c6baea --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/take.cpp @@ -0,0 +1,62 @@ +// Copyright Louis Dionne 2013-2017 +// 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 <boost/hana/detail/variadic/take.hpp> + +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<0>()(f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<0>(ct_eq<1>{})(f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<0>(ct_eq<1>{}, ct_eq<2>{})(f), + f() + )); + } + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<1>(ct_eq<1>{})(f), + f(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<1>(ct_eq<1>{}, ct_eq<2>{})(f), + f(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<1>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})(f), + f(ct_eq<1>{}) + )); + } + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{})(f), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{})(f), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}) + )); + } +} |