diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/hana/test/experimental | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/hana/test/experimental')
41 files changed, 2304 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/experimental/printable/map.cpp b/src/boost/libs/hana/test/experimental/printable/map.cpp new file mode 100644 index 000000000..ad9bb5753 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/map.cpp @@ -0,0 +1,51 @@ +// 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/experimental/printable.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> + +#include <sstream> +#include <string> +namespace hana = boost::hana; + + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_map() + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{}"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_map(hana::make_pair(hana::int_c<1>, 'x')) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1 => x}"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_map(hana::make_pair(hana::int_c<1>, 'x'), + hana::make_pair(hana::int_c<2>, 'y')) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1 => x, 2 => y}"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_map(hana::make_pair(hana::int_c<1>, 'x'), + hana::make_pair(hana::int_c<2>, 'y'), + hana::make_pair(hana::int_c<3>, 'z')) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1 => x, 2 => y, 3 => z}"); + } +} diff --git a/src/boost/libs/hana/test/experimental/printable/metafunction.cpp b/src/boost/libs/hana/test/experimental/printable/metafunction.cpp new file mode 100644 index 000000000..5cfdb6a62 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/metafunction.cpp @@ -0,0 +1,45 @@ +// Copyright Jason Rice 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/assert.hpp> +#include <boost/hana/experimental/printable.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/type.hpp> + +#include <regex> +#include <sstream> +namespace hana = boost::hana; + +namespace foo { + template <typename T> struct my_template { }; + template <typename ...> struct my_mf { struct type; }; + struct my_mf_class { template <typename ...> struct apply { struct type; }; }; +} + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::template_<foo::my_template> + ); + BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(), + std::regex("template<(?:struct )?foo::my_template>"))); + } + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::metafunction<foo::my_mf> + ); + BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(), + std::regex("metafunction<(?:struct )?foo::my_mf>"))); + } + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::metafunction_class<foo::my_mf_class> + ); + BOOST_HANA_RUNTIME_CHECK(std::regex_match(ss.str(), + std::regex("metafunction_class<(?:struct )?foo::my_mf_class>"))); + } +} diff --git a/src/boost/libs/hana/test/experimental/printable/optional.cpp b/src/boost/libs/hana/test/experimental/printable/optional.cpp new file mode 100644 index 000000000..c963204c2 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/optional.cpp @@ -0,0 +1,29 @@ +// Copyright Jason Rice 2015 +// 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/experimental/printable.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/optional.hpp> + +#include <sstream> +namespace hana = boost::hana; + + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::just(hana::int_c<5>) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "just(5)"); + } + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::nothing + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "nothing"); + } +} diff --git a/src/boost/libs/hana/test/experimental/printable/pair.cpp b/src/boost/libs/hana/test/experimental/printable/pair.cpp new file mode 100644 index 000000000..4d592fb3f --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/pair.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/assert.hpp> +#include <boost/hana/experimental/printable.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/pair.hpp> + +#include <sstream> +namespace hana = boost::hana; + + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_pair(1, hana::int_c<1>) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 1)"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_pair(1, hana::int_c<2>) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2)"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_pair('x', hana::int_c<2>) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(x, 2)"); + } +} diff --git a/src/boost/libs/hana/test/experimental/printable/set.cpp b/src/boost/libs/hana/test/experimental/printable/set.cpp new file mode 100644 index 000000000..7a9399446 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/set.cpp @@ -0,0 +1,48 @@ +// 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/experimental/printable.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/set.hpp> +#include <boost/hana/string.hpp> + +#include <sstream> +#include <string> +namespace hana = boost::hana; + + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_set() + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{}"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_set(hana::int_c<1>) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1}"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_set(hana::int_c<1>, BOOST_HANA_STRING("3456")) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{1, \"3456\"}"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::make_set(hana::char_c<'x'>, BOOST_HANA_STRING("3456")) + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "{x, \"3456\"}"); + } +} diff --git a/src/boost/libs/hana/test/experimental/printable/string.cpp b/src/boost/libs/hana/test/experimental/printable/string.cpp new file mode 100644 index 000000000..419e06ad2 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/string.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/assert.hpp> +#include <boost/hana/experimental/printable.hpp> +#include <boost/hana/string.hpp> + +#include <sstream> +namespace hana = boost::hana; + + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print( + BOOST_HANA_STRING("") + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"\""); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + BOOST_HANA_STRING("x") + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"x\""); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + BOOST_HANA_STRING("xy") + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"xy\""); + } + + { + std::ostringstream ss; + ss << hana::experimental::print( + BOOST_HANA_STRING("xyz") + ); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "\"xyz\""); + } +} diff --git a/src/boost/libs/hana/test/experimental/printable/tuple.cpp b/src/boost/libs/hana/test/experimental/printable/tuple.cpp new file mode 100644 index 000000000..db53626bd --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/tuple.cpp @@ -0,0 +1,50 @@ +// 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/experimental/printable.hpp> +#include <boost/hana/tuple.hpp> + +#include <sstream> +#include <string> +namespace hana = boost::hana; + + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print(hana::make_tuple()); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "()"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print(hana::make_tuple(1)); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1)"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print(hana::make_tuple(1, 2)); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2)"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print(hana::make_tuple(1, '2', "3456")); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, 3456)"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print(hana::make_tuple(1, '2', hana::make_tuple())); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, ())"); + } + + { + std::ostringstream ss; + ss << hana::experimental::print(hana::make_tuple(1, '2', hana::make_tuple(3.3, '4'))); + BOOST_HANA_RUNTIME_CHECK(ss.str() == "(1, 2, (3.3, 4))"); + } +} diff --git a/src/boost/libs/hana/test/experimental/printable/type.cpp b/src/boost/libs/hana/test/experimental/printable/type.cpp new file mode 100644 index 000000000..718cdc0c1 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/printable/type.cpp @@ -0,0 +1,35 @@ +// 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/experimental/printable.hpp> +#include <boost/hana/type.hpp> + +#include <iostream> +namespace hana = boost::hana; + + +template <typename ...T> +struct Template { }; + +int main() { + // Since demangling may not always be available, and since that's not + // our job to test this (but Boost.Core's job), we don't test the + // actual demangling of types. We merely print a type to make sure + // things don't blow up stupidly, but we can't really test more than + // that. + + std::cout << hana::experimental::print(hana::type_c<void>) << std::endl; + + std::cout << hana::experimental::print(hana::type_c<int>) << std::endl; + + std::cout << hana::experimental::print(hana::type_c<int const>) << std::endl; + + std::cout << hana::experimental::print(hana::type_c<int&>) << std::endl; + + std::cout << hana::experimental::print(hana::type_c<int const&>) << std::endl; + + std::cout << hana::experimental::print(hana::type_c<int(&)[]>) << std::endl; + + std::cout << hana::experimental::print(hana::type_c<Template<void, char const*>>) << std::endl; +} diff --git a/src/boost/libs/hana/test/experimental/type_name.cpp b/src/boost/libs/hana/test/experimental/type_name.cpp new file mode 100644 index 000000000..6144dc719 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/type_name.cpp @@ -0,0 +1,50 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/type_name.hpp> +#include <boost/hana/string.hpp> + +#include <cstdlib> +#include <iostream> +#include <regex> +#include <string> +namespace hana = boost::hana; + + +template <typename ...T> +struct Template { }; + +template <typename T> +void check_matches(std::string const& re) { + std::string name = hana::to<char const*>(hana::experimental::type_name<T>()); + std::regex regex{re}; + if (!std::regex_match(name, regex)) { + std::cerr << "type name '" << name << "' does not match regex '" << re << "'" << std::endl; + std::abort(); + } +} + +int main() { + // Make sure this can be obtained at compile-time + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::experimental::type_name<void>(), + BOOST_HANA_STRING("void") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::experimental::type_name<int>(), + BOOST_HANA_STRING("int") + )); + + // Make sure we get something reasonable + check_matches<int const>("int const|const int"); + check_matches<int&>(R"(int\s*&)"); + check_matches<int const&>(R"(const\s+int\s*&|int\s+const\s*&)"); + check_matches<int(&)[]>(R"(int\s*\(\s*&\s*\)\s*\[\s*\])"); + check_matches<int(&)[10]>(R"(int\s*\(\s*&\s*\)\s*\[\s*10\s*\])"); + check_matches<Template<void, char const*>>(R"(Template<\s*void\s*,\s*(char const|const char)\s*\*\s*>)"); + check_matches<void(*)(int)>(R"(void\s*\(\s*\*\s*\)\s*\(\s*int\s*\))"); +} diff --git a/src/boost/libs/hana/test/experimental/types/at.cpp b/src/boost/libs/hana/test/experimental/types/at.cpp new file mode 100644 index 000000000..f5fe8f666 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/at.cpp @@ -0,0 +1,80 @@ +// 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/at.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +template <int> struct x; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types<x<0>>{}), + hana::type_c<x<0>> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types<x<0>, x<1>>{}), + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types<x<0>, x<1>>{}), + hana::type_c<x<1>> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types<x<0>, x<1>, x<2>>{}), + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types<x<0>, x<1>, x<2>>{}), + hana::type_c<x<1>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(hana::experimental::types<x<0>, x<1>, x<2>>{}), + hana::type_c<x<2>> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}), + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}), + hana::type_c<x<1>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}), + hana::type_c<x<2>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<3>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}), + hana::type_c<x<3>> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c<x<1>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c<x<2>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<3>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c<x<3>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<4>(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c<x<4>> + )); +} diff --git a/src/boost/libs/hana/test/experimental/types/contains.cpp b/src/boost/libs/hana/test/experimental/types/contains.cpp new file mode 100644 index 000000000..d9d5197dc --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/contains.cpp @@ -0,0 +1,81 @@ +// 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/contains.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/not.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +template <int> struct x; +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types<>{}, + undefined{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>>{}, + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types<x<0>>{}, + hana::type_c<x<999>> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>>{}, + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>>{}, + hana::type_c<x<1>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types<x<0>, x<1>>{}, + hana::type_c<x<999>> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::type_c<x<1>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::type_c<x<2>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::type_c<x<999>> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, + hana::type_c<x<0>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, + hana::type_c<x<1>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, + hana::type_c<x<2>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, + hana::type_c<x<3>> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, + hana::type_c<x<999>> + ))); +} diff --git a/src/boost/libs/hana/test/experimental/types/drop_front.cpp b/src/boost/libs/hana/test/experimental/types/drop_front.cpp new file mode 100644 index 000000000..3277af409 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/drop_front.cpp @@ -0,0 +1,100 @@ +// 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/drop_front.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/integral_constant.hpp> +namespace hana = boost::hana; + + +template <int> struct x; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<>{}, hana::size_c<0>), + hana::experimental::types<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<>{}, hana::size_c<1>), + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>>{}, hana::size_c<0>), + hana::experimental::types<x<0>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>>{}, hana::size_c<1>), + hana::experimental::types<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>>{}, hana::size_c<2>), + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>>{}, hana::size_c<0>), + hana::experimental::types<x<0>, x<1>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>>{}, hana::size_c<1>), + hana::experimental::types<x<1>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>>{}, hana::size_c<2>), + hana::experimental::types<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>>{}, hana::size_c<3>), + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::size_c<0>), + hana::experimental::types<x<0>, x<1>, x<2>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::size_c<1>), + hana::experimental::types<x<1>, x<2>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::size_c<2>), + hana::experimental::types<x<2>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::size_c<3>), + hana::experimental::types<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::size_c<4>), + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::size_c<0>), + hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::size_c<1>), + hana::experimental::types<x<1>, x<2>, x<3>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::size_c<2>), + hana::experimental::types<x<2>, x<3>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::size_c<3>), + hana::experimental::types<x<3>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::size_c<4>), + hana::experimental::types<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::size_c<5>), + hana::experimental::types<>{} + )); +} diff --git a/src/boost/libs/hana/test/experimental/types/equal.cpp b/src/boost/libs/hana/test/experimental/types/equal.cpp new file mode 100644 index 000000000..a44b2dbf3 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/equal.cpp @@ -0,0 +1,59 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/not.hpp> +namespace hana = boost::hana; + + +template <int> struct x; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::experimental::types<>{}, + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::experimental::types<x<0>>{}, + hana::experimental::types<x<0>>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::experimental::types<x<0>, x<1>, x<2>>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types<>{}, + hana::experimental::types<x<0>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types<x<0>>{}, + hana::experimental::types<>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types<x<0>>{}, + hana::experimental::types<x<1>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::experimental::types<x<0>, x<1>, x<3>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::experimental::types<x<0>, x<1>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types<x<0>, x<1>, x<2>>{}, + hana::experimental::types<x<0>, x<9>, x<2>>{} + ))); +} diff --git a/src/boost/libs/hana/test/experimental/types/is_empty.cpp b/src/boost/libs/hana/test/experimental/types/is_empty.cpp new file mode 100644 index 000000000..f90c01549 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/is_empty.cpp @@ -0,0 +1,34 @@ +// 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/experimental/types.hpp> +#include <boost/hana/is_empty.hpp> +#include <boost/hana/not.hpp> +namespace hana = boost::hana; + + +template <int> struct x; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty( + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::experimental::types<x<0>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::experimental::types<x<0>, x<1>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::experimental::types<x<0>, x<1>, x<2>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{} + ))); +} diff --git a/src/boost/libs/hana/test/experimental/types/transform.cpp b/src/boost/libs/hana/test/experimental/types/transform.cpp new file mode 100644 index 000000000..0ed1b07c7 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/transform.cpp @@ -0,0 +1,74 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/transform.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +template <typename ...> +struct mf { struct type; }; + +template <int> struct x; +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<>{}, undefined{}), + hana::experimental::types<>{} + )); + + // with a Metafunction + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>>{}, hana::metafunction<mf>), + hana::experimental::types<mf<x<0>>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>, x<1>>{}, hana::metafunction<mf>), + hana::experimental::types<mf<x<0>>::type, mf<x<1>>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::metafunction<mf>), + hana::experimental::types<mf<x<0>>::type, mf<x<1>>::type, mf<x<2>>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::metafunction<mf>), + hana::experimental::types<mf<x<0>>::type, mf<x<1>>::type, mf<x<2>>::type, mf<x<3>>::type>{} + )); + } + + // with a non-Metafunction + { + auto f = [](auto t) { + return hana::metafunction<mf>(t); + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>>{}, f), + hana::experimental::types<mf<x<0>>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>, x<1>>{}, f), + hana::experimental::types<mf<x<0>>::type, mf<x<1>>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>, x<1>, x<2>>{}, f), + hana::experimental::types<mf<x<0>>::type, mf<x<1>>::type, mf<x<2>>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, f), + hana::experimental::types<mf<x<0>>::type, mf<x<1>>::type, mf<x<2>>::type, mf<x<3>>::type>{} + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/types/unpack.cpp b/src/boost/libs/hana/test/experimental/types/unpack.cpp new file mode 100644 index 000000000..96116b403 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/types/unpack.cpp @@ -0,0 +1,83 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/type.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; + + +template <typename ...> +struct mf { struct type; }; + +template <int> struct x; + +int main() { + // with a Metafunction + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<>{}, hana::metafunction<mf>), + hana::type_c<mf<>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>, x<2>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>, x<2>, x<3>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>, x<4>>{}, hana::metafunction<mf>), + hana::type_c<mf<x<0>, x<1>, x<2>, x<3>, x<4>>::type> + )); + } + + // with a non-Metafunction + { + auto f = hana::test::_injection<0>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<>{}, f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>>{}, f), + f(hana::type_c<x<0>>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>>{}, f), + f(hana::type_c<x<0>>, hana::type_c<x<1>>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>>{}, f), + f(hana::type_c<x<0>>, hana::type_c<x<1>>, hana::type_c<x<2>>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<x<0>, x<1>, x<2>, x<3>>{}, f), + f(hana::type_c<x<0>>, hana::type_c<x<1>>, hana::type_c<x<2>>, hana::type_c<x<3>>) + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/empty/is_empty.cpp b/src/boost/libs/hana/test/experimental/view/empty/is_empty.cpp new file mode 100644 index 000000000..c3efb7e25 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/empty/is_empty.cpp @@ -0,0 +1,16 @@ +// 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/experimental/view.hpp> +#include <boost/hana/is_empty.hpp> +namespace hana = boost::hana; + + +int main() { + { + auto empty = hana::experimental::empty_view(); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(empty)); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/empty/length.cpp b/src/boost/libs/hana/test/experimental/view/empty/length.cpp new file mode 100644 index 000000000..3325ec9c7 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/empty/length.cpp @@ -0,0 +1,21 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/length.hpp> +namespace hana = boost::hana; + + +int main() { + { + auto empty = hana::experimental::empty_view(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(empty), + hana::size_c<0> + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/empty/unpack.cpp b/src/boost/libs/hana/test/experimental/view/empty/unpack.cpp new file mode 100644 index 000000000..6942e35af --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/empty/unpack.cpp @@ -0,0 +1,24 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; + + +int main() { + auto f = hana::test::_injection<0>{}; + + { + auto empty = hana::experimental::empty_view(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(empty, f), + f() + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/joined/at.cpp b/src/boost/libs/hana/test/experimental/view/joined/at.cpp new file mode 100644 index 000000000..ec4e00170 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/joined/at.cpp @@ -0,0 +1,97 @@ +// 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/at.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<0>), + ct_eq<0>{} + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<0>), + ct_eq<0>{} + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<1>), + ct_eq<1>{} + )); + }{ + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(ct_eq<1>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<1>), + ct_eq<1>{} + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<1>), + ct_eq<1>{} + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<1>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<2>), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(joined, hana::size_c<3>), + ct_eq<3>{} + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/joined/is_empty.cpp b/src/boost/libs/hana/test/experimental/view/joined/is_empty.cpp new file mode 100644 index 000000000..b8a5e0ae5 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/joined/is_empty.cpp @@ -0,0 +1,43 @@ +// 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/experimental/view.hpp> +#include <boost/hana/is_empty.hpp> +#include <boost/hana/not.hpp> + +#include <support/seq.hpp> +namespace hana = boost::hana; + + +template <int> struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto storage1 = container(); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(joined)); + } + { + auto storage1 = container(undefined<0>{}); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined))); + } + { + auto storage1 = container(undefined<0>{}); + auto storage2 = container(undefined<1>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined))); + } + { + auto storage1 = container(); + auto storage2 = container(undefined<0>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(joined))); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/joined/length.cpp b/src/boost/libs/hana/test/experimental/view/joined/length.cpp new file mode 100644 index 000000000..457d5f626 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/joined/length.cpp @@ -0,0 +1,89 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/length.hpp> + +#include <support/seq.hpp> +namespace hana = boost::hana; + + +template <int> struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto storage1 = container(); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(joined), + hana::size_c<0> + )); + } + + { + auto storage1 = container(undefined<0>{}); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(joined), + hana::size_c<1> + )); + } + + { + auto storage1 = container(); + auto storage2 = container(undefined<0>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(joined), + hana::size_c<1> + )); + } + + { + auto storage1 = container(undefined<0>{}); + auto storage2 = container(undefined<1>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(joined), + hana::size_c<2> + )); + } + + { + auto storage1 = container(undefined<0>{}); + auto storage2 = container(undefined<1>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(joined), + hana::size_c<2> + )); + } + + { + auto storage1 = container(undefined<0>{}, undefined<1>{}); + auto storage2 = container(undefined<2>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(joined), + hana::size_c<3> + )); + } + + { + auto storage1 = container(undefined<0>{}, undefined<1>{}, undefined<2>{}); + auto storage2 = container(undefined<3>{}, undefined<4>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(joined), + hana::size_c<5> + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/joined/unpack.cpp b/src/boost/libs/hana/test/experimental/view/joined/unpack.cpp new file mode 100644 index 000000000..cf0896d8f --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/joined/unpack.cpp @@ -0,0 +1,81 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + auto f = hana::test::_injection<0>{}; + + { + auto storage1 = container(); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(joined, f), + f() + )); + } + + { + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(joined, f), + f(ct_eq<0>{}) + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(joined, f), + f(ct_eq<0>{}) + )); + }{ + auto storage1 = container(ct_eq<0>{}); + auto storage2 = container(ct_eq<1>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(joined, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(joined, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + }{ + auto storage1 = container(); + auto storage2 = container(ct_eq<0>{}, ct_eq<1>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(joined, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + }{ + auto storage1 = container(ct_eq<0>{}, ct_eq<1>{}); + auto storage2 = container(ct_eq<2>{}, ct_eq<3>{}); + auto joined = hana::experimental::joined(storage1, storage2); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(joined, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/single/at.cpp b/src/boost/libs/hana/test/experimental/view/single/at.cpp new file mode 100644 index 000000000..20d1490be --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/single/at.cpp @@ -0,0 +1,24 @@ +// 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/at.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + { + auto single = hana::experimental::single_view(ct_eq<0>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(single, hana::size_c<0>), + ct_eq<0>{} + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/single/is_empty.cpp b/src/boost/libs/hana/test/experimental/view/single/is_empty.cpp new file mode 100644 index 000000000..4422b3e40 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/single/is_empty.cpp @@ -0,0 +1,19 @@ +// 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/experimental/view.hpp> +#include <boost/hana/is_empty.hpp> +#include <boost/hana/not.hpp> +namespace hana = boost::hana; + + +template <int> struct undefined { }; + +int main() { + { + auto single = hana::experimental::single_view(undefined<0>{}); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(single))); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/single/length.cpp b/src/boost/libs/hana/test/experimental/view/single/length.cpp new file mode 100644 index 000000000..8153f8199 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/single/length.cpp @@ -0,0 +1,23 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/length.hpp> +namespace hana = boost::hana; + + +template <int> struct undefined { }; + +int main() { + { + auto single = hana::experimental::single_view(undefined<0>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(single), + hana::size_c<1> + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/single/unpack.cpp b/src/boost/libs/hana/test/experimental/view/single/unpack.cpp new file mode 100644 index 000000000..ca2398412 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/single/unpack.cpp @@ -0,0 +1,25 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto f = hana::test::_injection<0>{}; + + { + auto single = hana::experimental::single_view(ct_eq<0>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(single, f), + f(ct_eq<0>{}) + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/sliced/at.cpp b/src/boost/libs/hana/test/experimental/view/sliced/at.cpp new file mode 100644 index 000000000..c8d201a59 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/sliced/at.cpp @@ -0,0 +1,91 @@ +// 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/at.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/tuple.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + + { + auto storage = container(ct_eq<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<0>), + ct_eq<0>{} + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<0>), + ct_eq<0>{} + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<0>), + ct_eq<1>{} + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<1>), + ct_eq<1>{} + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<0>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<1>), + ct_eq<0>{} + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<1>), + ct_eq<0>{} + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 3>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<0>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(sliced, hana::size_c<1>), + ct_eq<3>{} + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/sliced/is_empty.cpp b/src/boost/libs/hana/test/experimental/view/sliced/is_empty.cpp new file mode 100644 index 000000000..d6f0d267e --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/sliced/is_empty.cpp @@ -0,0 +1,49 @@ +// 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/experimental/view.hpp> +#include <boost/hana/is_empty.hpp> +#include <boost/hana/not.hpp> +#include <boost/hana/tuple.hpp> + +#include <support/seq.hpp> +namespace hana = boost::hana; + + +template <int> struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto storage = container(); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); + }{ + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); + }{ + auto storage = container(undefined<0>{}, undefined<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); + } + + { + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced))); + }{ + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced))); + } + + { + auto storage = container(undefined<0>{}, undefined<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced))); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/sliced/length.cpp b/src/boost/libs/hana/test/experimental/view/sliced/length.cpp new file mode 100644 index 000000000..c975960aa --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/sliced/length.cpp @@ -0,0 +1,68 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/length.hpp> +#include <boost/hana/tuple.hpp> + +#include <support/seq.hpp> +namespace hana = boost::hana; + + +template <int> struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto storage = container(); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(sliced), + hana::size_c<0> + )); + } + + { + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(sliced), + hana::size_c<1> + )); + }{ + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(sliced), + hana::size_c<0> + )); + } + + { + auto storage = container(undefined<0>{}, undefined<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(sliced), + hana::size_c<1> + )); + }{ + auto storage = container(undefined<0>{}, undefined<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(sliced), + hana::size_c<2> + )); + }{ + auto storage = container(undefined<0>{}, undefined<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(sliced), + hana::size_c<2> + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/sliced/unpack.cpp b/src/boost/libs/hana/test/experimental/view/sliced/unpack.cpp new file mode 100644 index 000000000..710e8246e --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/sliced/unpack.cpp @@ -0,0 +1,135 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + auto f = hana::test::_injection<0>{}; + + { + auto storage = container(); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f() + )); + } + + { + auto storage = container(ct_eq<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f() + )); + }{ + auto storage = container(ct_eq<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<0>{}) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f() + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<0>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<1>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<1>{}, ct_eq<0>{}) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f() + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<0>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<1>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 2>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<2>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 0, 2>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<0>{}, ct_eq<2>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 1, 1>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<1>{}, ct_eq<1>{}) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c<int, 3, 1, 0, 2, 2>); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(sliced, f), + f(ct_eq<3>{}, ct_eq<1>{}, ct_eq<0>{}, ct_eq<2>{}, ct_eq<2>{}) + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/ap.cpp b/src/boost/libs/hana/test/experimental/view/transformed/ap.cpp new file mode 100644 index 000000000..b04d54fe5 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/ap.cpp @@ -0,0 +1,122 @@ +// 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/ap.hpp> +#include <boost/hana/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/functional/id.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::_injection; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + auto f = hana::test::_injection<99>{}; + + { + auto storage = container(); + auto functions = container(); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container() + )); + }{ + auto storage = container(ct_eq<0>{}); + auto functions = container(); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container() + )); + }{ + auto storage = container(); + auto functions = container(ct_eq<0>{}); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container() + )); + } + + { + auto storage = container(ct_eq<0>{}); + auto functions = container(_injection<0>{}); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container(_injection<0>{}(f(ct_eq<0>{}))) + )); + }{ + auto storage = container(ct_eq<0>{}); + auto functions = container(_injection<0>{}, _injection<1>{}); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container(_injection<0>{}(f(ct_eq<0>{})), + _injection<1>{}(f(ct_eq<0>{}))) + )); + }{ + auto storage = container(ct_eq<0>{}); + auto functions = container(_injection<0>{}, _injection<1>{}, _injection<2>{}); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container(_injection<0>{}(f(ct_eq<0>{})), + _injection<1>{}(f(ct_eq<0>{})), + _injection<2>{}(f(ct_eq<0>{}))) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto functions = container(_injection<0>{}); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container(_injection<0>{}(f(ct_eq<0>{})), + _injection<0>{}(f(ct_eq<1>{}))) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto functions = container(_injection<0>{}); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container(_injection<0>{}(f(ct_eq<0>{})), + _injection<0>{}(f(ct_eq<1>{})), + _injection<0>{}(f(ct_eq<2>{}))) + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto functions = container(_injection<0>{}, _injection<1>{}); + auto transformed_storage = hana::experimental::transformed(storage, f); + auto transformed_functions = hana::experimental::transformed(functions, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(transformed_functions, transformed_storage), + container(_injection<0>{}(f(ct_eq<0>{})), + _injection<0>{}(f(ct_eq<1>{})), + _injection<0>{}(f(ct_eq<2>{})), + + _injection<1>{}(f(ct_eq<0>{})), + _injection<1>{}(f(ct_eq<1>{})), + _injection<1>{}(f(ct_eq<2>{}))) + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/at.cpp b/src/boost/libs/hana/test/experimental/view/transformed/at.cpp new file mode 100644 index 000000000..2379f2878 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/at.cpp @@ -0,0 +1,73 @@ +// 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/at.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/view.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + auto f = hana::test::_injection<0>{}; + + { + auto storage = container(ct_eq<0>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(transformed), + f(ct_eq<0>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(transformed), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(transformed), + f(ct_eq<1>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(transformed), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(transformed), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(transformed), + f(ct_eq<2>{}) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(transformed), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(transformed), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(transformed), + f(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<3>(transformed), + f(ct_eq<3>{}) + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/drop_front.cpp b/src/boost/libs/hana/test/experimental/view/transformed/drop_front.cpp new file mode 100644 index 000000000..0db64fd41 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/drop_front.cpp @@ -0,0 +1,98 @@ +// 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/drop_front.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + auto f = hana::test::_injection<0>{}; + + { + auto storage = container(); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<0>), + container() + )); + } + + { + auto storage = container(ct_eq<0>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<0>), + container(f(ct_eq<0>{})) + )); + }{ + auto storage = container(ct_eq<0>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<1>), + container() + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<0>), + container(f(ct_eq<0>{}), f(ct_eq<1>{})) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<1>), + container(f(ct_eq<1>{})) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<2>), + container() + )); + } + + { + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<0>), + container(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<1>), + container(f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<2>), + container(f(ct_eq<2>{})) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(transformed, hana::size_c<3>), + container() + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/equal.cpp b/src/boost/libs/hana/test/experimental/view/transformed/equal.cpp new file mode 100644 index 000000000..f7723c0cf --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/equal.cpp @@ -0,0 +1,50 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/functional/id.hpp> +#include <boost/hana/not.hpp> + +#include <support/seq.hpp> +namespace hana = boost::hana; + + +int main() { + auto container = ::seq; + + auto xs = container(0, '1', 2.2); + auto tr = hana::experimental::transformed(xs, hana::id); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + tr, + container() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + tr, + container(0) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + tr, + container(0, '1') + ))); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + tr, + container(0, '1', 2.2) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + tr, + container(0, '1', 2.2, 345) + ))); + + BOOST_HANA_RUNTIME_CHECK(hana::not_(hana::equal( + tr, + container('0', '1', '2') + ))); +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/is_empty.cpp b/src/boost/libs/hana/test/experimental/view/transformed/is_empty.cpp new file mode 100644 index 000000000..aafec8ab5 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/is_empty.cpp @@ -0,0 +1,36 @@ +// 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/experimental/view.hpp> +#include <boost/hana/is_empty.hpp> +#include <boost/hana/not.hpp> + +#include <support/seq.hpp> +namespace hana = boost::hana; + + +struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto xs = container(); + auto tr = hana::experimental::transformed(xs, undefined{}); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(tr)); + } + + { + auto xs = container(undefined{}); + auto tr = hana::experimental::transformed(xs, undefined{}); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(tr))); + } + + { + auto xs = container(undefined{}, undefined{}); + auto tr = hana::experimental::transformed(xs, undefined{}); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(tr))); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/laziness.cpp b/src/boost/libs/hana/test/experimental/view/transformed/laziness.cpp new file mode 100644 index 000000000..c1c9fc4ca --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/laziness.cpp @@ -0,0 +1,20 @@ +// 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/experimental/view.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct undefined { }; + +int main() { + // Make sure we do not evaluate the function unless required + auto storage = ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto transformed = hana::experimental::transformed(storage, undefined{}); + (void)transformed; +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/length.cpp b/src/boost/libs/hana/test/experimental/view/transformed/length.cpp new file mode 100644 index 000000000..516df7da8 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/length.cpp @@ -0,0 +1,49 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/length.hpp> + +#include <support/seq.hpp> +namespace hana = boost::hana; + + +template <int> struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto storage = container(); + auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(transformed), + hana::size_c<0> + )); + }{ + auto storage = container(undefined<0>{}); + auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(transformed), + hana::size_c<1> + )); + }{ + auto storage = container(undefined<0>{}, undefined<1>{}); + auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(transformed), + hana::size_c<2> + )); + }{ + auto storage = container(undefined<0>{}, undefined<1>{}, undefined<2>{}); + auto transformed = hana::experimental::transformed(storage, undefined<99>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(transformed), + hana::size_c<3> + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/less.cpp b/src/boost/libs/hana/test/experimental/view/transformed/less.cpp new file mode 100644 index 000000000..562e0a462 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/less.cpp @@ -0,0 +1,58 @@ +// 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/experimental/view.hpp> +#include <boost/hana/less.hpp> +#include <boost/hana/not.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_ord; + + +int main() { + auto container = ::seq; + auto f = hana::test::_injection<0>{}; + + { + auto storage = container(); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + transformed, + container() + ))); + }{ + auto storage = container(ct_ord<0>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::less( + container(), + transformed + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + container(f(ct_ord<0>{})), + transformed + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + transformed, + container() + ))); + }{ + auto storage = container(ct_ord<0>{}, ct_ord<1>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::less( + container(), + transformed + )); + BOOST_HANA_CONSTANT_CHECK(hana::less( + container(f(ct_ord<0>{})), + transformed + )); + BOOST_HANA_CONSTANT_CHECK(hana::less( + container(f(ct_ord<0>{}), f(ct_ord<0>{})), + transformed + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/transform.cpp b/src/boost/libs/hana/test/experimental/view/transformed/transform.cpp new file mode 100644 index 000000000..6fbab6789 --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/transform.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/assert.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/transform.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto container = ::seq; + auto f = hana::test::_injection<0>{}; + auto g = hana::test::_injection<1>{}; + + { + auto storage = container(); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(transformed, g), + container() + )); + }{ + auto storage = container(ct_eq<0>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(transformed, g), + container(g(f(ct_eq<0>{}))) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(transformed, g), + container(g(f(ct_eq<0>{})), g(f(ct_eq<1>{}))) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(transformed, g), + container(g(f(ct_eq<0>{})), g(f(ct_eq<1>{})), g(f(ct_eq<2>{}))) + )); + }{ + auto storage = container(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + auto transformed = hana::experimental::transformed(storage, f); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(transformed, g), + container(g(f(ct_eq<0>{})), g(f(ct_eq<1>{})), g(f(ct_eq<2>{})), g(f(ct_eq<3>{}))) + )); + } +} diff --git a/src/boost/libs/hana/test/experimental/view/transformed/unpack.cpp b/src/boost/libs/hana/test/experimental/view/transformed/unpack.cpp new file mode 100644 index 000000000..6ade5ed2e --- /dev/null +++ b/src/boost/libs/hana/test/experimental/view/transformed/unpack.cpp @@ -0,0 +1,34 @@ +// 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/equal.hpp> +#include <boost/hana/experimental/view.hpp> +#include <boost/hana/unpack.hpp> + +#include <laws/base.hpp> +#include <support/seq.hpp> +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto f = hana::test::_injection<0>{}; + auto g = hana::test::_injection<1>{}; + auto check = [=](auto ...x) { + auto storage = ::seq(x...); + auto transformed = hana::experimental::transformed(storage, f); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(transformed, g), + g(f(x)...) + )); + }; + + check(); + check(ct_eq<0>{}); + check(ct_eq<0>{}, ct_eq<1>{}); + check(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + check(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); +} |