// 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) #ifndef BOOST_HANA_TEST_LAWS_SEQUENCE_HPP #define BOOST_HANA_TEST_LAWS_SEQUENCE_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace hana { namespace test { template > struct TestSequence : TestSequence { using TestSequence::TestSequence; }; template struct TestSequence { template using eq = integer; template using cx_eq = integer; template using ord = integer; struct undefined { }; TestSequence() { constexpr auto list = make; (void)list; constexpr auto foldable = ::seq; (void)foldable; ////////////////////////////////////////////////////////////////// // Check for Sequence<...> ////////////////////////////////////////////////////////////////// static_assert(Sequence{}, ""); static_assert(Sequence{}, ""); static_assert(Sequence{}, ""); static_assert(Sequence{}, ""); ////////////////////////////////////////////////////////////////// // Check for basic tag consistency ////////////////////////////////////////////////////////////////// struct Random; static_assert(std::is_same, S>{}, ""); static_assert(std::is_same, S>{}, ""); static_assert(std::is_same, S>{}, ""); static_assert(std::is_same, S>{}, ""); static_assert(!std::is_same, S>{}, ""); ////////////////////////////////////////////////////////////////// // Foldable -> Sequence conversion ////////////////////////////////////////////////////////////////// { BOOST_HANA_CONSTANT_CHECK(equal( to(foldable()), list() )); BOOST_HANA_CONSTANT_CHECK(equal( to(foldable(eq<0>{})), list(eq<0>{}) )); BOOST_HANA_CONSTANT_CHECK(equal( to(foldable(eq<0>{}, eq<1>{})), list(eq<0>{}, eq<1>{}) )); BOOST_HANA_CONSTANT_CHECK(equal( to(foldable(eq<0>{}, eq<1>{}, eq<2>{})), list(eq<0>{}, eq<1>{}, eq<2>{}) )); BOOST_HANA_CONSTANT_CHECK(equal( to(foldable(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})), list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}) )); } ////////////////////////////////////////////////////////////////// // make (tautological given our definition of `list`) ////////////////////////////////////////////////////////////////// BOOST_HANA_CONSTANT_CHECK(equal( make(), list() )); BOOST_HANA_CONSTANT_CHECK(equal( make(eq<0>{}), list(eq<0>{}) )); BOOST_HANA_CONSTANT_CHECK(equal( make(eq<0>{}, eq<1>{}), list(eq<0>{}, eq<1>{}) )); BOOST_HANA_CONSTANT_CHECK(equal( make(eq<0>{}, eq<1>{}, eq<2>{}), list(eq<0>{}, eq<1>{}, eq<2>{}) )); BOOST_HANA_CONSTANT_CHECK(equal( make(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}), list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}) )); } }; }}} // end namespace boost::hana::test #endif // !BOOST_HANA_TEST_LAWS_SEQUENCE_HPP