diff options
Diffstat (limited to 'src/boost/libs/hana/test/issues')
21 files changed, 1014 insertions, 0 deletions
diff --git a/src/boost/libs/hana/test/issues/clang_20046.cpp b/src/boost/libs/hana/test/issues/clang_20046.cpp new file mode 100644 index 000000000..7dc68742b --- /dev/null +++ b/src/boost/libs/hana/test/issues/clang_20046.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/type.hpp> +namespace hana = boost::hana; + + +template <typename ...> struct F { struct type; }; +struct M { template <typename ...> struct apply { struct type; }; }; +struct T; + +int main() { + // See http://llvm.org/bugs/show_bug.cgi?id=20046 + [](auto) { return hana::trait<F>; }(1); + [](auto) { return hana::type_c<T>; }(1); + [](auto) { return hana::template_<F>; }(1); + [](auto) { return hana::metafunction<F>; }(1); + [](auto) { return hana::metafunction_class<M>; }(1); +} diff --git a/src/boost/libs/hana/test/issues/github_112.cpp b/src/boost/libs/hana/test/issues/github_112.cpp new file mode 100644 index 000000000..6286cfabe --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_112.cpp @@ -0,0 +1,29 @@ +// 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/accessors.hpp> +#include <boost/hana/adapt_struct.hpp> +#include <boost/hana/define_struct.hpp> +namespace hana = boost::hana; + + +struct Person { + BOOST_HANA_DEFINE_STRUCT(Person, + (int, age) + ); +}; + +struct Employee { + int age; +}; + +BOOST_HANA_ADAPT_STRUCT(Employee, age); + +constexpr auto person_members = hana::accessors<Person>(); +constexpr auto employee_members = hana::accessors<Employee>(); + +int main() { + (void)person_members; + (void)employee_members; +} diff --git a/src/boost/libs/hana/test/issues/github_113.cpp b/src/boost/libs/hana/test/issues/github_113.cpp new file mode 100644 index 000000000..26156981c --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_113.cpp @@ -0,0 +1,22 @@ +// 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/adapt_struct.hpp> +#include <boost/hana/define_struct.hpp> +namespace hana = boost::hana; + + +struct Person { + BOOST_HANA_DEFINE_STRUCT(Person, + (int, Person) + ); +}; + +struct Employee { + int Employee; +}; + +BOOST_HANA_ADAPT_STRUCT(Employee, Employee); + +int main() { } diff --git a/src/boost/libs/hana/test/issues/github_149.cpp b/src/boost/libs/hana/test/issues/github_149.cpp new file mode 100644 index 000000000..59d8f4d58 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_149.cpp @@ -0,0 +1,12 @@ +// 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/map.hpp> +#include <boost/hana/optional.hpp> +namespace hana = boost::hana; + + +auto opt = hana::just(hana::make_map()); + +int main() { } diff --git a/src/boost/libs/hana/test/issues/github_15.cpp b/src/boost/libs/hana/test/issues/github_15.cpp new file mode 100644 index 000000000..09c8149ca --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_15.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/functional/always.hpp> + +#include <support/tracked.hpp> + +#include <utility> +namespace hana = boost::hana; + + +template <typename T> +decltype(auto) call_always(T&& x) { + return hana::always(std::forward<T>(x))(); +} + +int main() { + auto copy = call_always(Tracked{1}); + (void)copy; +} diff --git a/src/boost/libs/hana/test/issues/github_165.cpp b/src/boost/libs/hana/test/issues/github_165.cpp new file mode 100644 index 000000000..2d170df8b --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_165.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/tuple.hpp> + +#include <utility> +namespace hana = boost::hana; + + +constexpr int f() { + // copy-assign + { + hana::tuple<int> xs{1}; + hana::tuple<long> ys{1}; + xs = xs; + ys = xs; + } + + // move-assign + { + hana::tuple<int> xs{1}, xxs{1}; + hana::tuple<long> ys{1}; + xs = std::move(xxs); + ys = std::move(xs); + } + + return 0; +} + +static_assert(f() == 0, ""); // force f() to be constexpr + + +int main() { } diff --git a/src/boost/libs/hana/test/issues/github_202.cpp b/src/boost/libs/hana/test/issues/github_202.cpp new file mode 100644 index 000000000..83a0d6362 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_202.cpp @@ -0,0 +1,26 @@ +// 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/integral_constant.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/tuple.hpp> + +#include <vector> +namespace hana = boost::hana; + + +using Vector = std::vector<int>; + +static_assert( + sizeof(hana::tuple< + hana::pair<hana::int_<0>, Vector>, + hana::pair<hana::int_<1>, Vector>, + hana::pair<hana::int_<2>, Vector>, + hana::pair<hana::int_<3>, Vector> + >) + == + sizeof(hana::tuple<Vector, Vector, Vector, Vector>) +, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/issues/github_221.cpp b/src/boost/libs/hana/test/issues/github_221.cpp new file mode 100644 index 000000000..5bdd82e50 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_221.cpp @@ -0,0 +1,452 @@ +// 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/adjust_if.hpp> +#include <boost/hana/all_of.hpp> +#include <boost/hana/any_of.hpp> +#include <boost/hana/assert.hpp> +#include <boost/hana/count_if.hpp> +#include <boost/hana/drop_while.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/ext/std/tuple.hpp> +#include <boost/hana/filter.hpp> +#include <boost/hana/find_if.hpp> +#include <boost/hana/functional/id.hpp> +#include <boost/hana/functional/partial.hpp> +#include <boost/hana/group.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/lexicographical_compare.hpp> +#include <boost/hana/maximum.hpp> +#include <boost/hana/minimum.hpp> +#include <boost/hana/none_of.hpp> +#include <boost/hana/optional.hpp> +#include <boost/hana/partition.hpp> +#include <boost/hana/plus.hpp> +#include <boost/hana/remove_if.hpp> +#include <boost/hana/replace_if.hpp> +#include <boost/hana/sort.hpp> +#include <boost/hana/span.hpp> +#include <boost/hana/take_while.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/unique.hpp> +#include <boost/hana/while.hpp> +namespace hana = boost::hana; + + +constexpr auto increment = hana::partial(hana::plus, hana::int_c<1>); + +int main() { + + // adjust_if + { + constexpr auto x = hana::adjust_if(hana::make_tuple(hana::int_c<0>), hana::id, increment); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::make_tuple(hana::int_c<0>))); + + constexpr auto y = hana::adjust_if(hana::make_tuple(hana::int_c<1>), hana::id, increment); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, hana::make_tuple(hana::int_c<2>))); + + constexpr auto z = hana::adjust_if(hana::make_tuple(hana::int_c<3>), hana::id, increment); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::make_tuple(hana::int_c<4>))); + + constexpr auto l = hana::adjust_if(hana::tuple_c<int, 3>, hana::id, increment); + BOOST_HANA_CONSTANT_CHECK(hana::equal(l, hana::make_tuple(hana::int_c<4>))); + } + { + // test with lvalue + constexpr auto x = hana::adjust_if(hana::tuple_c<int, 3>, hana::id, increment); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::make_tuple(hana::int_c<4>))); + } + + // all_of + { + BOOST_HANA_CONSTANT_CHECK(!hana::all_of(hana::make_tuple(hana::int_c<0>), hana::id)); + BOOST_HANA_CONSTANT_CHECK(hana::all_of(hana::make_tuple(hana::int_c<1>), hana::id)); + BOOST_HANA_CONSTANT_CHECK(hana::all_of(hana::make_tuple(hana::int_c<3>), hana::id)); + // test with lvalue + BOOST_HANA_CONSTANT_CHECK(hana::all_of(hana::tuple_c<int, 3>, hana::id)); + } + + // any_of + { + BOOST_HANA_CONSTANT_CHECK(!hana::any_of(hana::make_tuple(hana::int_c<0>), hana::id)); + BOOST_HANA_CONSTANT_CHECK(hana::any_of(hana::make_tuple(hana::int_c<1>), hana::id)); + BOOST_HANA_CONSTANT_CHECK(hana::any_of(hana::make_tuple(hana::int_c<3>), hana::id)); + // test with lvalue + BOOST_HANA_CONSTANT_CHECK(hana::any_of(hana::tuple_c<int, 3>, hana::id)); + } + + // count_if + { + constexpr auto x = hana::count_if(hana::make_tuple(hana::int_c<0>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::size_c<0>)); + + constexpr auto y = hana::count_if(hana::make_tuple(hana::int_c<1>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, hana::size_c<1>)); + + constexpr auto z = hana::count_if(hana::make_tuple(hana::int_c<3>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::size_c<1>)); + } + { + // test with lvalue + constexpr auto x = hana::count_if(hana::tuple_c<int, 3>, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::size_c<1>)); + } + + // drop_while + { + constexpr auto x = hana::drop_while( + hana::make_tuple(hana::int_c<0>), hana::id + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_tuple(hana::int_c<0>) + ) + ); + constexpr auto y = hana::drop_while( + hana::make_tuple(hana::int_c<1>, hana::int_c<3>, hana::int_c<0>), hana::id + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, + hana::make_tuple(hana::int_c<0>) + ) + ); + } + { + // test with lvalue + constexpr auto x = hana::drop_while( + hana::tuple_c<int, 1, 3, 0>, hana::id + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_tuple(hana::int_c<0>) + ) + ); + } + + // filter + { + constexpr auto x = hana::filter(hana::make_tuple(hana::int_c<0>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::make_tuple())); + + constexpr auto y = hana::filter(hana::make_tuple(hana::int_c<1>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, hana::make_tuple(hana::int_c<1>))); + + constexpr auto z = hana::filter(hana::make_tuple(hana::int_c<3>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::make_tuple(hana::int_c<3>))); + + } + { + // test with lvalue + constexpr auto x = hana::filter(hana::tuple_c<int, 3>, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::make_tuple(hana::int_c<3>))); + } + + // find_if + { + constexpr auto x = hana::find_if(hana::make_tuple(hana::int_c<0>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::nothing)); + + constexpr auto y = hana::find_if(hana::make_tuple(hana::int_c<1>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, hana::just(hana::int_c<1>))); + + constexpr auto z = hana::find_if(hana::make_tuple(hana::int_c<3>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::just(hana::int_c<3>))); + } + { + // test with lvalue + constexpr auto z = hana::find_if(hana::tuple_c<int, 3>, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::just(hana::int_c<3>))); + } + { + // test with std::tuple (for default implementation of find_if) + constexpr auto x = hana::find_if(std::make_tuple(hana::int_c<0>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::nothing)); + + constexpr auto y = hana::find_if(std::make_tuple(hana::int_c<1>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, hana::just(hana::int_c<1>))); + + constexpr auto z = hana::find_if(std::make_tuple(hana::int_c<3>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::just(hana::int_c<3>))); + } + { + // test with lvalue + constexpr auto seq = std::make_tuple(hana::int_c<3>); + constexpr auto x = hana::find_if(seq, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::just(hana::int_c<3>))); + } + + // group + { + constexpr auto x = hana::group( + hana::make_tuple( + hana::int_c<0>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<1>, + hana::int_c<2> + ), + hana::plus + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_tuple( + hana::tuple_c<int, 0>, + hana::tuple_c<int, 0, 1, 1, 2> + ) + ) + ); + } + { + // test with lvalue + constexpr auto x = hana::group(hana::tuple_c<int, 0, 0, 1, 1, 2>, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_tuple( + hana::tuple_c<int, 0>, + hana::tuple_c<int, 0, 1, 1, 2> + ) + ) + ); + } + + // lexicographical_compare + { + BOOST_HANA_CONSTANT_CHECK( + hana::lexicographical_compare( + hana::make_tuple(hana::int_c<0>, hana::int_c<0>), + hana::make_tuple(hana::int_c<0>, hana::int_c<3>), + hana::plus + ) + ); + } + { + // test with lvalue + BOOST_HANA_CONSTANT_CHECK( + hana::lexicographical_compare( + hana::tuple_c<int, 0, 0>, + hana::tuple_c<int, 0, 3>, + hana::plus + ) + ); + } + + // maximum + { + constexpr auto x = hana::maximum( + hana::make_tuple( + hana::int_c<0>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<3>, + hana::int_c<2> + ), + hana::plus + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::int_c<2>)); + } + { + // test with lvalue + constexpr auto x = hana::maximum(hana::tuple_c<int, 0, 0, 1, 3, 2>, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::int_c<2>)); + } + + // minimum + { + constexpr auto x = hana::minimum( + hana::make_tuple( + hana::int_c<0>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<3>, + hana::int_c<2> + ), + hana::plus + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::int_c<0>)); + } + { + // test with lvalue + constexpr auto x = hana::minimum(hana::tuple_c<int, 0, 0, 1, 3, 2>, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::int_c<0>)); + } + + // none_of + { + BOOST_HANA_CONSTANT_CHECK(hana::none_of(hana::make_tuple(hana::int_c<0>), hana::id)); + BOOST_HANA_CONSTANT_CHECK(!hana::none_of(hana::make_tuple(hana::int_c<1>), hana::id)); + BOOST_HANA_CONSTANT_CHECK(!hana::none_of(hana::make_tuple(hana::int_c<3>), hana::id)); + } + { + // test with lvalue + BOOST_HANA_CONSTANT_CHECK(hana::none_of(hana::tuple_c<int, 0>, hana::id)); + BOOST_HANA_CONSTANT_CHECK(!hana::none_of(hana::tuple_c<int, 1>, hana::id)); + BOOST_HANA_CONSTANT_CHECK(!hana::none_of(hana::tuple_c<int, 3>, hana::id)); + } + + // partition + { + constexpr auto x = hana::partition( + hana::make_tuple( + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<3> + ), + hana::id + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_pair( + hana::tuple_c<int, 1, 3>, + hana::tuple_c<int, 0> + ) + ) + ); + } + { + // test with lvalue + constexpr auto x = hana::partition(hana::tuple_c<int, 0, 1, 3>, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_pair( + hana::tuple_c<int, 1, 3>, + hana::tuple_c<int, 0> + ) + ) + ); + } + + // remove_if + { + constexpr auto x = hana::remove_if(hana::make_tuple(hana::int_c<0>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::make_tuple(hana::int_c<0>))); + + constexpr auto y = hana::remove_if(hana::make_tuple(hana::int_c<1>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, hana::make_tuple())); + + constexpr auto z = hana::remove_if(hana::make_tuple(hana::int_c<3>), hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::make_tuple())); + } + { + // test with lvalue + constexpr auto z = hana::remove_if(hana::tuple_c<int, 3>, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::make_tuple())); + } + + // replace_if + { + constexpr auto x = hana::replace_if( + hana::make_tuple(hana::int_c<0>), + hana::id, + hana::int_c<42> + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::make_tuple(hana::int_c<0>))); + + constexpr auto y = hana::replace_if( + hana::make_tuple(hana::int_c<1>), + hana::id, + hana::int_c<42> + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(y, hana::make_tuple(hana::int_c<42>))); + + constexpr auto z = hana::replace_if( + hana::make_tuple(hana::int_c<3>), + hana::id, + hana::int_c<42> + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::make_tuple(hana::int_c<42>))); + } + { + // test with lvalue + constexpr auto z = hana::replace_if( + hana::tuple_c<int, 3>, + hana::id, + hana::int_c<42> + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(z, hana::make_tuple(hana::int_c<42>))); + } + + // sort + { + constexpr auto x = hana::sort( + hana::make_tuple( + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<2> + ), + hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c<int, 2, 1, 0>)); + } + { + // test with lvalue + constexpr auto x = hana::sort(hana::tuple_c<int, 0, 1, 2>, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c<int, 2, 1, 0>)); + } + // span + { + constexpr auto x = hana::span( + hana::make_tuple( + hana::int_c<2>, + hana::int_c<1>, + hana::int_c<0> + ), + hana::id + ); + BOOST_HANA_CONSTANT_CHECK( + hana::equal(x, + hana::make_pair( + hana::tuple_c<int, 2, 1>, + hana::tuple_c<int, 0> + ) + ) + ); + } + { + // test with an lvalue + constexpr auto x = hana::span(hana::tuple_c<int, 2, 1, 0>, hana::id); + BOOST_HANA_CONSTANT_CHECK( + hana::equal(x, + hana::make_pair( + hana::tuple_c<int, 2, 1>, + hana::tuple_c<int, 0> + ) + ) + ); + } + + // take_while + { + constexpr auto x = hana::take_while( + hana::make_tuple( + hana::int_c<2>, + hana::int_c<1>, + hana::int_c<0> + ), + hana::id + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c<int, 2, 1>)); + } + { + // test with lvalue + constexpr auto x = hana::take_while(hana::tuple_c<int, 2, 1, 0>, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c<int, 2, 1>)); + } + + // unique + { + constexpr auto x = hana::unique( + hana::make_tuple( + hana::int_c<0>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<2> + ), + hana::plus + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c<int, 0, 0>)); + } + { + // test with lvalue + constexpr auto x = hana::unique(hana::tuple_c<int, 0, 0, 1, 2>, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c<int, 0, 0>)); + } + + // while + { + constexpr auto x = hana::while_(hana::id, hana::int_c<-3>, increment); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::int_c<0>)); + } +} diff --git a/src/boost/libs/hana/test/issues/github_234.cpp b/src/boost/libs/hana/test/issues/github_234.cpp new file mode 100644 index 000000000..bf44412f8 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_234.cpp @@ -0,0 +1,31 @@ +// 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/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/set.hpp> +namespace hana = boost::hana; + + +int main() { + { + auto set = hana::make_set(hana::int_c<1>, hana::integral_c<signed char, 'x'>); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(set, hana::int_c<1>)); + BOOST_HANA_CONSTANT_CHECK(hana::contains(set, hana::integral_c<signed char, 'x'>)); + } + + { + auto map = hana::make_map( + hana::make_pair(hana::int_c<1>, 1), + hana::make_pair(hana::integral_c<signed char, 'x'>, 'x') + ); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(map, hana::int_c<1>)); + BOOST_HANA_CONSTANT_CHECK(hana::contains(map, hana::integral_c<signed char, 'x'>)); + } +} diff --git a/src/boost/libs/hana/test/issues/github_252.cpp b/src/boost/libs/hana/test/issues/github_252.cpp new file mode 100644 index 000000000..34df48d28 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_252.cpp @@ -0,0 +1,38 @@ +// Copyright Sergey Nizovtsev 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/core/is_a.hpp> +#include <boost/hana/functional/partial.hpp> +#include <boost/hana/product.hpp> +#include <boost/hana/range.hpp> +#include <boost/hana/traits.hpp> +#include <boost/hana/transform.hpp> +#include <boost/hana/tuple.hpp> +#include <boost/hana/type.hpp> + +namespace hana = boost::hana; + +int main() { + constexpr auto type = hana::type_c<int[2][3][4]>; + + BOOST_HANA_CONSTANT_CHECK( + hana::is_an<hana::integral_constant_tag<size_t>>( + hana::traits::extent(type, hana::uint_c<1>) + ) + ); + + // Check that we can multiple extents in size_t's ring + hana::product<hana::integral_constant_tag<size_t>>( + hana::transform( + hana::to_tuple( + hana::make_range( + hana::size_c<0>, + hana::traits::rank(type) + ) + ), + hana::partial(hana::traits::extent, type) + ) + ); +} diff --git a/src/boost/libs/hana/test/issues/github_260.cpp b/src/boost/libs/hana/test/issues/github_260.cpp new file mode 100644 index 000000000..8b2428562 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_260.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/functional/curry.hpp> +#include <boost/hana/functional/partial.hpp> +#include <boost/hana/functional/reverse_partial.hpp> +#include <boost/hana/tuple.hpp> + +#include <tuple> +#include <type_traits> +namespace hana = boost::hana; + + +struct DefaultConstructible { + DefaultConstructible() = default; +}; + +int main() { + auto curry_tuple = hana::make_tuple( + std::make_tuple(hana::curry<2>(DefaultConstructible{})(DefaultConstructible{})) + ); + + auto partial_tuple = hana::make_tuple( + std::make_tuple(hana::partial(DefaultConstructible{}, DefaultConstructible{})) + ); + + auto reverse_partial_tuple = hana::make_tuple( + std::make_tuple(hana::reverse_partial(DefaultConstructible{}, DefaultConstructible{})) + ); + + static_assert(std::is_default_constructible<decltype(curry_tuple)>::value, ""); + static_assert(std::is_default_constructible<decltype(partial_tuple)>::value, ""); + static_assert(std::is_default_constructible<decltype(reverse_partial_tuple)>::value, ""); +} diff --git a/src/boost/libs/hana/test/issues/github_266.cpp b/src/boost/libs/hana/test/issues/github_266.cpp new file mode 100644 index 000000000..52059da02 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_266.cpp @@ -0,0 +1,17 @@ +// 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/bool.hpp> +#include <boost/hana/experimental/types.hpp> +#include <boost/hana/replace_if.hpp> +#include <boost/hana/type.hpp> +namespace hana = boost::hana; + + +struct predicate { hana::true_ operator()(...) const; }; + +int main() { + auto types = hana::experimental::types<void, void>{}; + hana::replace_if(types, predicate{}, hana::type<struct anything>{}); +} diff --git a/src/boost/libs/hana/test/issues/github_269.cpp b/src/boost/libs/hana/test/issues/github_269.cpp new file mode 100644 index 000000000..242684aa4 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_269.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/assert.hpp> +#include <boost/hana/concept.hpp> +namespace hana = boost::hana; + + +using T = int; + +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Applicative<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Comonad<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Comparable<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Constant<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::EuclideanRing<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Foldable<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Functor<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Group<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Hashable<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::IntegralConstant<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Iterable<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Logical<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Metafunction<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Monad<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::MonadPlus<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Monoid<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Orderable<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Product<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Ring<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Searchable<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Sequence<T>>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant<hana::Struct<T>>{}); + +int main() { } diff --git a/src/boost/libs/hana/test/issues/github_297.cpp b/src/boost/libs/hana/test/issues/github_297.cpp new file mode 100644 index 000000000..40bf403be --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_297.cpp @@ -0,0 +1,22 @@ +// 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/integral_constant.hpp> +#include <boost/hana/map.hpp> +#include <boost/hana/pair.hpp> + +#include <memory> +namespace hana = boost::hana; + + +int main() { + auto map = hana::make_map( + hana::make_pair(hana::int_c<0>, 123), + hana::make_pair(hana::int_c<1>, 456) + ); + + std::unique_ptr<decltype(map)> p1{}, p2{}; + using std::swap; + swap(p1, p2); +} diff --git a/src/boost/libs/hana/test/issues/github_31.cpp b/src/boost/libs/hana/test/issues/github_31.cpp new file mode 100644 index 000000000..ddbdefcdd --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_31.cpp @@ -0,0 +1,53 @@ +// 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/any_of.hpp> +#include <boost/hana/assert.hpp> +#include <boost/hana/bool.hpp> +#include <boost/hana/equal.hpp> +#include <boost/hana/find_if.hpp> +#include <boost/hana/fwd/at.hpp> +#include <boost/hana/fwd/drop_front.hpp> +#include <boost/hana/fwd/is_empty.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/optional.hpp> +namespace hana = boost::hana; + + +// A simple infinite Iterable. +template <int i> +struct counter { }; + +namespace boost { namespace hana { + template <int i> + struct at_impl<counter<i>> { + template <typename N> + static constexpr auto apply(counter<i>, N const&) { + return hana::int_c<i + N::value>; + } + }; + + template <int i> + struct drop_front_impl<counter<i>> { + template <typename N> + static constexpr auto apply(counter<i>, N) { return counter<i + N::value>{}; } + }; + + template <int i> + struct is_empty_impl<counter<i>> { + static constexpr auto apply(counter<i>) { return hana::false_c; } + }; +}} + + +int main() { + // find_if and any_of should short-circuit and stop even though the + // Iterable is infinite. + BOOST_HANA_CONSTANT_CHECK(hana::any_of(counter<1>{}, hana::equal.to(hana::int_c<4>))); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(counter<1>{}, hana::equal.to(hana::int_c<4>)), + hana::just(hana::int_c<4>) + )); +} diff --git a/src/boost/libs/hana/test/issues/github_331.cpp b/src/boost/libs/hana/test/issues/github_331.cpp new file mode 100644 index 000000000..246f39432 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_331.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/at.hpp> +#include <boost/hana/bool.hpp> +#include <boost/hana/first.hpp> +#include <boost/hana/integral_constant.hpp> +#include <boost/hana/pair.hpp> +#include <boost/hana/second.hpp> +#include <boost/hana/tuple.hpp> + +#include <type_traits> +#include <utility> +namespace hana = boost::hana; + + +// In GitHub issue #331, we noticed that `first` and `second` could sometimes +// return the wrong member in case of nested pairs. This is due to the way we +// inherit from base classes to enable EBO. We also check for `basic_tuple`, +// because both are implemented similarly. + +int main() { + { + using Nested = hana::pair<hana::int_<1>, hana::int_<2>>; + using Pair = hana::pair<hana::int_<0>, Nested>; + Pair pair{}; + + auto a = hana::first(pair); + static_assert(std::is_same<decltype(a), hana::int_<0>>{}, ""); + + auto b = hana::second(pair); + static_assert(std::is_same<decltype(b), Nested>{}, ""); + } + + { + using Nested = hana::basic_tuple<hana::int_<1>, hana::int_<2>>; + using Tuple = hana::basic_tuple<hana::int_<0>, Nested>; + Tuple tuple{}; + + auto a = hana::at_c<0>(tuple); + static_assert(std::is_same<decltype(a), hana::int_<0>>{}, ""); + + auto b = hana::at_c<1>(tuple); + static_assert(std::is_same<decltype(b), Nested>{}, ""); + } + + // Original test case submitted by Vittorio Romeo + { + hana::pair<hana::int_<1>, hana::bool_<false>> p{}; + auto copy = hana::make_pair(hana::int_c<0>, p); + auto move = hana::make_pair(hana::int_c<0>, std::move(p)); + + copy = move; // copy assign + copy = std::move(move); // move assign + } +} diff --git a/src/boost/libs/hana/test/issues/github_362.cpp b/src/boost/libs/hana/test/issues/github_362.cpp new file mode 100644 index 000000000..885d386b5 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_362.cpp @@ -0,0 +1,13 @@ +// 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/integral_constant.hpp> +namespace hana = boost::hana; +using namespace hana::literals; + + +static constexpr auto x = 4'321'000_c; +static_assert(decltype(x)::value == 4'321'000, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/issues/github_365.cpp b/src/boost/libs/hana/test/issues/github_365.cpp new file mode 100644 index 000000000..63d756f4e --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_365.cpp @@ -0,0 +1,61 @@ +// 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/accessors.hpp> +#include <boost/hana/adapt_struct.hpp> +#include <boost/hana/assert.hpp> +#include <boost/hana/at.hpp> +#include <boost/hana/define_struct.hpp> +#include <boost/hana/second.hpp> + +#include <cstddef> +#include <type_traits> +namespace hana = boost::hana; + + +// +// This test makes sure that `hana::accessors` does not decay C-style array +// members to pointers. +// + +struct Foo { + float array[3]; +}; + +BOOST_HANA_ADAPT_STRUCT(Foo, + array +); + +template <std::size_t N> +using FloatArray = float[N]; + +struct Bar { + BOOST_HANA_DEFINE_STRUCT(Bar, + (FloatArray<3>, array) + ); +}; + +int main() { + { + Foo foo = {{1.0f, 2.0f, 3.0f}}; + auto accessors = hana::accessors<Foo>(); + auto get_array = hana::second(hana::at_c<0>(accessors)); + static_assert(std::is_same<decltype(get_array(foo)), float(&)[3]>{}, ""); + float (&array)[3] = get_array(foo); + BOOST_HANA_RUNTIME_CHECK(array[0] == 1.0f); + BOOST_HANA_RUNTIME_CHECK(array[1] == 2.0f); + BOOST_HANA_RUNTIME_CHECK(array[2] == 3.0f); + } + + { + Bar bar = {{1.0f, 2.0f, 3.0f}}; + auto accessors = hana::accessors<Bar>(); + auto get_array = hana::second(hana::at_c<0>(accessors)); + static_assert(std::is_same<decltype(get_array(bar)), float(&)[3]>{}, ""); + float (&array)[3] = get_array(bar); + BOOST_HANA_RUNTIME_CHECK(array[0] == 1.0f); + BOOST_HANA_RUNTIME_CHECK(array[1] == 2.0f); + BOOST_HANA_RUNTIME_CHECK(array[2] == 3.0f); + } +} diff --git a/src/boost/libs/hana/test/issues/github_75/tu1.cpp b/src/boost/libs/hana/test/issues/github_75/tu1.cpp new file mode 100644 index 000000000..d4b570f71 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_75/tu1.cpp @@ -0,0 +1,7 @@ +// 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.hpp> + +int main() { } diff --git a/src/boost/libs/hana/test/issues/github_75/tu2.cpp b/src/boost/libs/hana/test/issues/github_75/tu2.cpp new file mode 100644 index 000000000..688337665 --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_75/tu2.cpp @@ -0,0 +1,5 @@ +// 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.hpp> diff --git a/src/boost/libs/hana/test/issues/github_91.cpp b/src/boost/libs/hana/test/issues/github_91.cpp new file mode 100644 index 000000000..88f1832ef --- /dev/null +++ b/src/boost/libs/hana/test/issues/github_91.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/concept/comparable.hpp> +#include <boost/hana/concept/euclidean_ring.hpp> +#include <boost/hana/concept/group.hpp> +#include <boost/hana/concept/monoid.hpp> +#include <boost/hana/concept/orderable.hpp> +#include <boost/hana/concept/ring.hpp> +#include <boost/hana/integral_constant.hpp> +namespace hana = boost::hana; + + +using T = decltype(hana::int_c<1>); + +static_assert(hana::Comparable<T>::value, ""); +static_assert(hana::Orderable<T>::value, ""); +static_assert(hana::Monoid<T>::value, ""); +static_assert(hana::Group<T>::value, ""); +static_assert(hana::Ring<T>::value, ""); +static_assert(hana::EuclideanRing<T>::value, ""); + +int main() { } |