From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/boost/libs/hana/test/CMakeLists.txt | 143 +++ src/boost/libs/hana/test/Jamfile.v2 | 51 + src/boost/libs/hana/test/_include/auto/README.md | 44 + src/boost/libs/hana/test/_include/auto/all_of.hpp | 120 +++ src/boost/libs/hana/test/_include/auto/any_of.hpp | 173 +++ src/boost/libs/hana/test/_include/auto/ap.hpp | 76 ++ src/boost/libs/hana/test/_include/auto/at.hpp | 91 ++ .../hana/test/_include/auto/cartesian_product.hpp | 234 +++++ .../libs/hana/test/_include/auto/drop_back.hpp | 99 ++ .../libs/hana/test/_include/auto/drop_front.hpp | 160 +++ .../libs/hana/test/_include/auto/drop_while.hpp | 72 ++ .../libs/hana/test/_include/auto/for_each.hpp | 64 ++ src/boost/libs/hana/test/_include/auto/group.hpp | 150 +++ .../libs/hana/test/_include/auto/index_if.hpp | 81 ++ src/boost/libs/hana/test/_include/auto/insert.hpp | 84 ++ .../libs/hana/test/_include/auto/insert_range.hpp | 105 ++ .../libs/hana/test/_include/auto/intersperse.hpp | 54 + .../libs/hana/test/_include/auto/is_empty.hpp | 55 + src/boost/libs/hana/test/_include/auto/length.hpp | 48 + .../test/_include/auto/lexicographical_compare.hpp | 109 ++ src/boost/libs/hana/test/_include/auto/make.hpp | 41 + src/boost/libs/hana/test/_include/auto/none_of.hpp | 90 ++ .../libs/hana/test/_include/auto/partition.hpp | 74 ++ .../libs/hana/test/_include/auto/permutations.hpp | 87 ++ .../libs/hana/test/_include/auto/remove_at.hpp | 130 +++ .../libs/hana/test/_include/auto/remove_range.hpp | 114 ++ src/boost/libs/hana/test/_include/auto/reverse.hpp | 55 + src/boost/libs/hana/test/_include/auto/scans.hpp | 216 ++++ .../libs/hana/test/_include/auto/sequence.hpp | 13 + src/boost/libs/hana/test/_include/auto/slice.hpp | 182 ++++ src/boost/libs/hana/test/_include/auto/sort.hpp | 111 ++ src/boost/libs/hana/test/_include/auto/span.hpp | 84 ++ .../libs/hana/test/_include/auto/take_back.hpp | 82 ++ .../libs/hana/test/_include/auto/take_front.hpp | 77 ++ .../libs/hana/test/_include/auto/take_while.hpp | 68 ++ .../libs/hana/test/_include/auto/test_case.hpp | 13 + .../libs/hana/test/_include/auto/transform.hpp | 74 ++ src/boost/libs/hana/test/_include/auto/unfolds.hpp | 170 +++ src/boost/libs/hana/test/_include/auto/unique.hpp | 158 +++ src/boost/libs/hana/test/_include/auto/zips.hpp | 342 ++++++ .../libs/hana/test/_include/laws/applicative.hpp | 196 ++++ src/boost/libs/hana/test/_include/laws/base.hpp | 369 +++++++ src/boost/libs/hana/test/_include/laws/comonad.hpp | 53 + .../libs/hana/test/_include/laws/comparable.hpp | 167 +++ .../libs/hana/test/_include/laws/constant.hpp | 106 ++ .../hana/test/_include/laws/euclidean_ring.hpp | 99 ++ .../libs/hana/test/_include/laws/foldable.hpp | 1104 ++++++++++++++++++++ src/boost/libs/hana/test/_include/laws/functor.hpp | 250 +++++ src/boost/libs/hana/test/_include/laws/group.hpp | 93 ++ .../libs/hana/test/_include/laws/hashable.hpp | 60 ++ .../libs/hana/test/_include/laws/iterable.hpp | 195 ++++ src/boost/libs/hana/test/_include/laws/logical.hpp | 137 +++ src/boost/libs/hana/test/_include/laws/monad.hpp | 222 ++++ .../libs/hana/test/_include/laws/monad_plus.hpp | 616 +++++++++++ src/boost/libs/hana/test/_include/laws/monoid.hpp | 86 ++ .../libs/hana/test/_include/laws/orderable.hpp | 182 ++++ src/boost/libs/hana/test/_include/laws/product.hpp | 46 + src/boost/libs/hana/test/_include/laws/ring.hpp | 125 +++ .../libs/hana/test/_include/laws/searchable.hpp | 611 +++++++++++ .../libs/hana/test/_include/laws/sequence.hpp | 133 +++ .../libs/hana/test/_include/laws/templates/seq.hpp | 132 +++ .../libs/hana/test/_include/support/cnumeric.hpp | 66 ++ .../test/_include/support/constexpr_move_only.hpp | 41 + .../libs/hana/test/_include/support/counter.hpp | 56 + .../test/_include/support/equivalence_class.hpp | 34 + .../libs/hana/test/_include/support/identity.hpp | 159 +++ .../hana/test/_include/support/minimal_product.hpp | 61 ++ .../libs/hana/test/_include/support/numeric.hpp | 175 ++++ src/boost/libs/hana/test/_include/support/seq.hpp | 122 +++ .../libs/hana/test/_include/support/tracked.hpp | 120 +++ .../test/_include/support/tracked_move_only.hpp | 45 + src/boost/libs/hana/test/assert/commas.cpp | 35 + src/boost/libs/hana/test/assert/constant.cpp | 53 + src/boost/libs/hana/test/assert/constexpr.cpp | 30 + src/boost/libs/hana/test/assert/flexible.cpp | 34 + src/boost/libs/hana/test/assert/lambdas.cpp | 25 + src/boost/libs/hana/test/assert/runtime.cpp | 22 + .../libs/hana/test/basic_tuple/auto/_specs.hpp | 15 + .../libs/hana/test/basic_tuple/auto/all_of.cpp | 8 + .../libs/hana/test/basic_tuple/auto/any_of.cpp | 8 + src/boost/libs/hana/test/basic_tuple/auto/ap.cpp | 8 + src/boost/libs/hana/test/basic_tuple/auto/at.cpp | 8 + .../test/basic_tuple/auto/cartesian_product.cpp | 8 + .../libs/hana/test/basic_tuple/auto/drop_back.cpp | 8 + .../libs/hana/test/basic_tuple/auto/drop_front.cpp | 8 + .../libs/hana/test/basic_tuple/auto/drop_while.cpp | 8 + .../libs/hana/test/basic_tuple/auto/for_each.cpp | 8 + .../libs/hana/test/basic_tuple/auto/group.cpp | 8 + .../libs/hana/test/basic_tuple/auto/index_if.cpp | 9 + .../libs/hana/test/basic_tuple/auto/insert.cpp | 8 + .../hana/test/basic_tuple/auto/insert_range.cpp | 8 + .../hana/test/basic_tuple/auto/intersperse.cpp | 8 + .../libs/hana/test/basic_tuple/auto/is_empty.cpp | 8 + .../libs/hana/test/basic_tuple/auto/length.cpp | 8 + .../basic_tuple/auto/lexicographical_compare.cpp | 8 + src/boost/libs/hana/test/basic_tuple/auto/make.cpp | 8 + .../libs/hana/test/basic_tuple/auto/none_of.cpp | 8 + .../libs/hana/test/basic_tuple/auto/partition.cpp | 8 + .../hana/test/basic_tuple/auto/permutations.cpp | 8 + .../libs/hana/test/basic_tuple/auto/remove_at.cpp | 8 + .../hana/test/basic_tuple/auto/remove_range.cpp | 8 + .../libs/hana/test/basic_tuple/auto/reverse.cpp | 8 + .../libs/hana/test/basic_tuple/auto/scans.cpp | 8 + .../libs/hana/test/basic_tuple/auto/sequence.cpp | 8 + .../libs/hana/test/basic_tuple/auto/slice.cpp | 8 + src/boost/libs/hana/test/basic_tuple/auto/sort.cpp | 8 + src/boost/libs/hana/test/basic_tuple/auto/span.cpp | 8 + .../libs/hana/test/basic_tuple/auto/take_back.cpp | 8 + .../libs/hana/test/basic_tuple/auto/take_front.cpp | 8 + .../libs/hana/test/basic_tuple/auto/take_while.cpp | 8 + .../libs/hana/test/basic_tuple/auto/transform.cpp | 8 + .../libs/hana/test/basic_tuple/auto/unfolds.cpp | 8 + .../libs/hana/test/basic_tuple/auto/unique.cpp | 8 + src/boost/libs/hana/test/basic_tuple/auto/zips.cpp | 8 + .../libs/hana/test/basic_tuple/cnstr.copy.cpp | 86 ++ src/boost/libs/hana/test/basic_tuple/construct.cpp | 19 + src/boost/libs/hana/test/basic_tuple/laws.cpp | 35 + src/boost/libs/hana/test/basic_tuple/length.cpp | 41 + src/boost/libs/hana/test/basic_tuple/make.cpp | 18 + src/boost/libs/hana/test/basic_tuple/unpack.cpp | 37 + src/boost/libs/hana/test/builtin_array.cpp | 121 +++ src/boost/libs/hana/test/comparable.cpp | 70 ++ .../libs/hana/test/concept/constant/arithmetic.cpp | 29 + .../libs/hana/test/concept/constant/comparable.cpp | 23 + src/boost/libs/hana/test/concept/constant/laws.cpp | 25 + .../libs/hana/test/concept/constant/logical.cpp | 191 ++++ src/boost/libs/hana/test/concept/constant/mcd.cpp | 31 + .../libs/hana/test/concept/constant/minimal.hpp | 45 + .../libs/hana/test/concept/constant/orderable.cpp | 23 + src/boost/libs/hana/test/concept/constant/to.cpp | 21 + .../libs/hana/test/concept/integral_constant.cpp | 52 + .../libs/hana/test/concept/sequence/iterable.cpp | 6 + .../libs/hana/test/concept/sequence/monad.cpp | 6 + .../libs/hana/test/concept/sequence/monad_plus.cpp | 6 + .../libs/hana/test/concept/sequence/orderable.cpp | 6 + .../libs/hana/test/concept/sequence/searchable.cpp | 6 + .../libs/hana/test/concept/sequence/sequence.cpp | 6 + src/boost/libs/hana/test/concept/struct/any_of.cpp | 46 + src/boost/libs/hana/test/concept/struct/at_key.cpp | 55 + src/boost/libs/hana/test/concept/struct/equal.cpp | 47 + .../libs/hana/test/concept/struct/find_if.cpp | 48 + .../libs/hana/test/concept/struct/fold_left.cpp | 59 ++ .../libs/hana/test/concept/struct/fold_right.cpp | 59 ++ src/boost/libs/hana/test/concept/struct/keys.cpp | 46 + src/boost/libs/hana/test/concept/struct/laws.cpp | 43 + .../hana/test/concept/struct/macro.adapt_adt.cpp | 61 ++ .../test/concept/struct/macro.adapt_struct.cpp | 58 + .../test/concept/struct/macro.define_struct.cpp | 57 + .../hana/test/concept/struct/member_function.cpp | 43 + .../libs/hana/test/concept/struct/members.cpp | 51 + .../hana/test/concept/struct/minimal_struct.hpp | 54 + src/boost/libs/hana/test/concept/struct/unpack.cpp | 44 + src/boost/libs/hana/test/core/common.cpp | 32 + src/boost/libs/hana/test/core/default.cpp | 18 + src/boost/libs/hana/test/core/is_a.cpp | 18 + src/boost/libs/hana/test/core/is_embedded.cpp | 62 ++ src/boost/libs/hana/test/core/make.cpp | 16 + src/boost/libs/hana/test/core/tag_of.cpp | 74 ++ src/boost/libs/hana/test/core/to.cpp | 106 ++ src/boost/libs/hana/test/core/when.cpp | 24 + src/boost/libs/hana/test/deploy/CMakeLists.txt | 10 + src/boost/libs/hana/test/deploy/main.cpp | 8 + src/boost/libs/hana/test/detail/algorithm.cpp | 56 + src/boost/libs/hana/test/detail/any_of.cpp | 45 + .../hana/test/detail/canonical_constant/laws.cpp | 56 + src/boost/libs/hana/test/detail/create.cpp | 38 + src/boost/libs/hana/test/detail/decay.cpp | 54 + src/boost/libs/hana/test/detail/ebo.cpp | 95 ++ src/boost/libs/hana/test/detail/fast_and.cpp | 32 + .../hana/test/detail/first_unsatisfied_index.cpp | 47 + src/boost/libs/hana/test/detail/has_duplicates.cpp | 57 + src/boost/libs/hana/test/detail/preprocessor.cpp | 65 ++ src/boost/libs/hana/test/detail/struct_macros.cpp | 108 ++ src/boost/libs/hana/test/detail/type_at.cpp | 102 ++ src/boost/libs/hana/test/detail/type_foldl1.cpp | 64 ++ src/boost/libs/hana/test/detail/type_foldr1.cpp | 64 ++ src/boost/libs/hana/test/detail/unpack_flatten.cpp | 114 ++ src/boost/libs/hana/test/detail/variadic/at.cpp | 93 ++ .../libs/hana/test/detail/variadic/drop_into.cpp | 78 ++ .../libs/hana/test/detail/variadic/foldl1.cpp | 212 ++++ .../libs/hana/test/detail/variadic/foldr1.cpp | 207 ++++ .../hana/test/detail/variadic/reverse_apply.cpp | 70 ++ .../libs/hana/test/detail/variadic/split_at.cpp | 168 +++ src/boost/libs/hana/test/detail/variadic/take.cpp | 62 ++ src/boost/libs/hana/test/euclidean_ring.cpp | 28 + .../libs/hana/test/experimental/printable/map.cpp | 51 + .../test/experimental/printable/metafunction.cpp | 45 + .../hana/test/experimental/printable/optional.cpp | 29 + .../libs/hana/test/experimental/printable/pair.cpp | 38 + .../libs/hana/test/experimental/printable/set.cpp | 48 + .../hana/test/experimental/printable/string.cpp | 45 + .../hana/test/experimental/printable/tuple.cpp | 50 + .../libs/hana/test/experimental/printable/type.cpp | 35 + .../libs/hana/test/experimental/type_name.cpp | 50 + src/boost/libs/hana/test/experimental/types/at.cpp | 80 ++ .../libs/hana/test/experimental/types/contains.cpp | 81 ++ .../hana/test/experimental/types/drop_front.cpp | 100 ++ .../libs/hana/test/experimental/types/equal.cpp | 59 ++ .../libs/hana/test/experimental/types/is_empty.cpp | 34 + .../hana/test/experimental/types/transform.cpp | 74 ++ .../libs/hana/test/experimental/types/unpack.cpp | 83 ++ .../hana/test/experimental/view/empty/is_empty.cpp | 16 + .../hana/test/experimental/view/empty/length.cpp | 21 + .../hana/test/experimental/view/empty/unpack.cpp | 24 + .../libs/hana/test/experimental/view/joined/at.cpp | 97 ++ .../test/experimental/view/joined/is_empty.cpp | 43 + .../hana/test/experimental/view/joined/length.cpp | 89 ++ .../hana/test/experimental/view/joined/unpack.cpp | 81 ++ .../libs/hana/test/experimental/view/single/at.cpp | 24 + .../test/experimental/view/single/is_empty.cpp | 19 + .../hana/test/experimental/view/single/length.cpp | 23 + .../hana/test/experimental/view/single/unpack.cpp | 25 + .../libs/hana/test/experimental/view/sliced/at.cpp | 91 ++ .../test/experimental/view/sliced/is_empty.cpp | 49 + .../hana/test/experimental/view/sliced/length.cpp | 68 ++ .../hana/test/experimental/view/sliced/unpack.cpp | 135 +++ .../hana/test/experimental/view/transformed/ap.cpp | 122 +++ .../hana/test/experimental/view/transformed/at.cpp | 73 ++ .../experimental/view/transformed/drop_front.cpp | 98 ++ .../test/experimental/view/transformed/equal.cpp | 50 + .../experimental/view/transformed/is_empty.cpp | 36 + .../experimental/view/transformed/laziness.cpp | 20 + .../test/experimental/view/transformed/length.cpp | 49 + .../test/experimental/view/transformed/less.cpp | 58 + .../experimental/view/transformed/transform.cpp | 57 + .../test/experimental/view/transformed/unpack.cpp | 34 + .../test/ext/boost/fusion/deque/auto/_specs.hpp | 18 + .../test/ext/boost/fusion/deque/auto/all_of.cpp | 8 + .../test/ext/boost/fusion/deque/auto/any_of.cpp | 8 + .../hana/test/ext/boost/fusion/deque/auto/ap.cpp | 8 + .../hana/test/ext/boost/fusion/deque/auto/at.cpp | 8 + .../boost/fusion/deque/auto/cartesian_product.cpp | 8 + .../test/ext/boost/fusion/deque/auto/drop_back.cpp | 8 + .../ext/boost/fusion/deque/auto/drop_front.cpp | 8 + .../ext/boost/fusion/deque/auto/drop_while.cpp | 8 + .../test/ext/boost/fusion/deque/auto/for_each.cpp | 8 + .../test/ext/boost/fusion/deque/auto/group.cpp | 8 + .../test/ext/boost/fusion/deque/auto/index_if.cpp | 9 + .../test/ext/boost/fusion/deque/auto/insert.cpp | 8 + .../ext/boost/fusion/deque/auto/insert_range.cpp | 8 + .../ext/boost/fusion/deque/auto/intersperse.cpp | 8 + .../test/ext/boost/fusion/deque/auto/is_empty.cpp | 8 + .../test/ext/boost/fusion/deque/auto/length.cpp | 8 + .../fusion/deque/auto/lexicographical_compare.cpp | 8 + .../hana/test/ext/boost/fusion/deque/auto/make.cpp | 8 + .../test/ext/boost/fusion/deque/auto/none_of.cpp | 8 + .../test/ext/boost/fusion/deque/auto/partition.cpp | 8 + .../ext/boost/fusion/deque/auto/permutations.cpp | 8 + .../test/ext/boost/fusion/deque/auto/remove_at.cpp | 8 + .../ext/boost/fusion/deque/auto/remove_range.cpp | 8 + .../test/ext/boost/fusion/deque/auto/reverse.cpp | 8 + .../test/ext/boost/fusion/deque/auto/scans.cpp | 8 + .../test/ext/boost/fusion/deque/auto/sequence.cpp | 8 + .../test/ext/boost/fusion/deque/auto/slice.cpp | 8 + .../hana/test/ext/boost/fusion/deque/auto/sort.cpp | 8 + .../hana/test/ext/boost/fusion/deque/auto/span.cpp | 8 + .../test/ext/boost/fusion/deque/auto/take_back.cpp | 8 + .../ext/boost/fusion/deque/auto/take_front.cpp | 8 + .../ext/boost/fusion/deque/auto/take_while.cpp | 8 + .../test/ext/boost/fusion/deque/auto/transform.cpp | 8 + .../test/ext/boost/fusion/deque/auto/unfolds.cpp | 8 + .../test/ext/boost/fusion/deque/auto/unique.cpp | 8 + .../hana/test/ext/boost/fusion/deque/auto/zips.cpp | 8 + .../test/ext/boost/fusion/list/auto/_specs.hpp | 18 + .../test/ext/boost/fusion/list/auto/all_of.cpp | 8 + .../test/ext/boost/fusion/list/auto/any_of.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/ap.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/at.cpp | 8 + .../boost/fusion/list/auto/cartesian_product.cpp | 8 + .../test/ext/boost/fusion/list/auto/drop_back.cpp | 8 + .../test/ext/boost/fusion/list/auto/drop_front.cpp | 8 + .../test/ext/boost/fusion/list/auto/drop_while.cpp | 8 + .../test/ext/boost/fusion/list/auto/for_each.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/group.cpp | 8 + .../test/ext/boost/fusion/list/auto/index_if.cpp | 9 + .../test/ext/boost/fusion/list/auto/insert.cpp | 8 + .../ext/boost/fusion/list/auto/insert_range.cpp | 8 + .../ext/boost/fusion/list/auto/intersperse.cpp | 8 + .../test/ext/boost/fusion/list/auto/is_empty.cpp | 8 + .../test/ext/boost/fusion/list/auto/length.cpp | 8 + .../fusion/list/auto/lexicographical_compare.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/make.cpp | 8 + .../test/ext/boost/fusion/list/auto/none_of.cpp | 8 + .../test/ext/boost/fusion/list/auto/partition.cpp | 8 + .../ext/boost/fusion/list/auto/permutations.cpp | 8 + .../test/ext/boost/fusion/list/auto/remove_at.cpp | 8 + .../ext/boost/fusion/list/auto/remove_range.cpp | 8 + .../test/ext/boost/fusion/list/auto/reverse.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/scans.cpp | 8 + .../test/ext/boost/fusion/list/auto/sequence.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/slice.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/sort.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/span.cpp | 8 + .../test/ext/boost/fusion/list/auto/take_back.cpp | 8 + .../test/ext/boost/fusion/list/auto/take_front.cpp | 8 + .../test/ext/boost/fusion/list/auto/take_while.cpp | 8 + .../test/ext/boost/fusion/list/auto/transform.cpp | 8 + .../test/ext/boost/fusion/list/auto/unfolds.cpp | 8 + .../test/ext/boost/fusion/list/auto/unique.cpp | 8 + .../hana/test/ext/boost/fusion/list/auto/zips.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/_specs.hpp | 19 + .../test/ext/boost/fusion/tuple/auto/all_of.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/any_of.cpp | 8 + .../hana/test/ext/boost/fusion/tuple/auto/ap.cpp | 8 + .../hana/test/ext/boost/fusion/tuple/auto/at.cpp | 8 + .../boost/fusion/tuple/auto/cartesian_product.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/drop_back.cpp | 8 + .../ext/boost/fusion/tuple/auto/drop_front.cpp | 8 + .../ext/boost/fusion/tuple/auto/drop_while.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/for_each.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/group.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/index_if.cpp | 9 + .../test/ext/boost/fusion/tuple/auto/insert.cpp | 8 + .../ext/boost/fusion/tuple/auto/insert_range.cpp | 8 + .../ext/boost/fusion/tuple/auto/intersperse.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/is_empty.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/length.cpp | 8 + .../fusion/tuple/auto/lexicographical_compare.cpp | 8 + .../hana/test/ext/boost/fusion/tuple/auto/make.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/none_of.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/partition.cpp | 8 + .../ext/boost/fusion/tuple/auto/permutations.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/remove_at.cpp | 8 + .../ext/boost/fusion/tuple/auto/remove_range.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/reverse.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/scans.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/sequence.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/slice.cpp | 8 + .../hana/test/ext/boost/fusion/tuple/auto/sort.cpp | 8 + .../hana/test/ext/boost/fusion/tuple/auto/span.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/take_back.cpp | 8 + .../ext/boost/fusion/tuple/auto/take_front.cpp | 8 + .../ext/boost/fusion/tuple/auto/take_while.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/transform.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/unfolds.cpp | 8 + .../test/ext/boost/fusion/tuple/auto/unique.cpp | 8 + .../hana/test/ext/boost/fusion/tuple/auto/zips.cpp | 8 + .../test/ext/boost/fusion/vector/auto/_specs.hpp | 19 + .../test/ext/boost/fusion/vector/auto/all_of.cpp | 8 + .../test/ext/boost/fusion/vector/auto/any_of.cpp | 8 + .../hana/test/ext/boost/fusion/vector/auto/ap.cpp | 8 + .../hana/test/ext/boost/fusion/vector/auto/at.cpp | 8 + .../boost/fusion/vector/auto/cartesian_product.cpp | 8 + .../ext/boost/fusion/vector/auto/drop_back.cpp | 8 + .../ext/boost/fusion/vector/auto/drop_front.cpp | 8 + .../ext/boost/fusion/vector/auto/drop_while.cpp | 8 + .../test/ext/boost/fusion/vector/auto/for_each.cpp | 8 + .../test/ext/boost/fusion/vector/auto/group.cpp | 8 + .../test/ext/boost/fusion/vector/auto/index_if.cpp | 9 + .../test/ext/boost/fusion/vector/auto/insert.cpp | 8 + .../ext/boost/fusion/vector/auto/insert_range.cpp | 8 + .../ext/boost/fusion/vector/auto/intersperse.cpp | 8 + .../test/ext/boost/fusion/vector/auto/is_empty.cpp | 8 + .../test/ext/boost/fusion/vector/auto/length.cpp | 8 + .../fusion/vector/auto/lexicographical_compare.cpp | 8 + .../test/ext/boost/fusion/vector/auto/make.cpp | 8 + .../test/ext/boost/fusion/vector/auto/none_of.cpp | 8 + .../ext/boost/fusion/vector/auto/partition.cpp | 8 + .../ext/boost/fusion/vector/auto/permutations.cpp | 8 + .../ext/boost/fusion/vector/auto/remove_at.cpp | 8 + .../ext/boost/fusion/vector/auto/remove_range.cpp | 8 + .../test/ext/boost/fusion/vector/auto/reverse.cpp | 8 + .../test/ext/boost/fusion/vector/auto/scans.cpp | 8 + .../test/ext/boost/fusion/vector/auto/sequence.cpp | 8 + .../test/ext/boost/fusion/vector/auto/slice.cpp | 8 + .../test/ext/boost/fusion/vector/auto/sort.cpp | 8 + .../test/ext/boost/fusion/vector/auto/span.cpp | 8 + .../ext/boost/fusion/vector/auto/take_back.cpp | 8 + .../ext/boost/fusion/vector/auto/take_front.cpp | 8 + .../ext/boost/fusion/vector/auto/take_while.cpp | 8 + .../ext/boost/fusion/vector/auto/transform.cpp | 8 + .../test/ext/boost/fusion/vector/auto/unfolds.cpp | 8 + .../test/ext/boost/fusion/vector/auto/unique.cpp | 8 + .../test/ext/boost/fusion/vector/auto/zips.cpp | 8 + .../test/ext/boost/mpl/integral_c/arithmetic.cpp | 30 + .../test/ext/boost/mpl/integral_c/comparable.cpp | 26 + .../test/ext/boost/mpl/integral_c/constant.cpp | 32 + .../hana/test/ext/boost/mpl/integral_c/interop.cpp | 23 + .../hana/test/ext/boost/mpl/integral_c/logical.cpp | 66 ++ .../test/ext/boost/mpl/integral_c/orderable.cpp | 24 + .../hana/test/ext/boost/mpl/integral_c/tag.cpp | 52 + .../hana/test/ext/boost/mpl/list/comparable.cpp | 28 + .../libs/hana/test/ext/boost/mpl/list/foldable.cpp | 57 + .../libs/hana/test/ext/boost/mpl/list/iterable.cpp | 95 ++ .../hana/test/ext/boost/mpl/list/searchable.cpp | 30 + .../libs/hana/test/ext/boost/mpl/list/tag.cpp | 62 ++ src/boost/libs/hana/test/ext/boost/mpl/list/to.cpp | 49 + .../hana/test/ext/boost/mpl/vector/comparable.cpp | 28 + .../hana/test/ext/boost/mpl/vector/foldable.cpp | 57 + .../hana/test/ext/boost/mpl/vector/iterable.cpp | 95 ++ .../hana/test/ext/boost/mpl/vector/searchable.cpp | 30 + .../libs/hana/test/ext/boost/mpl/vector/tag.cpp | 62 ++ .../libs/hana/test/ext/boost/mpl/vector/to.cpp | 49 + .../libs/hana/test/ext/boost/tuple/auto/_specs.hpp | 18 + .../libs/hana/test/ext/boost/tuple/auto/all_of.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/any_of.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/ap.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/at.cpp | 8 + .../ext/boost/tuple/auto/cartesian_product.cpp | 8 + .../hana/test/ext/boost/tuple/auto/drop_back.cpp | 8 + .../hana/test/ext/boost/tuple/auto/drop_front.cpp | 8 + .../hana/test/ext/boost/tuple/auto/drop_while.cpp | 8 + .../hana/test/ext/boost/tuple/auto/for_each.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/group.cpp | 8 + .../hana/test/ext/boost/tuple/auto/index_if.cpp | 9 + .../libs/hana/test/ext/boost/tuple/auto/insert.cpp | 8 + .../test/ext/boost/tuple/auto/insert_range.cpp | 8 + .../ext/boost/tuple/auto/intersperse.broken.cpp | 10 + .../hana/test/ext/boost/tuple/auto/is_empty.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/length.cpp | 8 + .../boost/tuple/auto/lexicographical_compare.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/make.cpp | 8 + .../hana/test/ext/boost/tuple/auto/none_of.cpp | 8 + .../hana/test/ext/boost/tuple/auto/partition.cpp | 8 + .../ext/boost/tuple/auto/permutations.broken.cpp | 10 + .../hana/test/ext/boost/tuple/auto/remove_at.cpp | 8 + .../test/ext/boost/tuple/auto/remove_range.cpp | 8 + .../hana/test/ext/boost/tuple/auto/reverse.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/scans.cpp | 8 + .../hana/test/ext/boost/tuple/auto/sequence.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/slice.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/sort.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/span.cpp | 8 + .../hana/test/ext/boost/tuple/auto/take_back.cpp | 8 + .../ext/boost/tuple/auto/take_front.broken.cpp | 10 + .../hana/test/ext/boost/tuple/auto/take_while.cpp | 8 + .../hana/test/ext/boost/tuple/auto/transform.cpp | 8 + .../hana/test/ext/boost/tuple/auto/unfolds.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/unique.cpp | 8 + .../libs/hana/test/ext/boost/tuple/auto/zips.cpp | 8 + .../libs/hana/test/ext/boost/tuple/iterable.cpp | 36 + src/boost/libs/hana/test/ext/boost/tuple/monad.cpp | 52 + .../libs/hana/test/ext/boost/tuple/monad_plus.cpp | 42 + .../libs/hana/test/ext/boost/tuple/orderable.cpp | 47 + .../libs/hana/test/ext/boost/tuple/searchable.cpp | 54 + .../libs/hana/test/ext/boost/tuple/tag_of.cpp | 63 ++ src/boost/libs/hana/test/ext/std/array/at.cpp | 43 + .../libs/hana/test/ext/std/array/comparable.cpp | 29 + .../libs/hana/test/ext/std/array/foldable.cpp | 29 + .../libs/hana/test/ext/std/array/issue_304.cpp | 21 + .../libs/hana/test/ext/std/array/iterable.cpp | 83 ++ .../libs/hana/test/ext/std/array/orderable.cpp | 29 + .../libs/hana/test/ext/std/array/searchable.cpp | 31 + .../libs/hana/test/ext/std/bugs/libcxx_19616.cpp | 21 + .../libs/hana/test/ext/std/bugs/libcxx_22806.cpp | 21 + .../std/integer_sequence/drop_front_exactly.cpp | 44 + .../hana/test/ext/std/integer_sequence/equal.cpp | 52 + .../hana/test/ext/std/integer_sequence/find_if.cpp | 101 ++ .../hana/test/ext/std/integer_sequence/front.cpp | 31 + .../test/ext/std/integer_sequence/is_empty.cpp | 18 + .../hana/test/ext/std/integer_sequence/laws.cpp | 37 + .../hana/test/ext/std/integer_sequence/unpack.cpp | 47 + .../test/ext/std/integral_constant/arithmetic.cpp | 31 + .../test/ext/std/integral_constant/comparable.cpp | 27 + .../test/ext/std/integral_constant/constant.cpp | 33 + .../test/ext/std/integral_constant/interop.cpp | 22 + .../test/ext/std/integral_constant/logical.cpp | 63 ++ .../test/ext/std/integral_constant/orderable.cpp | 25 + .../hana/test/ext/std/integral_constant/tag.cpp | 53 + .../libs/hana/test/ext/std/pair/first_second.cpp | 30 + src/boost/libs/hana/test/ext/std/pair/issue_90.cpp | 44 + src/boost/libs/hana/test/ext/std/pair/laws.cpp | 41 + src/boost/libs/hana/test/ext/std/pair/make.cpp | 26 + src/boost/libs/hana/test/ext/std/ratio/div.cpp | 24 + src/boost/libs/hana/test/ext/std/ratio/equal.cpp | 34 + src/boost/libs/hana/test/ext/std/ratio/laws.cpp | 37 + src/boost/libs/hana/test/ext/std/ratio/less.cpp | 29 + src/boost/libs/hana/test/ext/std/ratio/minus.cpp | 19 + src/boost/libs/hana/test/ext/std/ratio/mod.cpp | 24 + src/boost/libs/hana/test/ext/std/ratio/mult.cpp | 19 + src/boost/libs/hana/test/ext/std/ratio/one.cpp | 24 + src/boost/libs/hana/test/ext/std/ratio/plus.cpp | 19 + src/boost/libs/hana/test/ext/std/ratio/to.cpp | 36 + src/boost/libs/hana/test/ext/std/ratio/zero.cpp | 24 + .../libs/hana/test/ext/std/tuple/auto/_specs.hpp | 17 + .../libs/hana/test/ext/std/tuple/auto/all_of.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/any_of.cpp | 8 + src/boost/libs/hana/test/ext/std/tuple/auto/ap.cpp | 8 + src/boost/libs/hana/test/ext/std/tuple/auto/at.cpp | 8 + .../test/ext/std/tuple/auto/cartesian_product.cpp | 8 + .../hana/test/ext/std/tuple/auto/drop_back.cpp | 8 + .../hana/test/ext/std/tuple/auto/drop_front.cpp | 8 + .../hana/test/ext/std/tuple/auto/drop_while.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/for_each.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/group.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/index_if.cpp | 9 + .../libs/hana/test/ext/std/tuple/auto/insert.cpp | 8 + .../hana/test/ext/std/tuple/auto/insert_range.cpp | 8 + .../hana/test/ext/std/tuple/auto/intersperse.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/is_empty.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/length.cpp | 8 + .../ext/std/tuple/auto/lexicographical_compare.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/make.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/none_of.cpp | 8 + .../hana/test/ext/std/tuple/auto/partition.cpp | 8 + .../hana/test/ext/std/tuple/auto/permutations.cpp | 8 + .../hana/test/ext/std/tuple/auto/remove_at.cpp | 8 + .../hana/test/ext/std/tuple/auto/remove_range.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/reverse.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/scans.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/sequence.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/slice.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/sort.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/span.cpp | 8 + .../hana/test/ext/std/tuple/auto/take_back.cpp | 8 + .../hana/test/ext/std/tuple/auto/take_front.cpp | 8 + .../hana/test/ext/std/tuple/auto/take_while.cpp | 8 + .../hana/test/ext/std/tuple/auto/transform.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/unfolds.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/unique.cpp | 8 + .../libs/hana/test/ext/std/tuple/auto/zips.cpp | 8 + .../libs/hana/test/ext/std/tuple/issue_90.cpp | 73 ++ src/boost/libs/hana/test/ext/std/tuple/laws.cpp | 43 + .../libs/hana/test/ext/std/tuple/laws.functor.cpp | 55 + .../hana/test/ext/std/tuple/laws.searchable.cpp | 38 + src/boost/libs/hana/test/ext/std/vector.cpp | 44 + src/boost/libs/hana/test/fold_left/ref.cpp | 40 + src/boost/libs/hana/test/fold_right/ref.cpp | 39 + .../hana/test/foldable/fold_left_mcd/iterable.cpp | 7 + .../hana/test/foldable/fold_left_mcd/monad.cpp | 7 + .../test/foldable/fold_left_mcd/monad_plus.cpp | 7 + .../hana/test/foldable/fold_left_mcd/orderable.cpp | 7 + .../test/foldable/fold_left_mcd/searchable.cpp | 7 + .../hana/test/foldable/fold_left_mcd/sequence.cpp | 7 + .../hana/test/foldable/iterable_mcd/iterable.cpp | 7 + .../libs/hana/test/foldable/iterable_mcd/monad.cpp | 7 + .../hana/test/foldable/iterable_mcd/monad_plus.cpp | 7 + .../hana/test/foldable/iterable_mcd/orderable.cpp | 7 + .../hana/test/foldable/iterable_mcd/searchable.cpp | 7 + .../hana/test/foldable/iterable_mcd/sequence.cpp | 7 + .../hana/test/foldable/unpack_mcd/iterable.cpp | 7 + .../libs/hana/test/foldable/unpack_mcd/monad.cpp | 7 + .../hana/test/foldable/unpack_mcd/monad_plus.cpp | 7 + .../hana/test/foldable/unpack_mcd/orderable.cpp | 7 + .../hana/test/foldable/unpack_mcd/searchable.cpp | 7 + .../hana/test/foldable/unpack_mcd/sequence.cpp | 7 + src/boost/libs/hana/test/functional.cpp | 503 +++++++++ src/boost/libs/hana/test/functional/apply.cpp | 262 +++++ src/boost/libs/hana/test/functional/capture.cpp | 100 ++ src/boost/libs/hana/test/functional/demux.cpp | 64 ++ src/boost/libs/hana/test/functional/fix.cpp | 41 + src/boost/libs/hana/test/functional/iterate.cpp | 151 +++ src/boost/libs/hana/test/functional/lockstep.cpp | 36 + .../hana/test/functional/overload_linearly.cpp | 122 +++ src/boost/libs/hana/test/functional/partial.cpp | 64 ++ .../libs/hana/test/functional/placeholder.cpp | 119 +++ .../libs/hana/test/functional/reverse_partial.cpp | 65 ++ src/boost/libs/hana/test/group.cpp | 24 + .../hana/test/identity/applicative.full_mcd.cpp | 6 + .../hana/test/identity/applicative.monad_mcd.cpp | 6 + .../libs/hana/test/identity/functor.adjust_mcd.cpp | 6 + .../hana/test/identity/functor.transform_mcd.cpp | 6 + src/boost/libs/hana/test/identity/main.hpp | 150 +++ .../libs/hana/test/identity/monad.chain_mcd.cpp | 6 + .../libs/hana/test/identity/monad.flatten_mcd.cpp | 6 + src/boost/libs/hana/test/if_/non_copyable.cpp | 53 + src/boost/libs/hana/test/index_if.cpp | 31 + .../hana/test/integral_constant/arithmetic.cpp | 29 + .../hana/test/integral_constant/comparable.cpp | 23 + .../libs/hana/test/integral_constant/constant.cpp | 38 + .../hana/test/integral_constant/constexpr_init.cpp | 50 + .../hana/test/integral_constant/github_354.cpp | 20 + .../libs/hana/test/integral_constant/hash.cpp | 110 ++ .../libs/hana/test/integral_constant/hashable.cpp | 26 + .../libs/hana/test/integral_constant/logical.cpp | 55 + .../libs/hana/test/integral_constant/operators.cpp | 57 + .../libs/hana/test/integral_constant/orderable.cpp | 23 + .../libs/hana/test/integral_constant/std_api.cpp | 44 + src/boost/libs/hana/test/integral_constant/tag.cpp | 26 + .../libs/hana/test/integral_constant/times.cpp | 61 ++ src/boost/libs/hana/test/integral_constant/udl.cpp | 75 ++ src/boost/libs/hana/test/issues/clang_20046.cpp | 20 + src/boost/libs/hana/test/issues/github_112.cpp | 29 + src/boost/libs/hana/test/issues/github_113.cpp | 22 + src/boost/libs/hana/test/issues/github_149.cpp | 12 + src/boost/libs/hana/test/issues/github_15.cpp | 21 + src/boost/libs/hana/test/issues/github_165.cpp | 34 + src/boost/libs/hana/test/issues/github_202.cpp | 26 + src/boost/libs/hana/test/issues/github_221.cpp | 452 ++++++++ src/boost/libs/hana/test/issues/github_234.cpp | 31 + src/boost/libs/hana/test/issues/github_252.cpp | 38 + src/boost/libs/hana/test/issues/github_260.cpp | 35 + src/boost/libs/hana/test/issues/github_266.cpp | 17 + src/boost/libs/hana/test/issues/github_269.cpp | 35 + src/boost/libs/hana/test/issues/github_297.cpp | 22 + src/boost/libs/hana/test/issues/github_31.cpp | 53 + src/boost/libs/hana/test/issues/github_331.cpp | 57 + src/boost/libs/hana/test/issues/github_362.cpp | 13 + src/boost/libs/hana/test/issues/github_365.cpp | 61 ++ src/boost/libs/hana/test/issues/github_75/tu1.cpp | 7 + src/boost/libs/hana/test/issues/github_75/tu2.cpp | 5 + src/boost/libs/hana/test/issues/github_91.cpp | 24 + src/boost/libs/hana/test/lazy.cpp | 342 ++++++ src/boost/libs/hana/test/logical.cpp | 84 ++ src/boost/libs/hana/test/map/any_of.cpp | 52 + src/boost/libs/hana/test/map/assign.copy.cpp | 57 + src/boost/libs/hana/test/map/assign.move.cpp | 92 ++ src/boost/libs/hana/test/map/at_key.collisions.cpp | 149 +++ src/boost/libs/hana/test/map/at_key.cpp | 60 ++ src/boost/libs/hana/test/map/at_key.ref.cpp | 84 ++ .../libs/hana/test/map/at_key.stackoverflow.cpp | 38 + src/boost/libs/hana/test/map/cnstr.copy.cpp | 114 ++ src/boost/libs/hana/test/map/cnstr.default.cpp | 74 ++ src/boost/libs/hana/test/map/cnstr.move.cpp | 123 +++ src/boost/libs/hana/test/map/cnstr.trap.cpp | 72 ++ src/boost/libs/hana/test/map/cnstr.variadic.cpp | 186 ++++ src/boost/libs/hana/test/map/contains.cpp | 117 +++ src/boost/libs/hana/test/map/difference.cpp | 106 ++ src/boost/libs/hana/test/map/equal.cpp | 97 ++ src/boost/libs/hana/test/map/erase_key.cpp | 70 ++ src/boost/libs/hana/test/map/find_if.cpp | 52 + src/boost/libs/hana/test/map/fold_left.cpp | 58 + src/boost/libs/hana/test/map/fold_right.cpp | 58 + src/boost/libs/hana/test/map/insert.cpp | 68 ++ src/boost/libs/hana/test/map/intersection.cpp | 99 ++ src/boost/libs/hana/test/map/is_subset.cpp | 51 + src/boost/libs/hana/test/map/keys.cpp | 49 + src/boost/libs/hana/test/map/laws.cpp | 37 + src/boost/libs/hana/test/map/map.cpp | 33 + .../libs/hana/test/map/symmetric_difference.cpp | 80 ++ src/boost/libs/hana/test/map/to.cpp | 92 ++ src/boost/libs/hana/test/map/union.cpp | 82 ++ src/boost/libs/hana/test/map/unpack.cpp | 50 + src/boost/libs/hana/test/map/values.cpp | 48 + src/boost/libs/hana/test/minimal_product.cpp | 55 + src/boost/libs/hana/test/monoid.cpp | 26 + src/boost/libs/hana/test/numeric/main.hpp | 511 +++++++++ src/boost/libs/hana/test/numeric/minus_mcd.cpp | 6 + src/boost/libs/hana/test/numeric/negate_mcd.cpp | 6 + src/boost/libs/hana/test/optional/any_of.cpp | 23 + src/boost/libs/hana/test/optional/ap.cpp | 34 + src/boost/libs/hana/test/optional/chain.cpp | 40 + src/boost/libs/hana/test/optional/concat.cpp | 55 + .../hana/test/optional/copy.trap_construct.cpp | 21 + src/boost/libs/hana/test/optional/empty.cpp | 17 + src/boost/libs/hana/test/optional/equal.cpp | 30 + src/boost/libs/hana/test/optional/find_if.cpp | 38 + src/boost/libs/hana/test/optional/flatten.cpp | 28 + src/boost/libs/hana/test/optional/fold_left.cpp | 28 + src/boost/libs/hana/test/optional/fold_right.cpp | 28 + src/boost/libs/hana/test/optional/is_just.cpp | 16 + src/boost/libs/hana/test/optional/is_nothing.cpp | 17 + src/boost/libs/hana/test/optional/laws.cpp | 72 ++ src/boost/libs/hana/test/optional/less.cpp | 52 + src/boost/libs/hana/test/optional/lift.cpp | 20 + src/boost/libs/hana/test/optional/make.cpp | 36 + src/boost/libs/hana/test/optional/maybe.cpp | 28 + src/boost/libs/hana/test/optional/nested_type.cpp | 33 + .../libs/hana/test/optional/operator_arrow.cpp | 37 + .../libs/hana/test/optional/operator_deref.cpp | 33 + .../libs/hana/test/optional/representation.cpp | 19 + src/boost/libs/hana/test/optional/sfinae.cpp | 71 ++ src/boost/libs/hana/test/optional/transform.cpp | 29 + src/boost/libs/hana/test/optional/unpack.cpp | 34 + src/boost/libs/hana/test/optional/value.cpp | 33 + src/boost/libs/hana/test/optional/value_or.cpp | 26 + src/boost/libs/hana/test/orderable.cpp | 126 +++ src/boost/libs/hana/test/pair/assign.copy.cpp | 40 + src/boost/libs/hana/test/pair/assign.move.cpp | 70 ++ src/boost/libs/hana/test/pair/cnstr.copy.cpp | 94 ++ src/boost/libs/hana/test/pair/cnstr.default.cpp | 71 ++ src/boost/libs/hana/test/pair/cnstr.memberwise.cpp | 87 ++ src/boost/libs/hana/test/pair/cnstr.move.cpp | 97 ++ src/boost/libs/hana/test/pair/comparable.cpp | 33 + src/boost/libs/hana/test/pair/empty_storage.cpp | 34 + src/boost/libs/hana/test/pair/foldable.cpp | 31 + src/boost/libs/hana/test/pair/issue_90.cpp | 43 + src/boost/libs/hana/test/pair/make.cpp | 57 + src/boost/libs/hana/test/pair/orderable.cpp | 46 + src/boost/libs/hana/test/pair/product.cpp | 29 + src/boost/libs/hana/test/pair/tag_of.cpp | 36 + src/boost/libs/hana/test/range/at.cpp | 36 + src/boost/libs/hana/test/range/back.cpp | 31 + src/boost/libs/hana/test/range/contains.cpp | 56 + src/boost/libs/hana/test/range/drop_front.cpp | 75 ++ .../libs/hana/test/range/drop_front_exactly.cpp | 63 ++ src/boost/libs/hana/test/range/equal.cpp | 65 ++ src/boost/libs/hana/test/range/find.cpp | 57 + src/boost/libs/hana/test/range/front.cpp | 36 + src/boost/libs/hana/test/range/is_empty.cpp | 26 + src/boost/libs/hana/test/range/laws.cpp | 38 + src/boost/libs/hana/test/range/length.cpp | 35 + src/boost/libs/hana/test/range/make.cpp | 21 + src/boost/libs/hana/test/range/maximum.cpp | 27 + src/boost/libs/hana/test/range/minimum.cpp | 27 + src/boost/libs/hana/test/range/product.cpp | 85 ++ src/boost/libs/hana/test/range/range_c.cpp | 40 + src/boost/libs/hana/test/range/sum.cpp | 85 ++ src/boost/libs/hana/test/range/unpack.cpp | 45 + src/boost/libs/hana/test/repeat.cpp | 45 + src/boost/libs/hana/test/ring.cpp | 24 + src/boost/libs/hana/test/searchable.cpp | 44 + src/boost/libs/hana/test/set/any_of.cpp | 43 + src/boost/libs/hana/test/set/cnstr.copy.cpp | 52 + src/boost/libs/hana/test/set/cnstr.default.cpp | 77 ++ src/boost/libs/hana/test/set/cnstr.move.cpp | 63 ++ src/boost/libs/hana/test/set/cnstr.trap.cpp | 67 ++ src/boost/libs/hana/test/set/difference.cpp | 67 ++ src/boost/libs/hana/test/set/equal.cpp | 56 + src/boost/libs/hana/test/set/erase_key.cpp | 62 ++ src/boost/libs/hana/test/set/find_if.cpp | 50 + src/boost/libs/hana/test/set/insert.cpp | 45 + src/boost/libs/hana/test/set/intersection.cpp | 90 ++ src/boost/libs/hana/test/set/is_subset.cpp | 45 + src/boost/libs/hana/test/set/laws.cpp | 33 + src/boost/libs/hana/test/set/make.cpp | 34 + .../libs/hana/test/set/symmetric_difference.cpp | 67 ++ src/boost/libs/hana/test/set/to.cpp | 84 ++ src/boost/libs/hana/test/set/union.cpp | 84 ++ src/boost/libs/hana/test/set/unpack.cpp | 38 + src/boost/libs/hana/test/string/any_of.cpp | 29 + src/boost/libs/hana/test/string/at.cpp | 53 + src/boost/libs/hana/test/string/c_str.cpp | 51 + src/boost/libs/hana/test/string/cnstr.c_str.cpp | 59 ++ src/boost/libs/hana/test/string/cnstr.copy.cpp | 16 + src/boost/libs/hana/test/string/cnstr.default.cpp | 13 + src/boost/libs/hana/test/string/contains.cpp | 32 + .../libs/hana/test/string/drop_front_exactly.cpp | 44 + src/boost/libs/hana/test/string/equal.cpp | 52 + src/boost/libs/hana/test/string/find.cpp | 29 + src/boost/libs/hana/test/string/find_if.cpp | 36 + src/boost/libs/hana/test/string/front.cpp | 28 + src/boost/libs/hana/test/string/hash.cpp | 33 + src/boost/libs/hana/test/string/is_empty.cpp | 21 + src/boost/libs/hana/test/string/laws.cpp | 95 ++ src/boost/libs/hana/test/string/length.cpp | 30 + src/boost/libs/hana/test/string/less.cpp | 65 ++ src/boost/libs/hana/test/string/macro.cpp | 31 + src/boost/libs/hana/test/string/make.cpp | 39 + src/boost/libs/hana/test/string/plus.cpp | 35 + src/boost/libs/hana/test/string/to.cpp | 47 + src/boost/libs/hana/test/string/udl.cpp | 24 + src/boost/libs/hana/test/string/unpack.cpp | 42 + src/boost/libs/hana/test/string/zero.cpp | 17 + .../libs/hana/test/tuple/any_of.clang_ice.cpp | 19 + .../libs/hana/test/tuple/assign.convert_copy.cpp | 59 ++ .../libs/hana/test/tuple/assign.convert_move.cpp | 73 ++ src/boost/libs/hana/test/tuple/assign.copy.cpp | 43 + src/boost/libs/hana/test/tuple/assign.move.cpp | 58 + src/boost/libs/hana/test/tuple/at.const.cpp | 50 + src/boost/libs/hana/test/tuple/at.non_const.cpp | 81 ++ src/boost/libs/hana/test/tuple/at.rv.cpp | 40 + src/boost/libs/hana/test/tuple/auto/_specs.hpp | 15 + src/boost/libs/hana/test/tuple/auto/all_of.cpp | 8 + src/boost/libs/hana/test/tuple/auto/any_of.cpp | 8 + src/boost/libs/hana/test/tuple/auto/ap.cpp | 8 + src/boost/libs/hana/test/tuple/auto/at.cpp | 8 + .../hana/test/tuple/auto/cartesian_product.cpp | 8 + src/boost/libs/hana/test/tuple/auto/drop_back.cpp | 8 + src/boost/libs/hana/test/tuple/auto/drop_front.cpp | 8 + src/boost/libs/hana/test/tuple/auto/drop_while.cpp | 8 + src/boost/libs/hana/test/tuple/auto/for_each.cpp | 8 + src/boost/libs/hana/test/tuple/auto/group.cpp | 8 + src/boost/libs/hana/test/tuple/auto/index_if.cpp | 9 + src/boost/libs/hana/test/tuple/auto/insert.cpp | 8 + .../libs/hana/test/tuple/auto/insert_range.cpp | 8 + .../libs/hana/test/tuple/auto/intersperse.cpp | 8 + src/boost/libs/hana/test/tuple/auto/is_empty.cpp | 8 + src/boost/libs/hana/test/tuple/auto/length.cpp | 8 + .../test/tuple/auto/lexicographical_compare.cpp | 8 + src/boost/libs/hana/test/tuple/auto/make.cpp | 8 + src/boost/libs/hana/test/tuple/auto/none_of.cpp | 8 + src/boost/libs/hana/test/tuple/auto/partition.cpp | 8 + .../libs/hana/test/tuple/auto/permutations.cpp | 8 + src/boost/libs/hana/test/tuple/auto/remove_at.cpp | 8 + .../libs/hana/test/tuple/auto/remove_range.cpp | 8 + src/boost/libs/hana/test/tuple/auto/reverse.cpp | 8 + src/boost/libs/hana/test/tuple/auto/scans.cpp | 8 + src/boost/libs/hana/test/tuple/auto/sequence.cpp | 8 + src/boost/libs/hana/test/tuple/auto/slice.cpp | 8 + src/boost/libs/hana/test/tuple/auto/sort.cpp | 8 + src/boost/libs/hana/test/tuple/auto/span.cpp | 8 + src/boost/libs/hana/test/tuple/auto/take_back.cpp | 8 + src/boost/libs/hana/test/tuple/auto/take_front.cpp | 8 + src/boost/libs/hana/test/tuple/auto/take_while.cpp | 8 + src/boost/libs/hana/test/tuple/auto/transform.cpp | 8 + src/boost/libs/hana/test/tuple/auto/unfolds.cpp | 8 + src/boost/libs/hana/test/tuple/auto/unique.cpp | 8 + src/boost/libs/hana/test/tuple/auto/zips.cpp | 8 + .../libs/hana/test/tuple/cnstr.convert_copy.cpp | 93 ++ .../libs/hana/test/tuple/cnstr.convert_move.cpp | 68 ++ src/boost/libs/hana/test/tuple/cnstr.copy.cpp | 68 ++ src/boost/libs/hana/test/tuple/cnstr.default.cpp | 138 +++ src/boost/libs/hana/test/tuple/cnstr.move.cpp | 73 ++ src/boost/libs/hana/test/tuple/cnstr.nested.cpp | 19 + src/boost/libs/hana/test/tuple/cnstr.trap.cpp | 120 +++ .../libs/hana/test/tuple/cnstr.variadic_array.cpp | 19 + .../libs/hana/test/tuple/cnstr.variadic_copy.cpp | 125 +++ .../hana/test/tuple/cnstr.variadic_forward.cpp | 114 ++ src/boost/libs/hana/test/tuple/empty_member.cpp | 33 + src/boost/libs/hana/test/tuple/hold_refs.cpp | 78 ++ src/boost/libs/hana/test/tuple/issue_90.cpp | 72 ++ src/boost/libs/hana/test/tuple/laws.cpp | 43 + src/boost/libs/hana/test/tuple/laws.functor.cpp | 64 ++ src/boost/libs/hana/test/tuple/laws.searchable.cpp | 40 + src/boost/libs/hana/test/tuple/move_only.cpp | 55 + src/boost/libs/hana/test/tuple/pair_interop.cpp | 75 ++ src/boost/libs/hana/test/tuple/smart_ptr.cpp | 23 + .../hana/test/tuple/special.drop_front_exactly.cpp | 46 + src/boost/libs/hana/test/tuple/special.empty.cpp | 25 + src/boost/libs/hana/test/tuple/special.equal.cpp | 76 ++ src/boost/libs/hana/test/tuple/special.fill.cpp | 36 + .../libs/hana/test/tuple/special.fold_left.cpp | 68 ++ .../libs/hana/test/tuple/special.fold_right.cpp | 68 ++ src/boost/libs/hana/test/tuple/special.front.cpp | 46 + .../libs/hana/test/tuple/special.is_empty.cpp | 28 + src/boost/libs/hana/test/tuple/special.prepend.cpp | 30 + .../libs/hana/test/tuple/special.transform.cpp | 52 + src/boost/libs/hana/test/tuple/to.cpp | 18 + src/boost/libs/hana/test/tuple/unpack.cpp | 89 ++ .../libs/hana/test/tuple/usability_of_types.cpp | 41 + src/boost/libs/hana/test/type/adl.cpp | 24 + src/boost/libs/hana/test/type/alignof.cpp | 32 + src/boost/libs/hana/test/type/decltype.cpp | 182 ++++ src/boost/libs/hana/test/type/equal.cpp | 35 + src/boost/libs/hana/test/type/hash.cpp | 24 + .../libs/hana/test/type/inherit_basic_type.cpp | 17 + src/boost/libs/hana/test/type/integral.cpp | 83 ++ src/boost/libs/hana/test/type/is_valid.cpp | 206 ++++ src/boost/libs/hana/test/type/laws.cpp | 28 + src/boost/libs/hana/test/type/make.cpp | 41 + src/boost/libs/hana/test/type/metafunction.cpp | 72 ++ .../libs/hana/test/type/metafunction_class.cpp | 73 ++ src/boost/libs/hana/test/type/nested_type.cpp | 18 + src/boost/libs/hana/test/type/sizeof.cpp | 32 + src/boost/libs/hana/test/type/template.cpp | 61 ++ src/boost/libs/hana/test/type/traits.cpp | 154 +++ src/boost/libs/hana/test/type/typeid.cpp | 182 ++++ src/boost/libs/hana/test/type/unary_plus.cpp | 39 + 829 files changed, 37190 insertions(+) create mode 100644 src/boost/libs/hana/test/CMakeLists.txt create mode 100644 src/boost/libs/hana/test/Jamfile.v2 create mode 100644 src/boost/libs/hana/test/_include/auto/README.md create mode 100644 src/boost/libs/hana/test/_include/auto/all_of.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/any_of.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/ap.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/at.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/cartesian_product.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/drop_back.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/drop_front.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/drop_while.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/for_each.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/group.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/index_if.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/insert.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/insert_range.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/intersperse.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/is_empty.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/length.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/lexicographical_compare.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/make.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/none_of.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/partition.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/permutations.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/remove_at.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/remove_range.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/reverse.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/scans.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/sequence.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/slice.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/sort.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/span.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/take_back.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/take_front.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/take_while.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/test_case.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/transform.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/unfolds.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/unique.hpp create mode 100644 src/boost/libs/hana/test/_include/auto/zips.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/applicative.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/base.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/comonad.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/comparable.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/constant.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/euclidean_ring.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/foldable.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/functor.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/group.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/hashable.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/iterable.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/logical.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/monad.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/monad_plus.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/monoid.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/orderable.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/product.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/ring.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/searchable.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/sequence.hpp create mode 100644 src/boost/libs/hana/test/_include/laws/templates/seq.hpp create mode 100644 src/boost/libs/hana/test/_include/support/cnumeric.hpp create mode 100644 src/boost/libs/hana/test/_include/support/constexpr_move_only.hpp create mode 100644 src/boost/libs/hana/test/_include/support/counter.hpp create mode 100644 src/boost/libs/hana/test/_include/support/equivalence_class.hpp create mode 100644 src/boost/libs/hana/test/_include/support/identity.hpp create mode 100644 src/boost/libs/hana/test/_include/support/minimal_product.hpp create mode 100644 src/boost/libs/hana/test/_include/support/numeric.hpp create mode 100644 src/boost/libs/hana/test/_include/support/seq.hpp create mode 100644 src/boost/libs/hana/test/_include/support/tracked.hpp create mode 100644 src/boost/libs/hana/test/_include/support/tracked_move_only.hpp create mode 100644 src/boost/libs/hana/test/assert/commas.cpp create mode 100644 src/boost/libs/hana/test/assert/constant.cpp create mode 100644 src/boost/libs/hana/test/assert/constexpr.cpp create mode 100644 src/boost/libs/hana/test/assert/flexible.cpp create mode 100644 src/boost/libs/hana/test/assert/lambdas.cpp create mode 100644 src/boost/libs/hana/test/assert/runtime.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/at.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/group.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/length.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/make.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/span.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/cnstr.copy.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/construct.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/laws.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/length.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/make.cpp create mode 100644 src/boost/libs/hana/test/basic_tuple/unpack.cpp create mode 100644 src/boost/libs/hana/test/builtin_array.cpp create mode 100644 src/boost/libs/hana/test/comparable.cpp create mode 100644 src/boost/libs/hana/test/concept/constant/arithmetic.cpp create mode 100644 src/boost/libs/hana/test/concept/constant/comparable.cpp create mode 100644 src/boost/libs/hana/test/concept/constant/laws.cpp create mode 100644 src/boost/libs/hana/test/concept/constant/logical.cpp create mode 100644 src/boost/libs/hana/test/concept/constant/mcd.cpp create mode 100644 src/boost/libs/hana/test/concept/constant/minimal.hpp create mode 100644 src/boost/libs/hana/test/concept/constant/orderable.cpp create mode 100644 src/boost/libs/hana/test/concept/constant/to.cpp create mode 100644 src/boost/libs/hana/test/concept/integral_constant.cpp create mode 100644 src/boost/libs/hana/test/concept/sequence/iterable.cpp create mode 100644 src/boost/libs/hana/test/concept/sequence/monad.cpp create mode 100644 src/boost/libs/hana/test/concept/sequence/monad_plus.cpp create mode 100644 src/boost/libs/hana/test/concept/sequence/orderable.cpp create mode 100644 src/boost/libs/hana/test/concept/sequence/searchable.cpp create mode 100644 src/boost/libs/hana/test/concept/sequence/sequence.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/any_of.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/at_key.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/equal.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/find_if.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/fold_left.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/fold_right.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/keys.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/laws.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/macro.adapt_adt.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/macro.adapt_struct.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/macro.define_struct.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/member_function.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/members.cpp create mode 100644 src/boost/libs/hana/test/concept/struct/minimal_struct.hpp create mode 100644 src/boost/libs/hana/test/concept/struct/unpack.cpp create mode 100644 src/boost/libs/hana/test/core/common.cpp create mode 100644 src/boost/libs/hana/test/core/default.cpp create mode 100644 src/boost/libs/hana/test/core/is_a.cpp create mode 100644 src/boost/libs/hana/test/core/is_embedded.cpp create mode 100644 src/boost/libs/hana/test/core/make.cpp create mode 100644 src/boost/libs/hana/test/core/tag_of.cpp create mode 100644 src/boost/libs/hana/test/core/to.cpp create mode 100644 src/boost/libs/hana/test/core/when.cpp create mode 100644 src/boost/libs/hana/test/deploy/CMakeLists.txt create mode 100644 src/boost/libs/hana/test/deploy/main.cpp create mode 100644 src/boost/libs/hana/test/detail/algorithm.cpp create mode 100644 src/boost/libs/hana/test/detail/any_of.cpp create mode 100644 src/boost/libs/hana/test/detail/canonical_constant/laws.cpp create mode 100644 src/boost/libs/hana/test/detail/create.cpp create mode 100644 src/boost/libs/hana/test/detail/decay.cpp create mode 100644 src/boost/libs/hana/test/detail/ebo.cpp create mode 100644 src/boost/libs/hana/test/detail/fast_and.cpp create mode 100644 src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp create mode 100644 src/boost/libs/hana/test/detail/has_duplicates.cpp create mode 100644 src/boost/libs/hana/test/detail/preprocessor.cpp create mode 100644 src/boost/libs/hana/test/detail/struct_macros.cpp create mode 100644 src/boost/libs/hana/test/detail/type_at.cpp create mode 100644 src/boost/libs/hana/test/detail/type_foldl1.cpp create mode 100644 src/boost/libs/hana/test/detail/type_foldr1.cpp create mode 100644 src/boost/libs/hana/test/detail/unpack_flatten.cpp create mode 100644 src/boost/libs/hana/test/detail/variadic/at.cpp create mode 100644 src/boost/libs/hana/test/detail/variadic/drop_into.cpp create mode 100644 src/boost/libs/hana/test/detail/variadic/foldl1.cpp create mode 100644 src/boost/libs/hana/test/detail/variadic/foldr1.cpp create mode 100644 src/boost/libs/hana/test/detail/variadic/reverse_apply.cpp create mode 100644 src/boost/libs/hana/test/detail/variadic/split_at.cpp create mode 100644 src/boost/libs/hana/test/detail/variadic/take.cpp create mode 100644 src/boost/libs/hana/test/euclidean_ring.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/map.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/metafunction.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/optional.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/pair.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/set.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/string.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/tuple.cpp create mode 100644 src/boost/libs/hana/test/experimental/printable/type.cpp create mode 100644 src/boost/libs/hana/test/experimental/type_name.cpp create mode 100644 src/boost/libs/hana/test/experimental/types/at.cpp create mode 100644 src/boost/libs/hana/test/experimental/types/contains.cpp create mode 100644 src/boost/libs/hana/test/experimental/types/drop_front.cpp create mode 100644 src/boost/libs/hana/test/experimental/types/equal.cpp create mode 100644 src/boost/libs/hana/test/experimental/types/is_empty.cpp create mode 100644 src/boost/libs/hana/test/experimental/types/transform.cpp create mode 100644 src/boost/libs/hana/test/experimental/types/unpack.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/empty/is_empty.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/empty/length.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/empty/unpack.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/joined/at.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/joined/is_empty.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/joined/length.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/joined/unpack.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/single/at.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/single/is_empty.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/single/length.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/single/unpack.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/sliced/at.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/sliced/is_empty.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/sliced/length.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/sliced/unpack.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/ap.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/at.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/drop_front.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/equal.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/is_empty.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/laziness.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/length.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/less.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/transform.cpp create mode 100644 src/boost/libs/hana/test/experimental/view/transformed/unpack.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/group.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/length.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/make.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/span.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/deque/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/group.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/length.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/make.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/span.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/list/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/group.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/length.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/make.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/span.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/group.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/length.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/make.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/span.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/fusion/vector/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/integral_c/arithmetic.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/integral_c/comparable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/integral_c/constant.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/integral_c/interop.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/integral_c/logical.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/integral_c/orderable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/integral_c/tag.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/list/comparable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/list/foldable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/list/iterable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/list/searchable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/list/tag.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/list/to.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/vector/comparable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/vector/foldable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/vector/iterable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/vector/searchable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/vector/tag.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/mpl/vector/to.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/group.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/intersperse.broken.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/length.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/make.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/permutations.broken.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/span.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/take_front.broken.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/iterable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/monad.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/monad_plus.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/orderable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/searchable.cpp create mode 100644 src/boost/libs/hana/test/ext/boost/tuple/tag_of.cpp create mode 100644 src/boost/libs/hana/test/ext/std/array/at.cpp create mode 100644 src/boost/libs/hana/test/ext/std/array/comparable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/array/foldable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/array/issue_304.cpp create mode 100644 src/boost/libs/hana/test/ext/std/array/iterable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/array/orderable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/array/searchable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/bugs/libcxx_19616.cpp create mode 100644 src/boost/libs/hana/test/ext/std/bugs/libcxx_22806.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integer_sequence/drop_front_exactly.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integer_sequence/equal.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integer_sequence/find_if.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integer_sequence/front.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integer_sequence/is_empty.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integer_sequence/laws.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integer_sequence/unpack.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integral_constant/arithmetic.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integral_constant/comparable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integral_constant/constant.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integral_constant/interop.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integral_constant/logical.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integral_constant/orderable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/integral_constant/tag.cpp create mode 100644 src/boost/libs/hana/test/ext/std/pair/first_second.cpp create mode 100644 src/boost/libs/hana/test/ext/std/pair/issue_90.cpp create mode 100644 src/boost/libs/hana/test/ext/std/pair/laws.cpp create mode 100644 src/boost/libs/hana/test/ext/std/pair/make.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/div.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/equal.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/laws.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/less.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/minus.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/mod.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/mult.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/one.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/plus.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/to.cpp create mode 100644 src/boost/libs/hana/test/ext/std/ratio/zero.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/at.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/group.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/length.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/make.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/span.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/issue_90.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/laws.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/laws.functor.cpp create mode 100644 src/boost/libs/hana/test/ext/std/tuple/laws.searchable.cpp create mode 100644 src/boost/libs/hana/test/ext/std/vector.cpp create mode 100644 src/boost/libs/hana/test/fold_left/ref.cpp create mode 100644 src/boost/libs/hana/test/fold_right/ref.cpp create mode 100644 src/boost/libs/hana/test/foldable/fold_left_mcd/iterable.cpp create mode 100644 src/boost/libs/hana/test/foldable/fold_left_mcd/monad.cpp create mode 100644 src/boost/libs/hana/test/foldable/fold_left_mcd/monad_plus.cpp create mode 100644 src/boost/libs/hana/test/foldable/fold_left_mcd/orderable.cpp create mode 100644 src/boost/libs/hana/test/foldable/fold_left_mcd/searchable.cpp create mode 100644 src/boost/libs/hana/test/foldable/fold_left_mcd/sequence.cpp create mode 100644 src/boost/libs/hana/test/foldable/iterable_mcd/iterable.cpp create mode 100644 src/boost/libs/hana/test/foldable/iterable_mcd/monad.cpp create mode 100644 src/boost/libs/hana/test/foldable/iterable_mcd/monad_plus.cpp create mode 100644 src/boost/libs/hana/test/foldable/iterable_mcd/orderable.cpp create mode 100644 src/boost/libs/hana/test/foldable/iterable_mcd/searchable.cpp create mode 100644 src/boost/libs/hana/test/foldable/iterable_mcd/sequence.cpp create mode 100644 src/boost/libs/hana/test/foldable/unpack_mcd/iterable.cpp create mode 100644 src/boost/libs/hana/test/foldable/unpack_mcd/monad.cpp create mode 100644 src/boost/libs/hana/test/foldable/unpack_mcd/monad_plus.cpp create mode 100644 src/boost/libs/hana/test/foldable/unpack_mcd/orderable.cpp create mode 100644 src/boost/libs/hana/test/foldable/unpack_mcd/searchable.cpp create mode 100644 src/boost/libs/hana/test/foldable/unpack_mcd/sequence.cpp create mode 100644 src/boost/libs/hana/test/functional.cpp create mode 100644 src/boost/libs/hana/test/functional/apply.cpp create mode 100644 src/boost/libs/hana/test/functional/capture.cpp create mode 100644 src/boost/libs/hana/test/functional/demux.cpp create mode 100644 src/boost/libs/hana/test/functional/fix.cpp create mode 100644 src/boost/libs/hana/test/functional/iterate.cpp create mode 100644 src/boost/libs/hana/test/functional/lockstep.cpp create mode 100644 src/boost/libs/hana/test/functional/overload_linearly.cpp create mode 100644 src/boost/libs/hana/test/functional/partial.cpp create mode 100644 src/boost/libs/hana/test/functional/placeholder.cpp create mode 100644 src/boost/libs/hana/test/functional/reverse_partial.cpp create mode 100644 src/boost/libs/hana/test/group.cpp create mode 100644 src/boost/libs/hana/test/identity/applicative.full_mcd.cpp create mode 100644 src/boost/libs/hana/test/identity/applicative.monad_mcd.cpp create mode 100644 src/boost/libs/hana/test/identity/functor.adjust_mcd.cpp create mode 100644 src/boost/libs/hana/test/identity/functor.transform_mcd.cpp create mode 100644 src/boost/libs/hana/test/identity/main.hpp create mode 100644 src/boost/libs/hana/test/identity/monad.chain_mcd.cpp create mode 100644 src/boost/libs/hana/test/identity/monad.flatten_mcd.cpp create mode 100644 src/boost/libs/hana/test/if_/non_copyable.cpp create mode 100644 src/boost/libs/hana/test/index_if.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/arithmetic.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/comparable.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/constant.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/constexpr_init.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/github_354.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/hash.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/hashable.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/logical.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/operators.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/orderable.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/std_api.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/tag.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/times.cpp create mode 100644 src/boost/libs/hana/test/integral_constant/udl.cpp create mode 100644 src/boost/libs/hana/test/issues/clang_20046.cpp create mode 100644 src/boost/libs/hana/test/issues/github_112.cpp create mode 100644 src/boost/libs/hana/test/issues/github_113.cpp create mode 100644 src/boost/libs/hana/test/issues/github_149.cpp create mode 100644 src/boost/libs/hana/test/issues/github_15.cpp create mode 100644 src/boost/libs/hana/test/issues/github_165.cpp create mode 100644 src/boost/libs/hana/test/issues/github_202.cpp create mode 100644 src/boost/libs/hana/test/issues/github_221.cpp create mode 100644 src/boost/libs/hana/test/issues/github_234.cpp create mode 100644 src/boost/libs/hana/test/issues/github_252.cpp create mode 100644 src/boost/libs/hana/test/issues/github_260.cpp create mode 100644 src/boost/libs/hana/test/issues/github_266.cpp create mode 100644 src/boost/libs/hana/test/issues/github_269.cpp create mode 100644 src/boost/libs/hana/test/issues/github_297.cpp create mode 100644 src/boost/libs/hana/test/issues/github_31.cpp create mode 100644 src/boost/libs/hana/test/issues/github_331.cpp create mode 100644 src/boost/libs/hana/test/issues/github_362.cpp create mode 100644 src/boost/libs/hana/test/issues/github_365.cpp create mode 100644 src/boost/libs/hana/test/issues/github_75/tu1.cpp create mode 100644 src/boost/libs/hana/test/issues/github_75/tu2.cpp create mode 100644 src/boost/libs/hana/test/issues/github_91.cpp create mode 100644 src/boost/libs/hana/test/lazy.cpp create mode 100644 src/boost/libs/hana/test/logical.cpp create mode 100644 src/boost/libs/hana/test/map/any_of.cpp create mode 100644 src/boost/libs/hana/test/map/assign.copy.cpp create mode 100644 src/boost/libs/hana/test/map/assign.move.cpp create mode 100644 src/boost/libs/hana/test/map/at_key.collisions.cpp create mode 100644 src/boost/libs/hana/test/map/at_key.cpp create mode 100644 src/boost/libs/hana/test/map/at_key.ref.cpp create mode 100644 src/boost/libs/hana/test/map/at_key.stackoverflow.cpp create mode 100644 src/boost/libs/hana/test/map/cnstr.copy.cpp create mode 100644 src/boost/libs/hana/test/map/cnstr.default.cpp create mode 100644 src/boost/libs/hana/test/map/cnstr.move.cpp create mode 100644 src/boost/libs/hana/test/map/cnstr.trap.cpp create mode 100644 src/boost/libs/hana/test/map/cnstr.variadic.cpp create mode 100644 src/boost/libs/hana/test/map/contains.cpp create mode 100644 src/boost/libs/hana/test/map/difference.cpp create mode 100644 src/boost/libs/hana/test/map/equal.cpp create mode 100644 src/boost/libs/hana/test/map/erase_key.cpp create mode 100644 src/boost/libs/hana/test/map/find_if.cpp create mode 100644 src/boost/libs/hana/test/map/fold_left.cpp create mode 100644 src/boost/libs/hana/test/map/fold_right.cpp create mode 100644 src/boost/libs/hana/test/map/insert.cpp create mode 100644 src/boost/libs/hana/test/map/intersection.cpp create mode 100644 src/boost/libs/hana/test/map/is_subset.cpp create mode 100644 src/boost/libs/hana/test/map/keys.cpp create mode 100644 src/boost/libs/hana/test/map/laws.cpp create mode 100644 src/boost/libs/hana/test/map/map.cpp create mode 100644 src/boost/libs/hana/test/map/symmetric_difference.cpp create mode 100644 src/boost/libs/hana/test/map/to.cpp create mode 100644 src/boost/libs/hana/test/map/union.cpp create mode 100644 src/boost/libs/hana/test/map/unpack.cpp create mode 100644 src/boost/libs/hana/test/map/values.cpp create mode 100644 src/boost/libs/hana/test/minimal_product.cpp create mode 100644 src/boost/libs/hana/test/monoid.cpp create mode 100644 src/boost/libs/hana/test/numeric/main.hpp create mode 100644 src/boost/libs/hana/test/numeric/minus_mcd.cpp create mode 100644 src/boost/libs/hana/test/numeric/negate_mcd.cpp create mode 100644 src/boost/libs/hana/test/optional/any_of.cpp create mode 100644 src/boost/libs/hana/test/optional/ap.cpp create mode 100644 src/boost/libs/hana/test/optional/chain.cpp create mode 100644 src/boost/libs/hana/test/optional/concat.cpp create mode 100644 src/boost/libs/hana/test/optional/copy.trap_construct.cpp create mode 100644 src/boost/libs/hana/test/optional/empty.cpp create mode 100644 src/boost/libs/hana/test/optional/equal.cpp create mode 100644 src/boost/libs/hana/test/optional/find_if.cpp create mode 100644 src/boost/libs/hana/test/optional/flatten.cpp create mode 100644 src/boost/libs/hana/test/optional/fold_left.cpp create mode 100644 src/boost/libs/hana/test/optional/fold_right.cpp create mode 100644 src/boost/libs/hana/test/optional/is_just.cpp create mode 100644 src/boost/libs/hana/test/optional/is_nothing.cpp create mode 100644 src/boost/libs/hana/test/optional/laws.cpp create mode 100644 src/boost/libs/hana/test/optional/less.cpp create mode 100644 src/boost/libs/hana/test/optional/lift.cpp create mode 100644 src/boost/libs/hana/test/optional/make.cpp create mode 100644 src/boost/libs/hana/test/optional/maybe.cpp create mode 100644 src/boost/libs/hana/test/optional/nested_type.cpp create mode 100644 src/boost/libs/hana/test/optional/operator_arrow.cpp create mode 100644 src/boost/libs/hana/test/optional/operator_deref.cpp create mode 100644 src/boost/libs/hana/test/optional/representation.cpp create mode 100644 src/boost/libs/hana/test/optional/sfinae.cpp create mode 100644 src/boost/libs/hana/test/optional/transform.cpp create mode 100644 src/boost/libs/hana/test/optional/unpack.cpp create mode 100644 src/boost/libs/hana/test/optional/value.cpp create mode 100644 src/boost/libs/hana/test/optional/value_or.cpp create mode 100644 src/boost/libs/hana/test/orderable.cpp create mode 100644 src/boost/libs/hana/test/pair/assign.copy.cpp create mode 100644 src/boost/libs/hana/test/pair/assign.move.cpp create mode 100644 src/boost/libs/hana/test/pair/cnstr.copy.cpp create mode 100644 src/boost/libs/hana/test/pair/cnstr.default.cpp create mode 100644 src/boost/libs/hana/test/pair/cnstr.memberwise.cpp create mode 100644 src/boost/libs/hana/test/pair/cnstr.move.cpp create mode 100644 src/boost/libs/hana/test/pair/comparable.cpp create mode 100644 src/boost/libs/hana/test/pair/empty_storage.cpp create mode 100644 src/boost/libs/hana/test/pair/foldable.cpp create mode 100644 src/boost/libs/hana/test/pair/issue_90.cpp create mode 100644 src/boost/libs/hana/test/pair/make.cpp create mode 100644 src/boost/libs/hana/test/pair/orderable.cpp create mode 100644 src/boost/libs/hana/test/pair/product.cpp create mode 100644 src/boost/libs/hana/test/pair/tag_of.cpp create mode 100644 src/boost/libs/hana/test/range/at.cpp create mode 100644 src/boost/libs/hana/test/range/back.cpp create mode 100644 src/boost/libs/hana/test/range/contains.cpp create mode 100644 src/boost/libs/hana/test/range/drop_front.cpp create mode 100644 src/boost/libs/hana/test/range/drop_front_exactly.cpp create mode 100644 src/boost/libs/hana/test/range/equal.cpp create mode 100644 src/boost/libs/hana/test/range/find.cpp create mode 100644 src/boost/libs/hana/test/range/front.cpp create mode 100644 src/boost/libs/hana/test/range/is_empty.cpp create mode 100644 src/boost/libs/hana/test/range/laws.cpp create mode 100644 src/boost/libs/hana/test/range/length.cpp create mode 100644 src/boost/libs/hana/test/range/make.cpp create mode 100644 src/boost/libs/hana/test/range/maximum.cpp create mode 100644 src/boost/libs/hana/test/range/minimum.cpp create mode 100644 src/boost/libs/hana/test/range/product.cpp create mode 100644 src/boost/libs/hana/test/range/range_c.cpp create mode 100644 src/boost/libs/hana/test/range/sum.cpp create mode 100644 src/boost/libs/hana/test/range/unpack.cpp create mode 100644 src/boost/libs/hana/test/repeat.cpp create mode 100644 src/boost/libs/hana/test/ring.cpp create mode 100644 src/boost/libs/hana/test/searchable.cpp create mode 100644 src/boost/libs/hana/test/set/any_of.cpp create mode 100644 src/boost/libs/hana/test/set/cnstr.copy.cpp create mode 100644 src/boost/libs/hana/test/set/cnstr.default.cpp create mode 100644 src/boost/libs/hana/test/set/cnstr.move.cpp create mode 100644 src/boost/libs/hana/test/set/cnstr.trap.cpp create mode 100644 src/boost/libs/hana/test/set/difference.cpp create mode 100644 src/boost/libs/hana/test/set/equal.cpp create mode 100644 src/boost/libs/hana/test/set/erase_key.cpp create mode 100644 src/boost/libs/hana/test/set/find_if.cpp create mode 100644 src/boost/libs/hana/test/set/insert.cpp create mode 100644 src/boost/libs/hana/test/set/intersection.cpp create mode 100644 src/boost/libs/hana/test/set/is_subset.cpp create mode 100644 src/boost/libs/hana/test/set/laws.cpp create mode 100644 src/boost/libs/hana/test/set/make.cpp create mode 100644 src/boost/libs/hana/test/set/symmetric_difference.cpp create mode 100644 src/boost/libs/hana/test/set/to.cpp create mode 100644 src/boost/libs/hana/test/set/union.cpp create mode 100644 src/boost/libs/hana/test/set/unpack.cpp create mode 100644 src/boost/libs/hana/test/string/any_of.cpp create mode 100644 src/boost/libs/hana/test/string/at.cpp create mode 100644 src/boost/libs/hana/test/string/c_str.cpp create mode 100644 src/boost/libs/hana/test/string/cnstr.c_str.cpp create mode 100644 src/boost/libs/hana/test/string/cnstr.copy.cpp create mode 100644 src/boost/libs/hana/test/string/cnstr.default.cpp create mode 100644 src/boost/libs/hana/test/string/contains.cpp create mode 100644 src/boost/libs/hana/test/string/drop_front_exactly.cpp create mode 100644 src/boost/libs/hana/test/string/equal.cpp create mode 100644 src/boost/libs/hana/test/string/find.cpp create mode 100644 src/boost/libs/hana/test/string/find_if.cpp create mode 100644 src/boost/libs/hana/test/string/front.cpp create mode 100644 src/boost/libs/hana/test/string/hash.cpp create mode 100644 src/boost/libs/hana/test/string/is_empty.cpp create mode 100644 src/boost/libs/hana/test/string/laws.cpp create mode 100644 src/boost/libs/hana/test/string/length.cpp create mode 100644 src/boost/libs/hana/test/string/less.cpp create mode 100644 src/boost/libs/hana/test/string/macro.cpp create mode 100644 src/boost/libs/hana/test/string/make.cpp create mode 100644 src/boost/libs/hana/test/string/plus.cpp create mode 100644 src/boost/libs/hana/test/string/to.cpp create mode 100644 src/boost/libs/hana/test/string/udl.cpp create mode 100644 src/boost/libs/hana/test/string/unpack.cpp create mode 100644 src/boost/libs/hana/test/string/zero.cpp create mode 100644 src/boost/libs/hana/test/tuple/any_of.clang_ice.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.convert_copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.convert_move.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/assign.move.cpp create mode 100644 src/boost/libs/hana/test/tuple/at.const.cpp create mode 100644 src/boost/libs/hana/test/tuple/at.non_const.cpp create mode 100644 src/boost/libs/hana/test/tuple/at.rv.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/_specs.hpp create mode 100644 src/boost/libs/hana/test/tuple/auto/all_of.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/any_of.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/ap.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/at.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/drop_back.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/drop_front.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/drop_while.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/for_each.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/group.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/index_if.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/insert.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/insert_range.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/intersperse.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/is_empty.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/length.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/make.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/none_of.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/partition.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/permutations.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/remove_at.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/remove_range.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/reverse.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/scans.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/sequence.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/slice.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/sort.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/span.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/take_back.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/take_front.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/take_while.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/transform.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/unfolds.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/unique.cpp create mode 100644 src/boost/libs/hana/test/tuple/auto/zips.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.convert_move.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.default.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.move.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.nested.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.trap.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.variadic_array.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp create mode 100644 src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp create mode 100644 src/boost/libs/hana/test/tuple/empty_member.cpp create mode 100644 src/boost/libs/hana/test/tuple/hold_refs.cpp create mode 100644 src/boost/libs/hana/test/tuple/issue_90.cpp create mode 100644 src/boost/libs/hana/test/tuple/laws.cpp create mode 100644 src/boost/libs/hana/test/tuple/laws.functor.cpp create mode 100644 src/boost/libs/hana/test/tuple/laws.searchable.cpp create mode 100644 src/boost/libs/hana/test/tuple/move_only.cpp create mode 100644 src/boost/libs/hana/test/tuple/pair_interop.cpp create mode 100644 src/boost/libs/hana/test/tuple/smart_ptr.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.empty.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.equal.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.fill.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.fold_left.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.fold_right.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.front.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.is_empty.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.prepend.cpp create mode 100644 src/boost/libs/hana/test/tuple/special.transform.cpp create mode 100644 src/boost/libs/hana/test/tuple/to.cpp create mode 100644 src/boost/libs/hana/test/tuple/unpack.cpp create mode 100644 src/boost/libs/hana/test/tuple/usability_of_types.cpp create mode 100644 src/boost/libs/hana/test/type/adl.cpp create mode 100644 src/boost/libs/hana/test/type/alignof.cpp create mode 100644 src/boost/libs/hana/test/type/decltype.cpp create mode 100644 src/boost/libs/hana/test/type/equal.cpp create mode 100644 src/boost/libs/hana/test/type/hash.cpp create mode 100644 src/boost/libs/hana/test/type/inherit_basic_type.cpp create mode 100644 src/boost/libs/hana/test/type/integral.cpp create mode 100644 src/boost/libs/hana/test/type/is_valid.cpp create mode 100644 src/boost/libs/hana/test/type/laws.cpp create mode 100644 src/boost/libs/hana/test/type/make.cpp create mode 100644 src/boost/libs/hana/test/type/metafunction.cpp create mode 100644 src/boost/libs/hana/test/type/metafunction_class.cpp create mode 100644 src/boost/libs/hana/test/type/nested_type.cpp create mode 100644 src/boost/libs/hana/test/type/sizeof.cpp create mode 100644 src/boost/libs/hana/test/type/template.cpp create mode 100644 src/boost/libs/hana/test/type/traits.cpp create mode 100644 src/boost/libs/hana/test/type/typeid.cpp create mode 100644 src/boost/libs/hana/test/type/unary_plus.cpp (limited to 'src/boost/libs/hana/test') diff --git a/src/boost/libs/hana/test/CMakeLists.txt b/src/boost/libs/hana/test/CMakeLists.txt new file mode 100644 index 000000000..c51d577f3 --- /dev/null +++ b/src/boost/libs/hana/test/CMakeLists.txt @@ -0,0 +1,143 @@ +# 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) + +add_custom_target(tests COMMENT "Build all the unit tests.") +add_dependencies(hana_check tests) + + +############################################################################## +# Take note of files that depend on Boost +############################################################################## +file(GLOB_RECURSE TESTS_REQUIRING_BOOST "ext/boost/*.cpp" + "experimental/printable/*.cpp") + +file(GLOB_RECURSE PUBLIC_HEADERS_REQUIRING_BOOST + RELATIVE "${Boost.Hana_SOURCE_DIR}/include" + "${Boost.Hana_SOURCE_DIR}/include/boost/hana/ext/boost/*.hpp" + "${Boost.Hana_SOURCE_DIR}/include/boost/hana/ext/boost.hpp" + "${Boost.Hana_SOURCE_DIR}/include/boost/hana/experimental/printable.hpp" +) + + +############################################################################## +# Caveats: Take note of public headers and tests that are not supported. +############################################################################## +if (NOT Boost_FOUND) + list(APPEND EXCLUDED_UNIT_TESTS ${TESTS_REQUIRING_BOOST}) + list(APPEND EXCLUDED_PUBLIC_HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST}) +endif() + +# The experimental::type_name test is only supported on Clang and AppleClang >= 7.0 +if (NOT (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" + OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" AND + NOT ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 7))) + list(APPEND EXCLUDED_PUBLIC_HEADERS + "boost/hana/experimental/type_name.hpp") + list(APPEND EXCLUDED_UNIT_TESTS "experimental/type_name.cpp") +endif() + +# On Windows, Clang-cl emulates a MSVC bug that causes EBO not to be applied +# properly. We disable the tests that check for EBO. +if (MSVC AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") + list(APPEND EXCLUDED_UNIT_TESTS + "detail/ebo.cpp" + "issues/github_202.cpp" + "pair/empty_storage.cpp" + "tuple/empty_member.cpp" + ) +endif() + + +############################################################################## +# Generate tests that include each public header. +# The headers that were excluded above due to caveats are ignored here. +############################################################################## +add_custom_target(test.headers COMMENT "Build all the header-inclusion unit tests.") +add_dependencies(tests test.headers) + +file(GLOB_RECURSE PUBLIC_HEADERS + RELATIVE "${Boost.Hana_SOURCE_DIR}/include" + "${Boost.Hana_SOURCE_DIR}/include/*.hpp" +) +list(REMOVE_ITEM PUBLIC_HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST}) + +include(TestHeaders) +add_header_test(test.headers.standalone EXCLUDE_FROM_ALL + HEADERS ${PUBLIC_HEADERS} + EXCLUDE ${EXCLUDED_PUBLIC_HEADERS}) +target_link_libraries(test.headers.standalone PRIVATE hana) +add_dependencies(test.headers test.headers.standalone) + +if (Boost_FOUND) + add_header_test(test.headers.boost EXCLUDE_FROM_ALL + HEADERS ${PUBLIC_HEADERS_REQUIRING_BOOST} + EXCLUDE ${EXCLUDED_PUBLIC_HEADERS}) + target_link_libraries(test.headers.boost PRIVATE hana Boost::boost) + add_dependencies(test.headers test.headers.boost) +endif() + + +############################################################################## +# Check for ODR violations when linking several translation units +# (GitHub issue 75) +############################################################################## +list(APPEND EXCLUDED_UNIT_TESTS "issues/github_75/*.cpp") +boost_hana_target_name_for(github_75 "${CMAKE_CURRENT_LIST_DIR}/issues/github_75") +add_executable(${github_75} EXCLUDE_FROM_ALL "issues/github_75/tu1.cpp" "issues/github_75/tu2.cpp") +boost_hana_set_test_properties(${github_75}) +add_test(${github_75} "${CMAKE_CURRENT_BINARY_DIR}/${github_75}") +add_dependencies(tests ${github_75}) + + +############################################################################## +# Add all the remaining unit tests +############################################################################## +file(GLOB_RECURSE UNIT_TESTS "*.cpp") +file(GLOB_RECURSE EXCLUDED_UNIT_TESTS ${EXCLUDED_UNIT_TESTS}) +list(REMOVE_ITEM UNIT_TESTS ${EXCLUDED_UNIT_TESTS}) + +foreach(_file IN LISTS UNIT_TESTS) + boost_hana_target_name_for(_target "${_file}") + add_executable(${_target} EXCLUDE_FROM_ALL "${_file}") + boost_hana_set_test_properties(${_target}) + if (_file IN_LIST TESTS_REQUIRING_BOOST) + target_link_libraries(${_target} PRIVATE Boost::boost) + endif() + target_include_directories(${_target} PRIVATE _include) + add_test(${_target} "${CMAKE_CURRENT_BINARY_DIR}/${_target}") + add_dependencies(tests ${_target}) +endforeach() + + +############################################################################## +# Add the deployment test, which checks that we can indeed install `hana` and +# then use the provided `HanaConfig.cmake` config file to use `hana` from an +# external project. +############################################################################## +include(ExternalProject) +set(HANA_FAKE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/deploy/fakeroot") +ExternalProject_Add(test.deploy.fakeroot + SOURCE_DIR "${PROJECT_SOURCE_DIR}" + EXCLUDE_FROM_ALL TRUE + BUILD_ALWAYS TRUE + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${HANA_FAKE_INSTALL_DIR} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + TEST_COMMAND "" # Disable test step + UPDATE_COMMAND "" # Disable source work-tree update +) + +add_custom_target(test.deploy + DEPENDS test.deploy.fakeroot + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/deploy/build" + COMMAND ${CMAKE_COMMAND} -E chdir "${CMAKE_CURRENT_BINARY_DIR}/deploy/build" + ${CMAKE_COMMAND} "${CMAKE_CURRENT_SOURCE_DIR}/deploy" + -DCMAKE_CXX_COMPILER="${CMAKE_CXX_COMPILER}" + -DCMAKE_PREFIX_PATH="${HANA_FAKE_INSTALL_DIR}" + -DCMAKE_GENERATOR=${CMAKE_GENERATOR} + -DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN_FILE}" + COMMAND ${CMAKE_COMMAND} --build "${CMAKE_CURRENT_BINARY_DIR}/deploy/build" + USES_TERMINAL +) +add_dependencies(hana_check test.deploy) diff --git a/src/boost/libs/hana/test/Jamfile.v2 b/src/boost/libs/hana/test/Jamfile.v2 new file mode 100644 index 000000000..cc66d79bc --- /dev/null +++ b/src/boost/libs/hana/test/Jamfile.v2 @@ -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) + +import config : requires ; +import testing ; +import regex ; + +project boost/hana : + requirements + ./_include + ../include +; + +rule hana-all-tests { + local toolset = + clang:"-std=c++1y -pedantic -Wall -Wextra" + darwin:"-std=c++1y -pedantic -Wall -Wextra" + [ requires + cxx14_constexpr + cxx14_decltype_auto + cxx14_generic_lambdas + cxx14_return_type_deduction + ] + ; + + local result ; + + result += [ run issues/github_75/tu1.cpp issues/github_75/tu2.cpp : : : $(toolset) : test.issues.github_75 ] ; + + local sources = [ glob-tree *.cpp : *github_75* ] ; + for local source in $(sources) + { + local target = [ regex.replace $(source) "\.cpp" "" ] ; + target = [ regex.replace $(target) "/" "." ] ; + result += [ run $(source) : : : $(toolset) : test.$(target) ] ; + } + + return $(result) ; +} + +test-suite hana : [ hana-all-tests ] ; + +# Satisfy the Boost library requirements +test-suite minimal : hana ; +test-suite full : hana ; +test-suite extra : hana ; + +explicit hana ; +explicit minimal ; +explicit extra ; diff --git a/src/boost/libs/hana/test/_include/auto/README.md b/src/boost/libs/hana/test/_include/auto/README.md new file mode 100644 index 000000000..082906c28 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/README.md @@ -0,0 +1,44 @@ +The headers in this directory provide facilities for automatic unit testing. +Basically, each header defines unit tests for an algorithm or a set of related +algorithms. To get the tests for these algorithms, simply include the header +at global scope. However, before including the header, you must define the +following macros: + + `MAKE_TUPLE(...)` + Must expand to a sequence holding `__VA_ARGS__`. A valid definition + would be `hana::make_tuple(__VA_ARGS__)`. + + `TUPLE_TYPE(...)` + Must expand to the type of a sequence holding objects of type `__VA_ARGS__`. + A valid definition would be `hana::tuple<__VA_ARGS__>`. + + `TUPLE_TAG` + Must expand to the tag of the sequence. A valid definition would + be `hana::tuple_tag`. + + +The following macros may or may not be defined: + + `MAKE_TUPLE_NO_CONSTEXPR` + Must be defined if the `MAKE_TUPLE` macro can't be used inside a + constant expression. Otherwise, `MAKE_TUPLE` is assumed to be able + to construct a `constexpr` container. + +The following directories contain automatic unit tests, and the following is +sufficient when adding a new automatic unit test (in a file `${FILE}`): + +```sh +DIRECTORIES=$(find test -type d -name auto | grep -v test/_include/auto) +for d in ${DIRECTORIES}; do + cat > ${d}/${FILE}.cpp < + +int main() { } +EOF +done +``` diff --git a/src/boost/libs/hana/test/_include/auto/all_of.hpp b/src/boost/libs/hana/test/_include/auto/all_of.hpp new file mode 100644 index 000000000..b1bdc1125 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/all_of.hpp @@ -0,0 +1,120 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_ALL_OF_HPP +#define BOOST_HANA_TEST_AUTO_ALL_OF_HPP + +#include +#include +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_all_of{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(), + [](auto) { return hana::false_c; } + )); + + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}), + hana::equal.to(ct_eq<999>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::equal.to(ct_eq<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<999>{}, ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<999>{}, ct_eq<0>{}, ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<999>{}, ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::all_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{}, ct_eq<999>{}), + hana::equal.to(ct_eq<0>{}) + ))); + + // Make sure `all_of` short-circuits with runtime predicates + // See http://stackoverflow.com/q/42012512/627587 + { + { + int counter = 0; + auto tuple = MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}); + hana::all_of(tuple, [&](auto) { ++counter; return false; }); + BOOST_HANA_RUNTIME_CHECK(counter == 1); + } + { + int counter = 0; + auto tuple = MAKE_TUPLE(ct_eq<0>{}, ct_eq<999>{}, ct_eq<0>{}); + hana::all_of(tuple, [&](auto x) -> bool { + ++counter; + return hana::equal(x, ct_eq<0>{}); + }); + BOOST_HANA_RUNTIME_CHECK(counter == 2); + } + } +}}; + +#endif // !BOOST_HANA_TEST_AUTO_ALL_OF_HPP diff --git a/src/boost/libs/hana/test/_include/auto/any_of.hpp b/src/boost/libs/hana/test/_include/auto/any_of.hpp new file mode 100644 index 000000000..400b5a3b1 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/any_of.hpp @@ -0,0 +1,173 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_ANY_OF_HPP +#define BOOST_HANA_TEST_AUTO_ANY_OF_HPP + +#include +#include +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_any_of{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(), + [](auto) { return hana::true_c; } + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}), + hana::equal.to(ct_eq<999>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::equal.to(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::equal.to(ct_eq<999>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::equal.to(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::equal.to(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::equal.to(ct_eq<999>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::equal.to(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::equal.to(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::equal.to(ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::equal.to(ct_eq<999>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + [](auto) { return hana::false_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + [](auto) { return hana::true_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<999>{}) + ))); + + // Make sure `any_of` short-circuits with runtime predicates + // See http://stackoverflow.com/q/42012512/627587 + { + { + int counter = 0; + auto tuple = MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}); + hana::any_of(tuple, [&](auto) { ++counter; return true; }); + BOOST_HANA_RUNTIME_CHECK(counter == 1); + } + { + int counter = 0; + auto tuple = MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + hana::any_of(tuple, [&](auto x) -> bool { + ++counter; + return hana::equal(x, ct_eq<1>{}); + }); + BOOST_HANA_RUNTIME_CHECK(counter == 2); + } + } +}}; + +#endif // !BOOST_HANA_TEST_AUTO_ANY_OF_HPP diff --git a/src/boost/libs/hana/test/_include/auto/ap.hpp b/src/boost/libs/hana/test/_include/auto/ap.hpp new file mode 100644 index 000000000..7fe0fc5be --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/ap.hpp @@ -0,0 +1,76 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_AP_HPP +#define BOOST_HANA_TEST_AUTO_AP_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_ap{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + hana::test::_injection<0> f{}; + hana::test::_injection<1> g{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f), MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(f(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f, g), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f, g), MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(f(ct_eq<0>{}), g(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f, g), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{}), g(ct_eq<0>{}), g(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(MAKE_TUPLE(f, g), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{}), + g(ct_eq<0>{}), g(ct_eq<1>{}), g(ct_eq<2>{})) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_AP_HPP diff --git a/src/boost/libs/hana/test/_include/auto/at.hpp b/src/boost/libs/hana/test/_include/auto/at.hpp new file mode 100644 index 000000000..66574a361 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/at.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_AUTO_AT_HPP +#define BOOST_HANA_TEST_AUTO_AT_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +namespace _test_at_detail { template struct invalid { }; } + + +TestCase test_at{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + using _test_at_detail::invalid; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(MAKE_TUPLE(ct_eq<0>{}, invalid<1>{}), hana::size_c<0>), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(MAKE_TUPLE(invalid<0>{}, ct_eq<1>{}), hana::size_c<1>), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(MAKE_TUPLE(invalid<0>{}, ct_eq<1>{}, invalid<2>{}), hana::size_c<1>), + ct_eq<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(MAKE_TUPLE(invalid<0>{}, invalid<1>{}, ct_eq<2>{}), hana::size_c<2>), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(MAKE_TUPLE(invalid<0>{}, invalid<1>{}, ct_eq<2>{}, invalid<3>{}), hana::size_c<2>), + ct_eq<2>{} + )); + +#ifndef MAKE_TUPLE_NO_CONSTEXPR + static_assert(hana::equal( + hana::at(MAKE_TUPLE(1), hana::size_c<0>), + 1 + ), ""); + static_assert(hana::equal( + hana::at(MAKE_TUPLE(1, '2'), hana::size_c<0>), + 1 + ), ""); + static_assert(hana::equal( + hana::at(MAKE_TUPLE(1, '2', 3.3), hana::size_c<0>), + 1 + ), ""); + + static_assert(hana::equal( + hana::at(MAKE_TUPLE(1, '2'), hana::size_c<1>), + '2' + ), ""); + static_assert(hana::equal( + hana::at(MAKE_TUPLE(1, '2', 3.3), hana::size_c<1>), + '2' + ), ""); + + static_assert(hana::equal( + hana::at(MAKE_TUPLE(1, '2', 3.3), hana::size_c<2>), + 3.3 + ), ""); +#endif + + // make sure we can use non-pods on both sides + { + // store the result to make sure `at` is executed. + auto result = hana::at(MAKE_TUPLE(Tracked{0}, ct_eq<1>{}, Tracked{1}), hana::size_c<1>);; + BOOST_HANA_CONSTANT_CHECK(hana::equal(result, ct_eq<1>{})); + } + +}}; + +#endif // !BOOST_HANA_TEST_AUTO_AT_HPP diff --git a/src/boost/libs/hana/test/_include/auto/cartesian_product.hpp b/src/boost/libs/hana/test/_include/auto/cartesian_product.hpp new file mode 100644 index 000000000..8aecf3649 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/cartesian_product.hpp @@ -0,0 +1,234 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_CARTESIAN_PRODUCT_HPP +#define BOOST_HANA_TEST_AUTO_CARTESIAN_PRODUCT_HPP + +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_cartesian_product{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + // 0 lists + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE()), + MAKE_TUPLE() + )); + + // 1 list + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE() + )), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{}), + MAKE_TUPLE(ct_eq<3>{}) + ) + )); + + // 2 lists + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(), + MAKE_TUPLE() + )), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}), + MAKE_TUPLE() + )), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}), + MAKE_TUPLE(ct_eq<10>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<01>{}), + MAKE_TUPLE(ct_eq<10>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}), + MAKE_TUPLE(ct_eq<01>{}, ct_eq<10>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}), + MAKE_TUPLE(ct_eq<10>{}, ct_eq<11>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}), + MAKE_TUPLE(ct_eq<00>{}, ct_eq<11>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<01>{}), + MAKE_TUPLE(ct_eq<10>{}, ct_eq<11>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}), + MAKE_TUPLE(ct_eq<00>{}, ct_eq<11>{}), + MAKE_TUPLE(ct_eq<01>{}, ct_eq<10>{}), + MAKE_TUPLE(ct_eq<01>{}, ct_eq<11>{}) + ) + )); + + // misc + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}), + MAKE_TUPLE(ct_eq<10>{}), + MAKE_TUPLE(ct_eq<20>{}), + MAKE_TUPLE(ct_eq<30>{}, ct_eq<31>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}, ct_eq<20>{}, ct_eq<30>{}), + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}, ct_eq<20>{}, ct_eq<31>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}), + MAKE_TUPLE(ct_eq<10>{}), + MAKE_TUPLE(ct_eq<20>{}, ct_eq<21>{}), + MAKE_TUPLE(ct_eq<30>{}, ct_eq<31>{}) + )), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}, ct_eq<20>{}, ct_eq<30>{}), + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}, ct_eq<20>{}, ct_eq<31>{}), + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}, ct_eq<21>{}, ct_eq<30>{}), + MAKE_TUPLE(ct_eq<00>{}, ct_eq<10>{}, ct_eq<21>{}, ct_eq<31>{}) + ) + )); + + + // cartesian_product in a constexpr context +#ifndef MAKE_TUPLE_NO_CONSTEXPR + static_assert(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(1), + MAKE_TUPLE('a', 'b') + )), + MAKE_TUPLE( + MAKE_TUPLE(1, 'a'), + MAKE_TUPLE(1, 'b') + ) + ), ""); + + static_assert(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(1, 2), + MAKE_TUPLE('a') + )), + MAKE_TUPLE( + MAKE_TUPLE(1, 'a'), + MAKE_TUPLE(2, 'a') + ) + ), ""); + + static_assert(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(1, 2), + MAKE_TUPLE('a', 'b') + )), + MAKE_TUPLE( + MAKE_TUPLE(1, 'a'), + MAKE_TUPLE(1, 'b'), + MAKE_TUPLE(2, 'a'), + MAKE_TUPLE(2, 'b') + ) + ), ""); + + static_assert(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(1), + MAKE_TUPLE('a'), + MAKE_TUPLE(1.f), + MAKE_TUPLE(1l, 2l) + )), + MAKE_TUPLE( + MAKE_TUPLE(1, 'a', 1.f, 1l), + MAKE_TUPLE(1, 'a', 1.f, 2l) + ) + ), ""); + + static_assert(hana::equal( + hana::cartesian_product(MAKE_TUPLE( + MAKE_TUPLE(1), + MAKE_TUPLE('a'), + MAKE_TUPLE(1.f), + MAKE_TUPLE(1l, 2l), + MAKE_TUPLE(nullptr) + )), + MAKE_TUPLE( + MAKE_TUPLE(1, 'a', 1.f, 1l, nullptr), + MAKE_TUPLE(1, 'a', 1.f, 2l, nullptr) + ) + ), ""); +#endif +}}; + +#endif // !BOOST_HANA_TEST_AUTO_CARTESIAN_PRODUCT_HPP diff --git a/src/boost/libs/hana/test/_include/auto/drop_back.hpp b/src/boost/libs/hana/test/_include/auto/drop_back.hpp new file mode 100644 index 000000000..e3ea42e0c --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/drop_back.hpp @@ -0,0 +1,99 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_DROP_BACK_HPP +#define BOOST_HANA_TEST_AUTO_DROP_BACK_HPP + +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_drop_back{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(), hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<3>), + MAKE_TUPLE() + )); + + // make sure hana::drop_back(xs) == hana::drop_back(xs, hana::size_c<1>) + BOOST_HANA_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE()), + hana::drop_back(MAKE_TUPLE(), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{})), + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{})), + hana::drop_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}), hana::size_c<1>) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_DROP_BACK_HPP diff --git a/src/boost/libs/hana/test/_include/auto/drop_front.hpp b/src/boost/libs/hana/test/_include/auto/drop_front.hpp new file mode 100644 index 000000000..05988ace2 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/drop_front.hpp @@ -0,0 +1,160 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_DROP_FRONT_HPP +#define BOOST_HANA_TEST_AUTO_DROP_FRONT_HPP + +#include +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_drop_front{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(), hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<2>), + MAKE_TUPLE(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<3>), + MAKE_TUPLE() + )); + + // make sure hana::drop_front(xs) == hana::drop_front(xs, size_c<1>) + BOOST_HANA_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE()), + hana::drop_front(MAKE_TUPLE(), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{})), + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{})), + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}), hana::size_c<1>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); +}}; + +TestCase test_drop_front_exactly{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(), hana::size_c<0>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, + ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), hana::size_c<4>), + MAKE_TUPLE(ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}) + )); + + // make sure drop_front_exactly(xs) == drop_front_exactly(xs, size_c<1>) + BOOST_HANA_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{})), + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{})), + hana::drop_front_exactly(MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}), hana::size_c<1>) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_DROP_FRONT_HPP diff --git a/src/boost/libs/hana/test/_include/auto/drop_while.hpp b/src/boost/libs/hana/test/_include/auto/drop_while.hpp new file mode 100644 index 000000000..054d79be0 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/drop_while.hpp @@ -0,0 +1,72 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_DROP_WHILE_HPP +#define BOOST_HANA_TEST_AUTO_DROP_WHILE_HPP + +#include +#include +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_drop_while{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(), hana::id), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(hana::true_c), hana::id), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(hana::false_c), hana::id), + MAKE_TUPLE(hana::false_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(hana::true_c, hana::true_c), hana::id), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(hana::true_c, hana::false_c), hana::id), + MAKE_TUPLE(hana::false_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(hana::false_c, hana::true_c), hana::id), + MAKE_TUPLE(hana::false_c, hana::true_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(hana::false_c, hana::false_c), hana::id), + MAKE_TUPLE(hana::false_c, hana::false_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::not_equal.to(ct_eq<99>{})), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::not_equal.to(ct_eq<1>{})), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(ct_eq<3>{})), + MAKE_TUPLE(ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_while(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(ct_eq<0>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_DROP_WHILE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/for_each.hpp b/src/boost/libs/hana/test/_include/auto/for_each.hpp new file mode 100644 index 000000000..4e36e9853 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/for_each.hpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_FOR_EACH_HPP +#define BOOST_HANA_TEST_AUTO_FOR_EACH_HPP + +#include +#include + +#include "test_case.hpp" +#include + +#include + + +TestCase test_for_each{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + // Make sure the function is applied in left-to-right order. + { + auto check = [](auto ...xs) { + std::vector seen{}; + hana::for_each(MAKE_TUPLE(xs...), [&](int x) { + seen.push_back(x); + }); + BOOST_HANA_RUNTIME_CHECK(seen == std::vector{xs...}); + }; + + check(); + check(0); + check(0, 1); + check(0, 1, 2); + check(0, 1, 2, 3); + check(0, 1, 2, 3, 4); + } + + // Make sure the function is never called when the sequence is empty. + { + struct undefined { }; + hana::for_each(MAKE_TUPLE(), undefined{}); + } + + // Make sure it works with heterogeneous sequences. + { + hana::for_each(MAKE_TUPLE(ct_eq<0>{}), [](auto) { }); + hana::for_each(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), [](auto) { }); + hana::for_each(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), [](auto) { }); + hana::for_each(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), [](auto) { }); + } + + // Make sure for_each is constexpr when used with a constexpr function + // and constexpr arguments. This used not to be the case. +#ifndef MAKE_TUPLE_NO_CONSTEXPR + { + struct f { constexpr void operator()(int) const { } }; + constexpr int i = (hana::for_each(MAKE_TUPLE(1, 2, 3), f{}), 0); + (void)i; + } +#endif +}}; + +#endif // !BOOST_HANA_TEST_AUTO_FOR_EACH_HPP diff --git a/src/boost/libs/hana/test/_include/auto/group.hpp b/src/boost/libs/hana/test/_include/auto/group.hpp new file mode 100644 index 000000000..1802ebd33 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/group.hpp @@ -0,0 +1,150 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_GROUP_HPP +#define BOOST_HANA_TEST_AUTO_GROUP_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +TestCase test_group{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + struct undefined { }; + + // Test without a custom predicate + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE()), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<0>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}), + MAKE_TUPLE(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{}, ct_eq<0>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<1>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<1>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<2>{}, ct_eq<2>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<2>{}, ct_eq<2>{})) + )); + } + + // Test with a custom predicate + { + auto a = [](auto z) { return ::equivalence_class(ct_eq<999>{}, z); }; + auto b = [](auto z) { return ::equivalence_class(ct_eq<888>{}, z); }; + + auto pred = [](auto x, auto y) { + return hana::equal(x.unwrap, y.unwrap); + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(), undefined{}), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(a(ct_eq<0>{})), pred), + MAKE_TUPLE( + MAKE_TUPLE(a(ct_eq<0>{}))) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{})), pred), + MAKE_TUPLE( + MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}))) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}), a(ct_eq<1>{})), pred), + MAKE_TUPLE( + MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{})), + MAKE_TUPLE(a(ct_eq<1>{}))) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}), a(ct_eq<1>{}), b(ct_eq<1>{})), pred), + MAKE_TUPLE( + MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{})), + MAKE_TUPLE(a(ct_eq<1>{}), b(ct_eq<1>{}))) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}), a(ct_eq<1>{}), b(ct_eq<1>{}), b(ct_eq<0>{})), pred), + MAKE_TUPLE( + MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{})), + MAKE_TUPLE(a(ct_eq<1>{}), b(ct_eq<1>{})), + MAKE_TUPLE(b(ct_eq<0>{}))) + )); + + // Test group.by syntactic sugar + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group.by(pred, MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}), a(ct_eq<1>{}), b(ct_eq<1>{}), b(ct_eq<0>{}))), + MAKE_TUPLE( + MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{})), + MAKE_TUPLE(a(ct_eq<1>{}), b(ct_eq<1>{})), + MAKE_TUPLE(b(ct_eq<0>{}))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::group.by(pred)(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}), a(ct_eq<1>{}), b(ct_eq<1>{}), b(ct_eq<0>{}))), + MAKE_TUPLE( + MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{})), + MAKE_TUPLE(a(ct_eq<1>{}), b(ct_eq<1>{})), + MAKE_TUPLE(b(ct_eq<0>{}))) + )); + } +}}; + +#endif // !BOOST_HANA_TEST_AUTO_GROUP_HPP diff --git a/src/boost/libs/hana/test/_include/auto/index_if.hpp b/src/boost/libs/hana/test/_include/auto/index_if.hpp new file mode 100644 index 000000000..af7c86bbc --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/index_if.hpp @@ -0,0 +1,81 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_INDEX_IF_HPP +#define BOOST_HANA_TEST_AUTO_INDEX_IF_HPP + +#include +#include +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +namespace _test_index_if_detail { template struct invalid { }; } + + +TestCase test_index_if{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + using _test_index_if_detail::invalid; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::index_if(MAKE_TUPLE(), hana::equal.to(ct_eq<0>{})), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::index_if(MAKE_TUPLE(ct_eq<0>{}), hana::equal.to(ct_eq<0>{})), + hana::just(hana::size_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::index_if(MAKE_TUPLE(ct_eq<0>{}), hana::equal.to(ct_eq<42>{})), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::index_if(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(ct_eq<0>{})), + hana::just(hana::size_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::index_if(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(ct_eq<1>{})), + hana::just(hana::size_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::index_if(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(ct_eq<2>{})), + hana::just(hana::size_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::index_if(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(ct_eq<42>{})), + hana::nothing + )); + +#ifndef MAKE_TUPLE_NO_CONSTEXPR + auto type_equal = [](auto type) { return [=](auto&& value) { + return hana::equal(hana::typeid_(value), type); + };}; + + static_assert(decltype(hana::equal( + hana::index_if(MAKE_TUPLE(1, '2', 3.3), type_equal(hana::type_c)), + hana::just(hana::size_c<0>) + )){}, ""); + static_assert(decltype(hana::equal( + hana::index_if(MAKE_TUPLE(1, '2', 3.3), type_equal(hana::type_c)), + hana::just(hana::size_c<1>) + )){}, ""); + static_assert(decltype(hana::equal( + hana::index_if(MAKE_TUPLE(1, '2', 3.3), type_equal(hana::type_c)), + hana::just(hana::size_c<2>) + )){}, ""); + static_assert(decltype(hana::equal( + hana::index_if(MAKE_TUPLE(1, '2', 3.3), type_equal(hana::type_c>)), + hana::nothing + )){}, ""); +#endif +}}; + +#endif // !BOOST_HANA_TEST_AUTO_INDEX_IF_HPP diff --git a/src/boost/libs/hana/test/_include/auto/insert.hpp b/src/boost/libs/hana/test/_include/auto/insert.hpp new file mode 100644 index 000000000..c9715452a --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/insert.hpp @@ -0,0 +1,84 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_INSERT_HPP +#define BOOST_HANA_TEST_AUTO_INSERT_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_insert{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + auto z = ct_eq<999>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>, z), + MAKE_TUPLE(z, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>, z), + MAKE_TUPLE(ct_eq<0>{}, z) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>, z), + MAKE_TUPLE(z, ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>, z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<2>, z), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, z) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<0>, z), + MAKE_TUPLE(z, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<1>, z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<2>, z), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, z, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::size_c<3>, z), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, z) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<0>, z), + MAKE_TUPLE(z, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<1>, z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<2>, z), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, z, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<3>, z), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, z, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<4>, z), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, z) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_INSERT_HPP diff --git a/src/boost/libs/hana/test/_include/auto/insert_range.hpp b/src/boost/libs/hana/test/_include/auto/insert_range.hpp new file mode 100644 index 000000000..ac929d7ed --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/insert_range.hpp @@ -0,0 +1,105 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_INSERT_RANGE_HPP +#define BOOST_HANA_TEST_AUTO_INSERT_RANGE_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +TestCase test_insert_range{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + auto foldable = ::seq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}), + hana::size_c<0>, + foldable()), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}), + hana::size_c<0>, + foldable(ct_eq<-1>{})), + MAKE_TUPLE(ct_eq<-1>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}), + hana::size_c<0>, + foldable(ct_eq<-1>{}, ct_eq<-2>{})), + MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}), + hana::size_c<0>, + foldable(ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<-3>{})), + MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<-3>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<0>, + foldable()), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<0>, + foldable(ct_eq<-1>{})), + MAKE_TUPLE(ct_eq<-1>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<0>, + foldable(ct_eq<-1>{}, ct_eq<-2>{})), + MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<1>, + foldable()), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<1>, + foldable(ct_eq<-1>{})), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<-1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<1>, + foldable(ct_eq<-1>{}, ct_eq<-2>{})), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert_range( + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::size_c<2>, + foldable(ct_eq<-1>{}, ct_eq<-2>{})), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_INSERT_RANGE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/intersperse.hpp b/src/boost/libs/hana/test/_include/auto/intersperse.hpp new file mode 100644 index 000000000..83e7e8148 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/intersperse.hpp @@ -0,0 +1,54 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_INTERSPERSE_HPP +#define BOOST_HANA_TEST_AUTO_INTERSPERSE_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_intersperse{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + struct undefined { }; + + auto z = ct_eq<999>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersperse(MAKE_TUPLE(), undefined{}), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersperse(MAKE_TUPLE(ct_eq<0>{}), undefined{}), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersperse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersperse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}, z, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersperse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}, z, ct_eq<2>{}, z, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersperse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}, z, ct_eq<2>{}, z, ct_eq<3>{}, z, ct_eq<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersperse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}), z), + MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<1>{}, z, ct_eq<2>{}, z, ct_eq<3>{}, z, ct_eq<4>{}, z, ct_eq<5>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_INTERSPERSE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/is_empty.hpp b/src/boost/libs/hana/test/_include/auto/is_empty.hpp new file mode 100644 index 000000000..99ae879dd --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/is_empty.hpp @@ -0,0 +1,55 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_IS_EMPTY_HPP +#define BOOST_HANA_TEST_AUTO_IS_EMPTY_HPP + +#include +#include +#include + +#include "test_case.hpp" + + +namespace _test_is_empty_detail { template struct undefined { }; } + +TestCase test_is_empty{[]{ + namespace hana = boost::hana; + using _test_is_empty_detail::undefined; + + BOOST_HANA_CONSTANT_CHECK(hana::is_empty( + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + MAKE_TUPLE(undefined<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + MAKE_TUPLE(undefined<0>{}, undefined<1>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + MAKE_TUPLE(undefined<0>{}, undefined<1>{}, undefined<2>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + MAKE_TUPLE(undefined<0>{}, undefined<1>{}, undefined<2>{}, undefined<3>{}) + ))); + + // Check with a runtime value + { + int i = 3; // <- runtime value + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(MAKE_TUPLE(i)))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(MAKE_TUPLE(i, i)))); + } + +#ifndef MAKE_TUPLE_NO_CONSTEXPR + static_assert(hana::is_empty(MAKE_TUPLE()), ""); + static_assert(hana::not_(hana::is_empty(MAKE_TUPLE(undefined<0>{}))), ""); + static_assert(hana::not_(hana::is_empty(MAKE_TUPLE(undefined<0>{}, undefined<1>{}))), ""); +#endif +}}; + +#endif // !BOOST_HANA_TEST_AUTO_IS_EMPTY_HPP diff --git a/src/boost/libs/hana/test/_include/auto/length.hpp b/src/boost/libs/hana/test/_include/auto/length.hpp new file mode 100644 index 000000000..25f75dc4d --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/length.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_AUTO_LENGTH_HPP +#define BOOST_HANA_TEST_AUTO_LENGTH_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" + + +namespace _test_length_detail { template struct undefined { }; } + +TestCase test_length{[]{ + namespace hana = boost::hana; + using _test_length_detail::undefined; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(MAKE_TUPLE()), + hana::size_c<0> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(MAKE_TUPLE(undefined<1>{})), + hana::size_c<1> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(MAKE_TUPLE(undefined<1>{}, undefined<2>{})), + hana::size_c<2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(MAKE_TUPLE(undefined<1>{}, undefined<2>{}, undefined<3>{})), + hana::size_c<3> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(MAKE_TUPLE(undefined<1>{}, undefined<2>{}, undefined<3>{}, undefined<4>{}, undefined<5>{}, undefined<6>{})), + hana::size_c<6> + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_LENGTH_HPP diff --git a/src/boost/libs/hana/test/_include/auto/lexicographical_compare.hpp b/src/boost/libs/hana/test/_include/auto/lexicographical_compare.hpp new file mode 100644 index 000000000..83870d561 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/lexicographical_compare.hpp @@ -0,0 +1,109 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_LEXICOGRAPHICAL_COMPARE_HPP +#define BOOST_HANA_TEST_AUTO_LEXICOGRAPHICAL_COMPARE_HPP + +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_lexicographical_compare{[]{ + namespace hana = boost::hana; + using hana::test::ct_ord; + + struct undefined { }; + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(), + MAKE_TUPLE() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare( + MAKE_TUPLE(), + MAKE_TUPLE(undefined{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(undefined{}), + MAKE_TUPLE() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}), + MAKE_TUPLE(ct_ord<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}), + MAKE_TUPLE(ct_ord<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<1>{}), + MAKE_TUPLE(ct_ord<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, undefined{}), + MAKE_TUPLE(ct_ord<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}), + MAKE_TUPLE(ct_ord<0>{}, undefined{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<0>{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, undefined{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, undefined{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<3>{}, undefined{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, undefined{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, undefined{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<3>{}, undefined{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, undefined{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::lexicographical_compare( + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<3>{}), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, undefined{}) + ))); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_LEXICOGRAPHICAL_COMPARE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/make.hpp b/src/boost/libs/hana/test/_include/auto/make.hpp new file mode 100644 index 000000000..83536edfd --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/make.hpp @@ -0,0 +1,41 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_MAKE_HPP +#define BOOST_HANA_TEST_AUTO_MAKE_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_make{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + MAKE_TUPLE(), + hana::make() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + MAKE_TUPLE(ct_eq<0>{}), + hana::make(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::make(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_MAKE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/none_of.hpp b/src/boost/libs/hana/test/_include/auto/none_of.hpp new file mode 100644 index 000000000..7e1dff2d8 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/none_of.hpp @@ -0,0 +1,90 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_NONE_OF_HPP +#define BOOST_HANA_TEST_AUTO_NONE_OF_HPP + +#include +#include +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_none_of{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::none_of( + MAKE_TUPLE(), + [](auto) { return hana::false_c; } + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}), + [](auto) { return hana::true_c; } + ))); + BOOST_HANA_CONSTANT_CHECK(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}), + [](auto) { return hana::false_c; } + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}), + hana::equal.to(ct_eq<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}), + hana::equal.to(ct_eq<999>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<1>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<2>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<3>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<4>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::none_of( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::equal.to(ct_eq<999>{}) + )); + + // Make sure `none_of` short-circuits with runtime predicates + // See http://stackoverflow.com/q/42012512/627587 + { + { + int counter = 0; + auto tuple = MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}); + hana::none_of(tuple, [&](auto) { ++counter; return true; }); + BOOST_HANA_RUNTIME_CHECK(counter == 1); + } + { + int counter = 0; + auto tuple = MAKE_TUPLE(ct_eq<999>{}, ct_eq<0>{}, ct_eq<999>{}); + hana::none_of(tuple, [&](auto x) -> bool { + ++counter; + return hana::equal(x, ct_eq<0>{}); + }); + BOOST_HANA_RUNTIME_CHECK(counter == 2); + } + } +}}; + +#endif // !BOOST_HANA_TEST_AUTO_NONE_OF_HPP diff --git a/src/boost/libs/hana/test/_include/auto/partition.hpp b/src/boost/libs/hana/test/_include/auto/partition.hpp new file mode 100644 index 000000000..d1fa7212e --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/partition.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_AUTO_PARTITION_HPP +#define BOOST_HANA_TEST_AUTO_PARTITION_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +TestCase test_partition{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + struct undefined { }; + + auto pair = ::minimal_product; + auto pred = hana::in ^ MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<-3>{}, ct_eq<-4>{}, ct_eq<-5>{}); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition(MAKE_TUPLE(), undefined{}), + pair(MAKE_TUPLE(), MAKE_TUPLE()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition(MAKE_TUPLE(ct_eq<0>{}), pred), + pair(MAKE_TUPLE(), + MAKE_TUPLE(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), pred), + pair(MAKE_TUPLE(), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition(MAKE_TUPLE(ct_eq<-1>{}), pred), + pair(MAKE_TUPLE(ct_eq<-1>{}), + MAKE_TUPLE()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition(MAKE_TUPLE(ct_eq<-1>{}, ct_eq<0>{}, ct_eq<2>{}), pred), + pair(MAKE_TUPLE(ct_eq<-1>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition(MAKE_TUPLE(ct_eq<0>{}, ct_eq<-3>{}, ct_eq<2>{}, ct_eq<-5>{}, ct_eq<6>{}), pred), + pair(MAKE_TUPLE(ct_eq<-3>{}, ct_eq<-5>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<6>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition(MAKE_TUPLE(ct_eq<-1>{}, ct_eq<2>{}, ct_eq<-3>{}, ct_eq<0>{}, ct_eq<-3>{}, ct_eq<4>{}), pred), + pair(MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-3>{}, ct_eq<-3>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<0>{}, ct_eq<4>{})) + )); + + // partition.by + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition.by(pred, MAKE_TUPLE(ct_eq<-1>{}, ct_eq<0>{}, ct_eq<2>{})), + hana::partition(MAKE_TUPLE(ct_eq<-1>{}, ct_eq<0>{}, ct_eq<2>{}), pred) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partition.by(pred)(MAKE_TUPLE(ct_eq<-1>{}, ct_eq<0>{}, ct_eq<2>{})), + hana::partition(MAKE_TUPLE(ct_eq<-1>{}, ct_eq<0>{}, ct_eq<2>{}), pred) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_PARTITION_HPP diff --git a/src/boost/libs/hana/test/_include/auto/permutations.hpp b/src/boost/libs/hana/test/_include/auto/permutations.hpp new file mode 100644 index 000000000..d854103ac --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/permutations.hpp @@ -0,0 +1,87 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_PERMUTATIONS_HPP +#define BOOST_HANA_TEST_AUTO_PERMUTATIONS_HPP + +#include +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_permutations{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + auto is_permutation = [](auto xs, auto ys) { + return hana::and_(hana::is_subset(xs, ys), hana::is_subset(ys, xs)); + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::permutations(MAKE_TUPLE()), + MAKE_TUPLE(MAKE_TUPLE()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::permutations(MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(is_permutation( + hana::permutations(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(is_permutation( + hana::permutations(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<0>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + ) + )); + + BOOST_HANA_CONSTANT_CHECK(is_permutation( + hana::permutations(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})), + MAKE_TUPLE( + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<3>{}, ct_eq<1>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{}, ct_eq<2>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{}, ct_eq<3>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<0>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<3>{}, ct_eq<0>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<0>{}, ct_eq<3>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<3>{}, ct_eq<0>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<3>{}, ct_eq<1>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<0>{}, ct_eq<2>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<1>{}, ct_eq<0>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<0>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<2>{}, ct_eq<0>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + ) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_PERMUTATIONS_HPP diff --git a/src/boost/libs/hana/test/_include/auto/remove_at.hpp b/src/boost/libs/hana/test/_include/auto/remove_at.hpp new file mode 100644 index 000000000..296b989e8 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/remove_at.hpp @@ -0,0 +1,130 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_REMOVE_AT_HPP +#define BOOST_HANA_TEST_AUTO_REMOVE_AT_HPP + +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_remove_at{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}), + hana::size_c<0>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::size_c<0>), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<0>), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::size_c<0>), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::size_c<0>), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::size_c<4>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + // remove_at_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at_c<0>(MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at_c<0>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at_c<1>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at_c<0>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at_c<1>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_at_c<2>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_REMOVE_AT_HPP diff --git a/src/boost/libs/hana/test/_include/auto/remove_range.hpp b/src/boost/libs/hana/test/_include/auto/remove_range.hpp new file mode 100644 index 000000000..51bbf9133 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/remove_range.hpp @@ -0,0 +1,114 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_REMOVE_RANGE_HPP +#define BOOST_HANA_TEST_AUTO_REMOVE_RANGE_HPP + +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_remove_range{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(), hana::size_c<0>, hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(), hana::size_c<1>, hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(), hana::size_c<2>, hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>, hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>, hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>, hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<2>, hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>, hana::size_c<0>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>, hana::size_c<1>), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>, hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>, hana::size_c<2>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<2>, hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::size_c<9999>, hana::size_c<9999>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<0>, hana::size_c<2>), + MAKE_TUPLE(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::size_c<1>, hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::size_c<0>, hana::size_c<2>), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::size_c<2>, hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, + ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::size_c<4>, hana::size_c<7>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}) + )); + + // remove_range_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::remove_range_c<4, 7>(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, + ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_REMOVE_RANGE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/reverse.hpp b/src/boost/libs/hana/test/_include/auto/reverse.hpp new file mode 100644 index 000000000..c0c2000c5 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/reverse.hpp @@ -0,0 +1,55 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_REVERSE_HPP +#define BOOST_HANA_TEST_AUTO_REVERSE_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_reverse{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + using hana::test::cx_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::reverse(MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::reverse(MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::reverse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::reverse(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + + +#ifndef MAKE_TUPLE_NO_CONSTEXPR + static_assert(hana::equal( + hana::reverse(MAKE_TUPLE(cx_eq<1>{})), + MAKE_TUPLE(cx_eq<1>{}) + ), ""); + static_assert(hana::equal( + hana::reverse(MAKE_TUPLE(cx_eq<1>{}, cx_eq<2>{})), + MAKE_TUPLE(cx_eq<2>{}, cx_eq<1>{}) + ), ""); + static_assert(hana::equal( + hana::reverse(MAKE_TUPLE(cx_eq<1>{}, cx_eq<2>{}, cx_eq<3>{})), + MAKE_TUPLE(cx_eq<3>{}, cx_eq<2>{}, cx_eq<1>{}) + ), ""); +#endif +}}; + +#endif // !BOOST_HANA_TEST_AUTO_REVERSE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/scans.hpp b/src/boost/libs/hana/test/_include/auto/scans.hpp new file mode 100644 index 000000000..5c5c0dd6a --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/scans.hpp @@ -0,0 +1,216 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_SCANS_HPP +#define BOOST_HANA_TEST_AUTO_SCANS_HPP + +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_scan_left{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + struct undefined { }; + hana::test::_injection<0> f{}; + + // Without initial state + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(), undefined{}), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}), undefined{}), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), f), + MAKE_TUPLE(ct_eq<0>{}, f(ct_eq<0>{}, ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f), + MAKE_TUPLE( + ct_eq<0>{}, + f(ct_eq<0>{}, ct_eq<1>{}), + f(f(ct_eq<0>{}, ct_eq<1>{}), ct_eq<2>{}) + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), f), + MAKE_TUPLE( + ct_eq<0>{}, + f(ct_eq<0>{}, ct_eq<1>{}), + f(f(ct_eq<0>{}, ct_eq<1>{}), ct_eq<2>{}), + f(f(f(ct_eq<0>{}, ct_eq<1>{}), ct_eq<2>{}), ct_eq<3>{}) + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), f), + MAKE_TUPLE( + ct_eq<0>{}, + f(ct_eq<0>{}, ct_eq<1>{}), + f(f(ct_eq<0>{}, ct_eq<1>{}), ct_eq<2>{}), + f(f(f(ct_eq<0>{}, ct_eq<1>{}), ct_eq<2>{}), ct_eq<3>{}), + f(f(f(f(ct_eq<0>{}, ct_eq<1>{}), ct_eq<2>{}), ct_eq<3>{}), ct_eq<4>{}) + ) + )); + + // With initial state + auto s = ct_eq<999>{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(), s, undefined{}), + MAKE_TUPLE(s) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}), s, f), + MAKE_TUPLE(s, f(s, ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), s, f), + MAKE_TUPLE(s, f(s, ct_eq<0>{}), f(f(s, ct_eq<0>{}), ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), s, f), + MAKE_TUPLE( + s, + f(s, ct_eq<0>{}), + f(f(s, ct_eq<0>{}), ct_eq<1>{}), + f(f(f(s, ct_eq<0>{}), ct_eq<1>{}), ct_eq<2>{}) + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), s, f), + MAKE_TUPLE( + s, + f(s, ct_eq<0>{}), + f(f(s, ct_eq<0>{}), ct_eq<1>{}), + f(f(f(s, ct_eq<0>{}), ct_eq<1>{}), ct_eq<2>{}), + f(f(f(f(s, ct_eq<0>{}), ct_eq<1>{}), ct_eq<2>{}), ct_eq<3>{}) + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_left(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), s, f), + MAKE_TUPLE( + s, + f(s, ct_eq<0>{}), + f(f(s, ct_eq<0>{}), ct_eq<1>{}), + f(f(f(s, ct_eq<0>{}), ct_eq<1>{}), ct_eq<2>{}), + f(f(f(f(s, ct_eq<0>{}), ct_eq<1>{}), ct_eq<2>{}), ct_eq<3>{}), + f(f(f(f(f(s, ct_eq<0>{}), ct_eq<1>{}), ct_eq<2>{}), ct_eq<3>{}), ct_eq<4>{}) + ) + )); +}}; + + +TestCase test_scan_right{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + struct undefined { }; + hana::test::_injection<0> f{}; + + // Without initial state + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(), undefined{}), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}), undefined{}), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), f), + MAKE_TUPLE( + f(ct_eq<0>{}, ct_eq<1>{}), + ct_eq<1>{} + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f), + MAKE_TUPLE( + f(ct_eq<0>{}, f(ct_eq<1>{}, ct_eq<2>{})), + f(ct_eq<1>{}, ct_eq<2>{}), + ct_eq<2>{} + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), f), + MAKE_TUPLE( + f(ct_eq<0>{}, f(ct_eq<1>{}, f(ct_eq<2>{}, ct_eq<3>{}))), + f(ct_eq<1>{}, f(ct_eq<2>{}, ct_eq<3>{})), + f(ct_eq<2>{}, ct_eq<3>{}), + ct_eq<3>{} + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), f), + MAKE_TUPLE( + f(ct_eq<0>{}, f(ct_eq<1>{}, f(ct_eq<2>{}, f(ct_eq<3>{}, ct_eq<4>{})))), + f(ct_eq<1>{}, f(ct_eq<2>{}, f(ct_eq<3>{}, ct_eq<4>{}))), + f(ct_eq<2>{}, f(ct_eq<3>{}, ct_eq<4>{})), + f(ct_eq<3>{}, ct_eq<4>{}), + ct_eq<4>{} + ) + )); + + // With initial state + auto s = ct_eq<999>{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(), s, undefined{}), + MAKE_TUPLE(s) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}), s, f), + MAKE_TUPLE( + f(ct_eq<0>{}, s), + s + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), s, f), + MAKE_TUPLE( + f(ct_eq<0>{}, f(ct_eq<1>{}, s)), + f(ct_eq<1>{}, s), + s + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), s, f), + MAKE_TUPLE( + f(ct_eq<0>{}, f(ct_eq<1>{}, f(ct_eq<2>{}, s))), + f(ct_eq<1>{}, f(ct_eq<2>{}, s)), + f(ct_eq<2>{}, s), + s + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), s, f), + MAKE_TUPLE( + f(ct_eq<0>{}, f(ct_eq<1>{}, f(ct_eq<2>{}, f(ct_eq<3>{}, s)))), + f(ct_eq<1>{}, f(ct_eq<2>{}, f(ct_eq<3>{}, s))), + f(ct_eq<2>{}, f(ct_eq<3>{}, s)), + f(ct_eq<3>{}, s), + s + ) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::scan_right(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), s, f), + MAKE_TUPLE( + f(ct_eq<0>{}, f(ct_eq<1>{}, f(ct_eq<2>{}, f(ct_eq<3>{}, f(ct_eq<4>{}, s))))), + f(ct_eq<1>{}, f(ct_eq<2>{}, f(ct_eq<3>{}, f(ct_eq<4>{}, s)))), + f(ct_eq<2>{}, f(ct_eq<3>{}, f(ct_eq<4>{}, s))), + f(ct_eq<3>{}, f(ct_eq<4>{}, s)), + f(ct_eq<4>{}, s), + s + ) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_SCANS_HPP diff --git a/src/boost/libs/hana/test/_include/auto/sequence.hpp b/src/boost/libs/hana/test/_include/auto/sequence.hpp new file mode 100644 index 000000000..280b7355b --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/sequence.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_AUTO_SEQUENCE_HPP +#define BOOST_HANA_TEST_AUTO_SEQUENCE_HPP + +#include + + +static_assert(boost::hana::Sequence::value, ""); + +#endif // !BOOST_HANA_TEST_AUTO_SEQUENCE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/slice.hpp b/src/boost/libs/hana/test/_include/auto/slice.hpp new file mode 100644 index 000000000..3beb2ef0a --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/slice.hpp @@ -0,0 +1,182 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_SLICE_HPP +#define BOOST_HANA_TEST_AUTO_SLICE_HPP + +#include +#include +#include +#include +#include +#include + +#include "test_case.hpp" +#include +#include + +#include + + +TestCase test_slice{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + constexpr auto foldable = ::seq; + + struct undefined { }; + + ////////////////////////////////////////////////////////////////////////// + // Test with arbitrary indices + ////////////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(), + foldable()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}), + foldable()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}, undefined{}), + foldable()), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}), + foldable(hana::size_c<0>)), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, undefined{}), + foldable(hana::size_c<0>)), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}, ct_eq<1>{}), + foldable(hana::size_c<1>)), + MAKE_TUPLE(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + foldable(hana::size_c<0>, hana::size_c<1>)), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + foldable(hana::size_c<1>, hana::size_c<0>)), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + foldable(hana::size_c<0>, hana::size_c<0>)), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + foldable(hana::size_c<1>, hana::size_c<1>)), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + foldable(hana::size_c<0>, hana::size_c<1>, hana::size_c<2>)), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + foldable(hana::size_c<0>, hana::size_c<2>, hana::size_c<1>)), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + foldable(hana::size_c<0>, hana::size_c<2>, hana::size_c<1>, hana::size_c<0>)), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + foldable(hana::size_c<0>, hana::size_c<2>, hana::size_c<1>, hana::size_c<0>, hana::size_c<1>)), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}, ct_eq<1>{}) + )); + + // Try with a tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::tuple_c), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<3>{}, ct_eq<2>{}) + )); + + + + ////////////////////////////////////////////////////////////////////////// + // Test with a `range` (check the optimization for contiguous indices) + ////////////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(), + hana::range_c), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}), + hana::range_c), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}, undefined{}), + hana::range_c), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}), + hana::range_c), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, undefined{}), + hana::range_c), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}, ct_eq<1>{}), + hana::range_c), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}, ct_eq<1>{}, undefined{}), + hana::range_c), + MAKE_TUPLE(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + hana::range_c), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, undefined{}), + hana::range_c), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}, ct_eq<1>{}, ct_eq<2>{}), + hana::range_c), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::slice(MAKE_TUPLE(undefined{}, ct_eq<1>{}, ct_eq<2>{}, undefined{}), + hana::range_c), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_SLICE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/sort.hpp b/src/boost/libs/hana/test/_include/auto/sort.hpp new file mode 100644 index 000000000..398584fef --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/sort.hpp @@ -0,0 +1,111 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_SORT_HPP +#define BOOST_HANA_TEST_AUTO_SORT_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +TestCase test_sort{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + using hana::test::ct_ord; + + // Test without a custom predicate + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(ct_ord<0>{})), + MAKE_TUPLE(ct_ord<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{})), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(ct_ord<1>{}, ct_ord<0>{})), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(ct_ord<1>{}, ct_ord<0>{}, ct_ord<4>{}, ct_ord<2>{})), + MAKE_TUPLE(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(ct_ord<1>{}, ct_ord<0>{}, ct_ord<-4>{}, ct_ord<2>{})), + MAKE_TUPLE(ct_ord<-4>{}, ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) + )); + } + + // Test with a custom predicate + { + auto pred = [](auto x, auto y) { + return hana::less(x.unwrap, y.unwrap); + }; + auto a = [](auto z) { return ::equivalence_class(ct_eq<999>{}, z); }; + auto b = [](auto z) { return ::equivalence_class(ct_eq<888>{}, z); }; + + auto check = [=](auto ...sorted) { + auto perms = hana::transform( + hana::permutations(MAKE_TUPLE(a(sorted)...)), + hana::sort.by(pred) + ); + BOOST_HANA_CONSTANT_CHECK(hana::all_of(perms, [=](auto xs) { + return hana::equal(xs, MAKE_TUPLE(a(sorted)...)); + })); + }; + + check(); + check(ct_ord<1>{}); + check(ct_ord<1>{}, ct_ord<2>{}); + check(ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}); + + // check stability + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(a(ct_ord<1>{}), b(ct_ord<1>{})), pred), + MAKE_TUPLE(a(ct_ord<1>{}), b(ct_ord<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(b(ct_ord<1>{}), a(ct_ord<1>{})), pred), + MAKE_TUPLE(b(ct_ord<1>{}), a(ct_ord<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(a(ct_ord<1>{}), b(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<2>{})), pred), + MAKE_TUPLE(a(ct_ord<1>{}), b(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(a(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<1>{}), b(ct_ord<2>{})), pred), + MAKE_TUPLE(a(ct_ord<1>{}), b(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(b(ct_ord<1>{}), a(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<2>{})), pred), + MAKE_TUPLE(b(ct_ord<1>{}), a(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(a(ct_ord<2>{}), b(ct_ord<1>{}), b(ct_ord<2>{}), a(ct_ord<1>{})), pred), + MAKE_TUPLE(b(ct_ord<1>{}), a(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sort(MAKE_TUPLE(a(ct_ord<1>{}), a(ct_ord<3>{}), b(ct_ord<1>{}), a(ct_ord<2>{}), b(ct_ord<3>{})), pred), + MAKE_TUPLE(a(ct_ord<1>{}), b(ct_ord<1>{}), a(ct_ord<2>{}), a(ct_ord<3>{}), b(ct_ord<3>{})) + )); + } +}}; + +#endif // !BOOST_HANA_TEST_AUTO_SORT_HPP diff --git a/src/boost/libs/hana/test/_include/auto/span.hpp b/src/boost/libs/hana/test/_include/auto/span.hpp new file mode 100644 index 000000000..1a15d408b --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/span.hpp @@ -0,0 +1,84 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_SPAN_HPP +#define BOOST_HANA_TEST_AUTO_SPAN_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +TestCase test_span{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + auto z = ct_eq<999>{}; + auto pair = ::minimal_product; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(), hana::equal.to(z)), + pair(MAKE_TUPLE(), MAKE_TUPLE()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(ct_eq<0>{}), hana::equal.to(z)), + pair(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(z), hana::equal.to(z)), + pair(MAKE_TUPLE(z), MAKE_TUPLE()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(ct_eq<0>{}, z), hana::equal.to(z)), + pair(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{}, z)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(z, ct_eq<0>{}), hana::equal.to(z)), + pair(MAKE_TUPLE(z), MAKE_TUPLE(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::equal.to(z)), + pair(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(z)), + pair(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(z, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(z)), + pair(MAKE_TUPLE(z), MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<2>{}), hana::equal.to(z)), + pair(MAKE_TUPLE(), MAKE_TUPLE(ct_eq<0>{}, z, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(z, z, ct_eq<2>{}), hana::equal.to(z)), + pair(MAKE_TUPLE(z, z), MAKE_TUPLE(ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span(MAKE_TUPLE(z, z, z), hana::equal.to(z)), + pair(MAKE_TUPLE(z, z, z), MAKE_TUPLE()) + )); + + // span.by + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span.by(hana::equal.to(z), MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + hana::span(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(z)) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::span.by(hana::equal.to(z))(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + hana::span(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(z)) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_SPAN_HPP diff --git a/src/boost/libs/hana/test/_include/auto/take_back.hpp b/src/boost/libs/hana/test/_include/auto/take_back.hpp new file mode 100644 index 000000000..11a795e00 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/take_back.hpp @@ -0,0 +1,82 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_TAKE_BACK_HPP +#define BOOST_HANA_TEST_AUTO_TAKE_BACK_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_take_back{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(), hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::size_c<3>), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_back(MAKE_TUPLE( + ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, + ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::size_c<5>), + MAKE_TUPLE(ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_TAKE_BACK_HPP diff --git a/src/boost/libs/hana/test/_include/auto/take_front.hpp b/src/boost/libs/hana/test/_include/auto/take_front.hpp new file mode 100644 index 000000000..5e9b67338 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/take_front.hpp @@ -0,0 +1,77 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_TAKE_FRONT_HPP +#define BOOST_HANA_TEST_AUTO_TAKE_FRONT_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_take{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(), hana::size_c<1>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(), hana::size_c<2>), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}), hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<0>), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<1>), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<2>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), hana::size_c<3>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_front(MAKE_TUPLE( + ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, + ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}, ct_eq<11>{}, ct_eq<12>{}, ct_eq<13>{}), + hana::size_c<10>), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, + ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_TAKE_FRONT_HPP diff --git a/src/boost/libs/hana/test/_include/auto/take_while.hpp b/src/boost/libs/hana/test/_include/auto/take_while.hpp new file mode 100644 index 000000000..72d0b8b11 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/take_while.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_AUTO_TAKE_WHILE_HPP +#define BOOST_HANA_TEST_AUTO_TAKE_WHILE_HPP + +#include +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_take_while{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + auto z = ct_eq<999>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(), hana::not_equal.to(z)), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(ct_eq<1>{}), hana::not_equal.to(z)), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(z), hana::not_equal.to(z)), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), hana::not_equal.to(z)), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(ct_eq<1>{}, z), hana::not_equal.to(z)), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(z, ct_eq<2>{}), hana::not_equal.to(z)), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(z)), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, z), hana::not_equal.to(z)), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(ct_eq<1>{}, z, ct_eq<3>{}), hana::not_equal.to(z)), + MAKE_TUPLE(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::take_while(MAKE_TUPLE(z, ct_eq<2>{}, ct_eq<3>{}), hana::not_equal.to(z)), + MAKE_TUPLE() + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_TAKE_WHILE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/test_case.hpp b/src/boost/libs/hana/test/_include/auto/test_case.hpp new file mode 100644 index 000000000..03de19ac0 --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/test_case.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_AUTO_TEST_CASE_HPP +#define BOOST_HANA_TEST_AUTO_TEST_CASE_HPP + +struct TestCase { + template + explicit TestCase(F const& f) { f(); } +}; + +#endif // !BOOST_HANA_TEST_AUTO_TEST_CASE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/transform.hpp b/src/boost/libs/hana/test/_include/auto/transform.hpp new file mode 100644 index 000000000..478d725ac --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/transform.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_AUTO_TRANSFORM_HPP +#define BOOST_HANA_TEST_AUTO_TRANSFORM_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include + + +TestCase test_transform{[] { + namespace hana = boost::hana; + using hana::test::ct_eq; + struct undefined { }; + constexpr hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(MAKE_TUPLE(), undefined{}), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(MAKE_TUPLE(ct_eq<1>{}), f), + MAKE_TUPLE(f(ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), f), + MAKE_TUPLE(f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), f), + MAKE_TUPLE(f(ct_eq<1>{}), f(ct_eq<2>{}), f(ct_eq<3>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), f), + MAKE_TUPLE(f(ct_eq<1>{}), f(ct_eq<2>{}), f(ct_eq<3>{}), f(ct_eq<4>{})) + )); + +#ifndef MAKE_TUPLE_NO_CONSTEXPR + struct incr { + constexpr int operator()(int i) const { return i + 1; } + }; + + static_assert(hana::equal( + hana::transform(MAKE_TUPLE(1), incr{}), + MAKE_TUPLE(2) + ), ""); + + static_assert(hana::equal( + hana::transform(MAKE_TUPLE(1, 2), incr{}), + MAKE_TUPLE(2, 3) + ), ""); + + static_assert(hana::equal( + hana::transform(MAKE_TUPLE(1, 2, 3), incr{}), + MAKE_TUPLE(2, 3, 4) + ), ""); + + static_assert(hana::equal( + hana::transform(MAKE_TUPLE(1, 2, 3, 4), incr{}), + MAKE_TUPLE(2, 3, 4, 5) + ), ""); +#endif +}}; + +#endif // !BOOST_HANA_TEST_AUTO_TRANSFORM_HPP diff --git a/src/boost/libs/hana/test/_include/auto/unfolds.hpp b/src/boost/libs/hana/test/_include/auto/unfolds.hpp new file mode 100644 index 000000000..afa01d3fc --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/unfolds.hpp @@ -0,0 +1,170 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_UNFOLDS_HPP +#define BOOST_HANA_TEST_AUTO_UNFOLDS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "test_case.hpp" + + +TestCase test_unfold_left{[]{ + namespace hana = boost::hana; + + hana::test::_injection<0> f{}; + auto stop_at = [=](auto stop) { + return [=](auto x) { + return hana::if_(hana::equal(stop, x), + hana::nothing, + hana::just(::minimal_product(x + hana::int_c<1>, f(x))) + ); + }; + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::int_c<0>, stop_at(hana::int_c<0>)), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::int_c<0>, stop_at(hana::int_c<1>)), + MAKE_TUPLE(f(hana::int_c<0>)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::int_c<0>, stop_at(hana::int_c<2>)), + MAKE_TUPLE(f(hana::int_c<1>), f(hana::int_c<0>)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::int_c<0>, stop_at(hana::int_c<3>)), + MAKE_TUPLE(f(hana::int_c<2>), f(hana::int_c<1>), f(hana::int_c<0>)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::int_c<0>, stop_at(hana::int_c<4>)), + MAKE_TUPLE(f(hana::int_c<3>), f(hana::int_c<2>), f(hana::int_c<1>), f(hana::int_c<0>)) + )); +}}; + + +TestCase test_unfold_right{[]{ + namespace hana = boost::hana; + + hana::test::_injection<0> f{}; + auto stop_at = [=](auto stop) { + return [=](auto x) { + return hana::if_(hana::equal(stop, x), + hana::nothing, + hana::just(::minimal_product(f(x), x + hana::int_c<1>)) + ); + }; + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::int_c<0>, stop_at(hana::int_c<0>)), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::int_c<0>, stop_at(hana::int_c<1>)), + MAKE_TUPLE(f(hana::int_c<0>)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::int_c<0>, stop_at(hana::int_c<2>)), + MAKE_TUPLE(f(hana::int_c<0>), f(hana::int_c<1>)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::int_c<0>, stop_at(hana::int_c<3>)), + MAKE_TUPLE(f(hana::int_c<0>), f(hana::int_c<1>), f(hana::int_c<2>)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::int_c<0>, stop_at(hana::int_c<4>)), + MAKE_TUPLE(f(hana::int_c<0>), f(hana::int_c<1>), f(hana::int_c<2>), f(hana::int_c<3>)) + )); +}}; + +// Make sure unfolds can be reversed under certain conditions. +TestCase test_unfold_undo{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + auto z = ct_eq<999>{}; + auto f = ::minimal_product; + auto g = [=](auto k) { + return hana::if_(hana::equal(k, z), + hana::nothing, + hana::just(k) + ); + }; + + // Make sure the special conditions are met + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(z), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(f(ct_eq<0>{}, z)), + hana::just(::minimal_product(ct_eq<0>{}, z)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(f(z, ct_eq<0>{})), + hana::just(::minimal_product(z, ct_eq<0>{})) + )); + + // Make sure the reversing works + { + auto xs = MAKE_TUPLE(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::fold_left(xs, z, f), g), + xs + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::fold_right(xs, z, f), g), + xs + )); + } + { + auto xs = MAKE_TUPLE(ct_eq<0>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::fold_left(xs, z, f), g), + xs + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::fold_right(xs, z, f), g), + xs + )); + } + { + auto xs = MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::fold_left(xs, z, f), g), + xs + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::fold_right(xs, z, f), g), + xs + )); + } + { + auto xs = MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_left(hana::fold_left(xs, z, f), g), + xs + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unfold_right(hana::fold_right(xs, z, f), g), + xs + )); + } +}}; + +#endif // !BOOST_HANA_TEST_AUTO_UNFOLDS_HPP diff --git a/src/boost/libs/hana/test/_include/auto/unique.hpp b/src/boost/libs/hana/test/_include/auto/unique.hpp new file mode 100644 index 000000000..8ef7076fb --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/unique.hpp @@ -0,0 +1,158 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_UNIQUE_HPP +#define BOOST_HANA_TEST_AUTO_UNIQUE_HPP + +#include +#include +#include + +#include "test_case.hpp" +#include +#include + + +TestCase test_unique{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE()), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{})), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<0>{})), + MAKE_TUPLE(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{}, ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<0>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<1>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE( + ct_eq<0>{}, ct_eq<0>{}, + ct_eq<1>{}, + ct_eq<2>{}, ct_eq<2>{}, ct_eq<2>{}, + ct_eq<3>{}, ct_eq<3>{}, ct_eq<3>{}, + ct_eq<0>{})), + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<0>{}) + )); +}}; + +TestCase test_unique_by{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + struct undefined { }; + + auto a = [](auto z) { return ::equivalence_class(ct_eq<999>{}, z); }; + auto b = [](auto z) { return ::equivalence_class(ct_eq<888>{}, z); }; + auto c = [](auto z) { return ::equivalence_class(ct_eq<777>{}, z); }; + + auto pred = [](auto x, auto y) { + return hana::equal(x.unwrap, y.unwrap); + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(), undefined{}), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}), c(ct_eq<0>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<0>{}), c(ct_eq<1>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{}), c(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<0>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<1>{}), b(ct_eq<1>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{}), b(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<2>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique(MAKE_TUPLE( + a(ct_eq<0>{}), b(ct_eq<0>{}), + a(ct_eq<1>{}), + a(ct_eq<2>{}), b(ct_eq<2>{}), c(ct_eq<2>{}), + a(ct_eq<3>{}), b(ct_eq<3>{}), c(ct_eq<3>{}), + a(ct_eq<0>{})), pred), + MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<2>{}), a(ct_eq<3>{}), a(ct_eq<0>{})) + )); + + // unique.by + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique.by(pred, MAKE_TUPLE( + a(ct_eq<0>{}), b(ct_eq<0>{}), + a(ct_eq<1>{}), + a(ct_eq<2>{}), b(ct_eq<2>{}), c(ct_eq<2>{}), + a(ct_eq<3>{}), b(ct_eq<3>{}), c(ct_eq<3>{}), + a(ct_eq<0>{}))), + MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<2>{}), a(ct_eq<3>{}), a(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unique.by(pred)(MAKE_TUPLE( + a(ct_eq<0>{}), b(ct_eq<0>{}), + a(ct_eq<1>{}), + a(ct_eq<2>{}), b(ct_eq<2>{}), c(ct_eq<2>{}), + a(ct_eq<3>{}), b(ct_eq<3>{}), c(ct_eq<3>{}), + a(ct_eq<0>{}))), + MAKE_TUPLE(a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<2>{}), a(ct_eq<3>{}), a(ct_eq<0>{})) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_UNIQUE_HPP diff --git a/src/boost/libs/hana/test/_include/auto/zips.hpp b/src/boost/libs/hana/test/_include/auto/zips.hpp new file mode 100644 index 000000000..3d129c90d --- /dev/null +++ b/src/boost/libs/hana/test/_include/auto/zips.hpp @@ -0,0 +1,342 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_AUTO_ZIPS_HPP +#define BOOST_HANA_TEST_AUTO_ZIPS_HPP + +#include +#include +#include +#include +#include +#include + +#include +#include "test_case.hpp" + + +TestCase test_zip_shortest_with{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + hana::test::_injection<0> f{}; + auto zip = hana::zip_shortest_with; + struct undefined { }; + + // zip 1 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(f(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + + // zip 2 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(undefined{}), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(), MAKE_TUPLE(undefined{})), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<-1>{})), + MAKE_TUPLE(f(ct_eq<1>{}, ct_eq<-1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), MAKE_TUPLE(ct_eq<-1>{})), + MAKE_TUPLE(f(ct_eq<1>{}, ct_eq<-1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{})), + MAKE_TUPLE(f(ct_eq<1>{}, ct_eq<-1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{})), + MAKE_TUPLE(f(ct_eq<1>{}, ct_eq<-1>{}), f(ct_eq<2>{}, ct_eq<-2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<-3>{})), + MAKE_TUPLE(f(ct_eq<1>{}, ct_eq<-1>{}), + f(ct_eq<2>{}, ct_eq<-2>{}), + f(ct_eq<3>{}, ct_eq<-3>{})) + )); + + // zip 3 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(), MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(undefined{}), MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(), MAKE_TUPLE(undefined{}), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(), MAKE_TUPLE(), MAKE_TUPLE(undefined{})), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(), MAKE_TUPLE(undefined{}), MAKE_TUPLE(undefined{})), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(undefined{}), MAKE_TUPLE(), MAKE_TUPLE(undefined{})), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(undefined{}, MAKE_TUPLE(undefined{}), MAKE_TUPLE(undefined{}), MAKE_TUPLE()), + MAKE_TUPLE() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<2>{})), + MAKE_TUPLE(f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + + // zip 4 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, + MAKE_TUPLE(ct_eq<11>{}, ct_eq<12>{}, ct_eq<13>{}, ct_eq<14>{}), + MAKE_TUPLE(ct_eq<21>{}, ct_eq<22>{}, ct_eq<23>{}), + MAKE_TUPLE(ct_eq<31>{}, ct_eq<32>{}, ct_eq<33>{}, ct_eq<34>{}), + MAKE_TUPLE(ct_eq<41>{}, ct_eq<42>{}, ct_eq<43>{}, ct_eq<44>{}, ct_eq<45>{}) + ), + MAKE_TUPLE( + f(ct_eq<11>{}, ct_eq<21>{}, ct_eq<31>{}, ct_eq<41>{}), + f(ct_eq<12>{}, ct_eq<22>{}, ct_eq<32>{}, ct_eq<42>{}), + f(ct_eq<13>{}, ct_eq<23>{}, ct_eq<33>{}, ct_eq<43>{}) + ) + )); + + // zip 5 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + zip(f, + MAKE_TUPLE(ct_eq<11>{}, ct_eq<12>{}, ct_eq<13>{}, ct_eq<14>{}), + MAKE_TUPLE(ct_eq<21>{}, ct_eq<22>{}, ct_eq<23>{}, ct_eq<24>{}, ct_eq<25>{}), + MAKE_TUPLE(ct_eq<31>{}, ct_eq<32>{}, ct_eq<33>{}, ct_eq<34>{}), + MAKE_TUPLE(ct_eq<41>{}, ct_eq<42>{}, ct_eq<43>{}, ct_eq<44>{}, ct_eq<45>{}, ct_eq<46>{}), + MAKE_TUPLE(ct_eq<51>{}, ct_eq<52>{}, ct_eq<53>{}, ct_eq<54>{}, ct_eq<55>{}) + ), + MAKE_TUPLE( + f(ct_eq<11>{}, ct_eq<21>{}, ct_eq<31>{}, ct_eq<41>{}, ct_eq<51>{}), + f(ct_eq<12>{}, ct_eq<22>{}, ct_eq<32>{}, ct_eq<42>{}, ct_eq<52>{}), + f(ct_eq<13>{}, ct_eq<23>{}, ct_eq<33>{}, ct_eq<43>{}, ct_eq<53>{}), + f(ct_eq<14>{}, ct_eq<24>{}, ct_eq<34>{}, ct_eq<44>{}, ct_eq<54>{}) + ) + )); +}}; + +TestCase test_zip_with{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + hana::test::_injection<0> f{}; + struct undefined { }; + + // zip 1 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(undefined{}, MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(f(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + + // zip 2 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(undefined{}, MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<-1>{})), + MAKE_TUPLE(f(ct_eq<1>{}, ct_eq<-1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}), MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{})), + MAKE_TUPLE(f(ct_eq<1>{}, ct_eq<-1>{}), f(ct_eq<2>{}, ct_eq<-2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, + MAKE_TUPLE(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<-1>{}, ct_eq<-2>{}, ct_eq<-3>{})), + MAKE_TUPLE( + f(ct_eq<1>{}, ct_eq<-1>{}), + f(ct_eq<2>{}, ct_eq<-2>{}), + f(ct_eq<3>{}, ct_eq<-3>{})) + )); + + // zip 3 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(undefined{}, MAKE_TUPLE(), MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<2>{})), + MAKE_TUPLE(f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, + MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<4>{}, ct_eq<5>{}) + ), + MAKE_TUPLE( + f(ct_eq<0>{}, ct_eq<2>{}, ct_eq<4>{}), + f(ct_eq<1>{}, ct_eq<3>{}, ct_eq<5>{}) + ) + )); + + // zip 4 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, + MAKE_TUPLE(ct_eq<11>{}, ct_eq<12>{}, ct_eq<13>{}), + MAKE_TUPLE(ct_eq<21>{}, ct_eq<22>{}, ct_eq<23>{}), + MAKE_TUPLE(ct_eq<31>{}, ct_eq<32>{}, ct_eq<33>{}), + MAKE_TUPLE(ct_eq<41>{}, ct_eq<42>{}, ct_eq<43>{}) + ), + MAKE_TUPLE( + f(ct_eq<11>{}, ct_eq<21>{}, ct_eq<31>{}, ct_eq<41>{}), + f(ct_eq<12>{}, ct_eq<22>{}, ct_eq<32>{}, ct_eq<42>{}), + f(ct_eq<13>{}, ct_eq<23>{}, ct_eq<33>{}, ct_eq<43>{}) + ) + )); + + // zip 5 + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_with(f, + MAKE_TUPLE(ct_eq<11>{}, ct_eq<12>{}, ct_eq<13>{}, ct_eq<14>{}), + MAKE_TUPLE(ct_eq<21>{}, ct_eq<22>{}, ct_eq<23>{}, ct_eq<24>{}), + MAKE_TUPLE(ct_eq<31>{}, ct_eq<32>{}, ct_eq<33>{}, ct_eq<34>{}), + MAKE_TUPLE(ct_eq<41>{}, ct_eq<42>{}, ct_eq<43>{}, ct_eq<44>{}), + MAKE_TUPLE(ct_eq<51>{}, ct_eq<52>{}, ct_eq<53>{}, ct_eq<54>{}) + ), + MAKE_TUPLE( + f(ct_eq<11>{}, ct_eq<21>{}, ct_eq<31>{}, ct_eq<41>{}, ct_eq<51>{}), + f(ct_eq<12>{}, ct_eq<22>{}, ct_eq<32>{}, ct_eq<42>{}, ct_eq<52>{}), + f(ct_eq<13>{}, ct_eq<23>{}, ct_eq<33>{}, ct_eq<43>{}, ct_eq<53>{}), + f(ct_eq<14>{}, ct_eq<24>{}, ct_eq<34>{}, ct_eq<44>{}, ct_eq<54>{}) + ) + )); +}}; + +TestCase test_zip{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<2>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip(MAKE_TUPLE(ct_eq<0>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<4>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<5>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{})) + )); +}}; + +TestCase test_zip_shortest{[]{ + namespace hana = boost::hana; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE(ct_eq<0>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{}), MAKE_TUPLE(ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE(), MAKE_TUPLE()), + MAKE_TUPLE() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE(ct_eq<0>{}), MAKE_TUPLE(ct_eq<1>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE(ct_eq<0>{}), + MAKE_TUPLE(ct_eq<1>{}), + MAKE_TUPLE(ct_eq<2>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zip_shortest(MAKE_TUPLE(ct_eq<0>{}, ct_eq<3>{}), + MAKE_TUPLE(ct_eq<1>{}, ct_eq<4>{}), + MAKE_TUPLE(ct_eq<2>{}, ct_eq<5>{}, ct_eq<8>{})), + MAKE_TUPLE(MAKE_TUPLE(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + MAKE_TUPLE(ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{})) + )); +}}; + +#endif // !BOOST_HANA_TEST_AUTO_ZIPS_HPP diff --git a/src/boost/libs/hana/test/_include/laws/applicative.hpp b/src/boost/libs/hana/test/_include/laws/applicative.hpp new file mode 100644 index 000000000..a7de47b9d --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/applicative.hpp @@ -0,0 +1,196 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_APPLICATIVE_HPP +#define BOOST_HANA_TEST_LAWS_APPLICATIVE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestApplicative : TestApplicative { + using TestApplicative::TestApplicative; + }; + + template + struct TestApplicative { + template + TestApplicative(Applicatives applicatives) { + hana::for_each(applicatives, [](auto a) { + static_assert(Applicative{}, ""); + }); + + auto functions1 = hana::take_front( + hana::transform(applicatives, [](auto xs) { + return hana::transform(xs, hana::curry<2>(test::_injection<0>{})); + }), hana::int_c<3>); + + auto functions2 = hana::take_front( + hana::transform(applicatives, [](auto xs) { + return hana::transform(xs, hana::curry<2>(test::_injection<1>{})); + }), hana::int_c<3>); + + // identity + { + hana::for_each(applicatives, [](auto xs) { + BOOST_HANA_CHECK(hana::equal( + hana::ap(hana::lift(hana::id), xs), + xs + )); + }); + } + + // composition + { + hana::for_each(applicatives, hana::capture(functions1, functions2)( + [](auto functions1, auto functions2, auto xs) { + hana::for_each(functions1, hana::capture(functions2, xs)( + [](auto functions2, auto xs, auto fs) { + hana::for_each(functions2, hana::capture(xs, fs)( + [](auto xs, auto fs, auto gs) { + BOOST_HANA_CHECK(hana::equal( + hana::ap(hana::ap(hana::lift(compose), fs, gs), xs), + hana::ap(fs, hana::ap(gs, xs)) + )); + }));}));})); + } + + // homomorphism + { + test::_injection<0> f{}; + test::ct_eq<3> x{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::lift(f), hana::lift(x)), + hana::lift(f(x)) + )); + } + + // interchange + { + hana::for_each(functions1, [](auto fs) { + test::ct_eq<4> x{}; + BOOST_HANA_CHECK(hana::equal( + hana::ap(fs, hana::lift(x)), + hana::ap(hana::lift(hana::_(x)), fs) + )); + }); + } + + // definition of transform + { + hana::for_each(applicatives, [](auto xs) { + test::_injection<0> f{}; + BOOST_HANA_CHECK(hana::equal( + hana::transform(xs, f), + hana::ap(hana::lift(f), xs) + )); + }); + } + } + }; + + template + struct TestApplicative::value>> + : TestApplicative + { + template + TestApplicative(Applicatives applicatives) + : TestApplicative{applicatives} + { + _injection<0> f{}; + _injection<1> g{}; + using test::ct_eq; + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // ap + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(), list()), + list() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(), list(ct_eq<0>{})), + list() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(), list(ct_eq<0>{}, ct_eq<1>{})), + list() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(), list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f), list()), + list() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f), list(ct_eq<0>{})), + list(f(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f), list(ct_eq<0>{}, ct_eq<1>{})), + list(f(ct_eq<0>{}), f(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f), list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + list(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f, g), list()), + list() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f, g), list(ct_eq<0>{})), + list(f(ct_eq<0>{}), g(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f, g), list(ct_eq<0>{}, ct_eq<1>{})), + list(f(ct_eq<0>{}), f(ct_eq<1>{}), g(ct_eq<0>{}), g(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(list(f, g), list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + list(f(ct_eq<0>{}), f(ct_eq<1>{}), f(ct_eq<2>{}), + g(ct_eq<0>{}), g(ct_eq<1>{}), g(ct_eq<2>{})) + )); + + ////////////////////////////////////////////////////////////////// + // lift + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::equal( + lift(ct_eq<0>{}), + list(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + lift(ct_eq<1>{}), + list(ct_eq<1>{}) + )); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_APPLICATIVE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/base.hpp b/src/boost/libs/hana/test/_include/laws/base.hpp new file mode 100644 index 000000000..0f421b8ae --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/base.hpp @@ -0,0 +1,369 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_BASE_HPP +#define BOOST_HANA_TEST_LAWS_BASE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + + +namespace boost { namespace hana { + ////////////////////////////////////////////////////////////////////////// + // Misc + ////////////////////////////////////////////////////////////////////////// + namespace test { + struct laws; + + template + struct for_each_n_t { + static_assert(i > 0, "can't use for_each_n with i < 0"); + + template + constexpr auto operator()(Xs const& xs, F const& f) const { + hana::for_each(xs, + hana::compose( + hana::partial(for_each_n_t{}, xs), + hana::partial(hana::partial, f) + ) + ); + } + }; + + template <> + struct for_each_n_t<1> { + template + constexpr auto operator()(Xs const& xs, F const& f) const { + hana::for_each(xs, f); + } + }; + + template + constexpr for_each_n_t for_each_n{}; + + auto foreach = hana::for_each; + constexpr auto foreach3 = for_each_n<3>; + constexpr auto foreach2 = for_each_n<2>; + + struct implies_t { + template + constexpr decltype(auto) operator()(P&& p, Q&& q) const { + return hana::or_(hana::not_(static_cast(p)), + static_cast(q)); + } + }; + constexpr auto implies = hana::infix(implies_t{}); + + struct iff_t { + template + constexpr decltype(auto) operator()(P&& p, Q&& q) const { + return hana::and_(implies(p, q), implies(q, p)); + } + }; + constexpr auto iff = hana::infix(iff_t{}); + + template + constexpr decltype(auto) only_when_(Cond cond, F f) { + return hana::eval_if(cond, f, [](auto){ }); + } + + // A type with a constructor that must not be instantiated. + // This is to make sure we don't instantiate something else than + // the copy-constructor of the elements inside a container when we + // copy the container. + struct trap_construct { + trap_construct() = default; + trap_construct(trap_construct const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + trap_construct(trap_construct&) = default; +#endif + trap_construct(trap_construct&&) = default; + + template + trap_construct(X&&) { + static_assert(detail::wrong{}, + "this constructor must not be instantiated"); + } + }; + + // A move-only type. Useful for testing containers. + struct move_only { + move_only() = default; + move_only(move_only const&) = delete; + move_only(move_only&&) = default; + }; + + ////////////////////////////////////////////////////////////////////// + // InjectionResult + ////////////////////////////////////////////////////////////////////// + struct InjectionResult { }; + + template + struct injection_result { + using hana_tag = InjectionResult; + static constexpr int injection_id = i; + hana::tuple args; + Tracked tracker; + + template {std::declval()...})> + constexpr explicit injection_result(Y&& ...y) + : args{static_cast(y)...}, tracker{i} + { } + }; + + //! A monotonic injective function. + //! + //! This is used in the unit tests, where we often just need a function + //! which preserves equality and order, but which also satisfies the + //! following law for all `Injection`s `f` and `g`: + //! @code + //! f(x) == g(x) if and only if f === g + //! @endcode + //! where `===` means _was created by the same call to `injection`_. + //! This allows creating several such functions in the unit tests while + //! conserving precious information such as the fact that + //! `f(g(x)) != g(f(x))`. + template + struct _injection { + template + constexpr auto operator()(X&& ...x) const { + return injection_result::type... + >{static_cast(x)...}; + } + }; + } // end namespace test + + template <> + struct equal_impl { + template + static constexpr auto apply(X x, Y y) { + return hana::and_( + hana::bool_c, + hana::equal(x.args, y.args) + ); + } + }; + + template <> + struct less_impl { + template + static constexpr auto apply(X x, Y y) { + static_assert(X::injection_id == Y::injection_id, + "can't order the result of two different injections"); + return hana::less(x.args, y.args); + } + }; + + + ////////////////////////////////////////////////////////////////////////// + // Integer + ////////////////////////////////////////////////////////////////////////// + namespace test { + enum class Policy : int { + // One of those is mandatory + Constant = 1 << 0 + , Constexpr = 1 << 1 + , Runtime = 1 << 2 + + // Those are optional + , Tracked = 1 << 3 + , Comparable = 1 << 4 + , Orderable = 1 << 5 + }; + + constexpr bool operator&&(Policy a, Policy b) { + return static_cast(a) && static_cast(b); + } + + constexpr bool operator&&(Policy a, bool b) { + return static_cast(a) && b; + } + + constexpr bool operator&&(bool a, Policy b) { + return a && static_cast(b); + } + + constexpr bool operator||(Policy a, Policy b) { + return static_cast(a) || static_cast(b); + } + + constexpr bool operator||(Policy a, bool b) { + return static_cast(a) || b; + } + + constexpr bool operator||(bool a, Policy b) { + return a || static_cast(b); + } + + constexpr bool operator!(Policy a) { + return !static_cast(a); + } + + constexpr Policy operator|(Policy a, Policy b) { + return static_cast(static_cast(a) | static_cast(b)); + } + + constexpr Policy operator&(Policy a, Policy b) { + return static_cast(static_cast(a) & static_cast(b)); + } + + template + struct Integer { }; + + template + struct Integer> { + using value_type = int; + }; + + template + struct integer { + static_assert( + !!(policy & (Policy::Constant | Policy::Constexpr | Policy::Runtime)) + , "You must choose at least one of Constant, Constexpr and Runtime."); + + static constexpr int value = i; + constexpr operator int() const { return value; } + using hana_tag = Integer; + Tracked tracker{i}; + }; + + template + struct integer > { + static constexpr int value = i; + constexpr operator int() const { return value; } + using hana_tag = Integer; + }; + + template + struct eq : integer { }; + + template + struct ct_eq : integer { }; + + template + struct cx_eq : integer { }; + + template + struct ord : integer { }; + + template + struct ct_ord : integer { }; + + template + struct cx_ord : integer { }; + + template + struct _constant + : integer + { }; + } + + ////////////////////////////////////////////////////////////////////////// + // Model of Constant/IntegralConstant + ////////////////////////////////////////////////////////////////////////// + template + struct IntegralConstant> { + static constexpr bool value = static_cast(policy & test::Policy::Constant); + }; + + template + struct to_impl, C, when< + (policy & test::Policy::Constant) && + hana::IntegralConstant::value + >> + : embedding::value> + { + template + static constexpr auto apply(N const&) { + return test::integer{}; + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Model of Comparable + ////////////////////////////////////////////////////////////////////////// + template + struct equal_impl, test::Integer, when< + // both Comparable or Orderable + (p1 & (test::Policy::Comparable | test::Policy::Orderable)) && + (p2 & (test::Policy::Comparable | test::Policy::Orderable)) && + + // one Constexpr and the other Constant, or both Constexpr + (((p1 & test::Policy::Constant) && (p2 & test::Policy::Constexpr)) || + ((p1 & test::Policy::Constexpr) && (p2 & test::Policy::Constant)) || + ((p1 & test::Policy::Constexpr) && (p2 & test::Policy::Constexpr))) + >> { + template + static constexpr bool apply(X const&, Y const&) + { return X::value == Y::value; } + }; + + template + struct equal_impl, test::Integer, when< + // both Comparable or Orderable + (p1 & (test::Policy::Comparable | test::Policy::Orderable)) && + (p2 & (test::Policy::Comparable | test::Policy::Orderable)) && + + // either one is Runtime + ((p1 & test::Policy::Runtime) || (p2 & test::Policy::Runtime)) + >> { + template + static bool apply(X const&, Y const&) + { return X::value == Y::value; } + }; + + + ////////////////////////////////////////////////////////////////////////// + // Model of Orderable + ////////////////////////////////////////////////////////////////////////// + template + struct less_impl, test::Integer, when< + // both Orderable + (p1 & test::Policy::Orderable) && (p2 & test::Policy::Orderable) && + + // one Constexpr and the other Constant, or both Constexpr + (((p1 & test::Policy::Constant) && (p2 & test::Policy::Constexpr)) || + ((p1 & test::Policy::Constexpr) && (p2 & test::Policy::Constant)) || + ((p1 & test::Policy::Constexpr) && (p2 & test::Policy::Constexpr))) + >> { + template + static constexpr bool apply(X const&, Y const&) + { return X::value < Y::value; } + }; + + template + struct less_impl, test::Integer, when< + // both Orderable + (p1 & test::Policy::Orderable) && (p2 & test::Policy::Orderable) && + + // either one is Runtime + ((p1 & test::Policy::Runtime) || (p2 & test::Policy::Runtime)) + >> { + template + static bool apply(X const&, Y const&) + { return X::value < Y::value; } + }; +}} // end namespace boost::hana + +#endif // !BOOST_HANA_TEST_LAWS_BASE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/comonad.hpp b/src/boost/libs/hana/test/_include/laws/comonad.hpp new file mode 100644 index 000000000..82ef7b32d --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/comonad.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_LAWS_COMONAD_HPP +#define BOOST_HANA_TEST_LAWS_COMONAD_HPP + +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestComonad : TestComonad { + using TestComonad::TestComonad; + }; + + template + struct TestComonad { + template + TestComonad(Ws ws) { + hana::for_each(ws, [](auto w) { + static_assert(Comonad{}, ""); + + // extract(duplicate(w)) == w + BOOST_HANA_CHECK(hana::equal( + hana::extract(hana::duplicate(w)), + w + )); + + // transform(duplicate(w), extract) == w + BOOST_HANA_CHECK(hana::equal( + hana::transform(hana::duplicate(w), extract), + w + )); + + // duplicate(duplicate(w)) == transform(duplicate(w), duplicate) + BOOST_HANA_CHECK(hana::equal( + hana::duplicate(hana::duplicate(w)), + hana::transform(hana::duplicate(w), duplicate) + )); + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_COMONAD_HPP diff --git a/src/boost/libs/hana/test/_include/laws/comparable.hpp b/src/boost/libs/hana/test/_include/laws/comparable.hpp new file mode 100644 index 000000000..24ce317b8 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/comparable.hpp @@ -0,0 +1,167 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_COMPARABLE_HPP +#define BOOST_HANA_TEST_LAWS_COMPARABLE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestComparable : TestComparable { + using TestComparable::TestComparable; + }; + + template + struct TestComparable { + template + TestComparable(Xs xs) { + hana::for_each(xs, [](auto x) { + static_assert(hana::Comparable{}, ""); + }); + + foreach2(xs, [](auto a, auto b) { + + // reflexivity + BOOST_HANA_CHECK( + hana::equal(a, a) + ); + + // symmetry + BOOST_HANA_CHECK( + hana::equal(a, b) ^implies^ hana::equal(b, a) + ); + + // `not_equal` is the negation of `equal` + BOOST_HANA_CHECK( + hana::not_equal(a, b) ^iff^ hana::not_(hana::equal(a, b)) + ); + + // equal.to and not_equal.to + BOOST_HANA_CHECK( + hana::equal.to(a)(b) ^iff^ hana::equal(a, b) + ); + + BOOST_HANA_CHECK( + hana::not_equal.to(a)(b) ^iff^ hana::not_equal(a, b) + ); + + // comparing + _injection<0> f{}; + BOOST_HANA_CHECK( + hana::comparing(f)(a, b) ^iff^ hana::equal(f(a), f(b)) + ); + }); + + // transitivity + foreach3(xs, [](auto a, auto b, auto c) { + BOOST_HANA_CHECK( + hana::and_(hana::equal(a, b), hana::equal(b, c)) + ^implies^ hana::equal(a, c) + ); + }); + } + }; + + template + struct TestComparable::value>> + : TestComparable + { + template + TestComparable(Xs xs) : TestComparable{xs} { + foreach2(xs, [](auto a, auto b) { + BOOST_HANA_CHECK( + hana::value(hana::equal(a, b)) ^iff^ + hana::equal(hana::value(a), hana::value(b)) + ); + }); + } + }; + + template + struct TestComparable::value>> + : TestComparable + { + template + TestComparable(Products products) : TestComparable{products} { + foreach2(products, [](auto x, auto y) { + BOOST_HANA_CHECK( + hana::equal(x, y) ^iff^ + hana::and_( + hana::equal(hana::first(x), hana::first(y)), + hana::equal(hana::second(x), hana::second(y)) + ) + ); + }); + } + }; + + template + struct TestComparable::value>> + : TestComparable + { + template + using x = _constant; + + template + TestComparable(Xs xs) : TestComparable{xs} { + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // equal + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::equal( + list(), + list() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + list(x<0>{}), + list() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + list(), + list(x<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + list(x<0>{}), + list(x<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + list(x<0>{}, x<1>{}), + list(x<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + list(x<0>{}, x<1>{}), + list(x<0>{}, x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + list(x<0>{}, x<1>{}, x<2>{}, x<3>{}), + list(x<0>{}, x<1>{}, x<2>{}, x<4>{}) + ))); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_COMPARABLE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/constant.hpp b/src/boost/libs/hana/test/_include/laws/constant.hpp new file mode 100644 index 000000000..1acd335e4 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/constant.hpp @@ -0,0 +1,106 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_CONSTANT_HPP +#define BOOST_HANA_TEST_LAWS_CONSTANT_HPP + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestConstant { + using T = typename C::value_type; + + template + struct wrap_arbitrary_constant { + static constexpr bool value = boost::hana::value(); + using hana_tag = detail::CanonicalConstant; + }; + + template + TestConstant(Xs xs, Convertibles types) { + hana::for_each(xs, [](auto x) { + static_assert(Constant{}, ""); + }); + + hana::for_each(xs, hana::capture(types)([](auto types, auto c) { + + // constexpr-ness of hana::value(c) + constexpr auto must_be_constexpr1 = hana::value(c); + constexpr auto must_be_constexpr2 = hana::value(); + (void)must_be_constexpr1; + (void)must_be_constexpr2; + + // consistency of C::value_type + static_assert(std::is_same< + T, + tag_of_t + >{}, ""); + + // equivalence of value_of(c) and value + BOOST_HANA_CHECK(hana::equal( + hana::value_of(c), + hana::value() + )); + + // equivalence of value() and value(c) + BOOST_HANA_CHECK(hana::equal( + hana::value(), + hana::value(c) + )); + + // conversion from an arbitrary Constant + (void)to(wrap_arbitrary_constant{}); + static_assert(is_embedded, C>{}, ""); + + hana::for_each(types, hana::capture(c)([](auto c, auto u) { + using U = typename decltype(u)::type; + + // conversion to something to which the underlying data + // type can be converted. + BOOST_HANA_CHECK(equal( + to(c), + make(hana::value(c)) + )); + static_assert(is_embedded::value ^iff^ is_embedded::value, ""); + + // common data type + static_assert(std::is_same< + common_t>, + detail::CanonicalConstant> + >{}, ""); + + static_assert(std::is_same< + common_t, C>, + detail::CanonicalConstant> + >{}, ""); + + static_assert(std::is_same< + common_t, + common_t + >{}, ""); + })); + })); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_CONSTANT_HPP diff --git a/src/boost/libs/hana/test/_include/laws/euclidean_ring.hpp b/src/boost/libs/hana/test/_include/laws/euclidean_ring.hpp new file mode 100644 index 000000000..96d1fce58 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/euclidean_ring.hpp @@ -0,0 +1,99 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_EUCLIDEAN_RING_HPP +#define BOOST_HANA_TEST_LAWS_EUCLIDEAN_RING_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestEuclideanRing : TestEuclideanRing { + using TestEuclideanRing::TestEuclideanRing; + }; + + template + struct TestEuclideanRing { + template + TestEuclideanRing(Xs xs) { + hana::for_each(xs, [](auto x) { + static_assert(EuclideanRing{}, ""); + }); + +#ifdef BOOST_HANA_WORKAROUND_MSVC_DECLTYPEAUTO_RETURNTYPE_662735 + zero(); // force adding zero's member function to pending temploid list +#endif + + foreach2(xs, [](auto a, auto b) { + + // commutativity + BOOST_HANA_CHECK(hana::equal( + hana::mult(a, b), + hana::mult(b, a) + )); + + only_when_(hana::not_equal(b, zero()), + hana::make_lazy([](auto a, auto b) { + BOOST_HANA_CHECK(hana::equal( + hana::plus( + hana::mult(hana::div(a, b), b), + hana::mod(a, b) + ), + a + )); + + BOOST_HANA_CHECK(hana::equal( + hana::mod(zero(), b), + zero() + )); + })(a, b)); + + }); + } + }; + + template + struct TestEuclideanRing::value>> + : TestEuclideanRing + { + template + TestEuclideanRing(Xs xs) : TestEuclideanRing{xs} { + foreach2(xs, [](auto x, auto y) { + only_when_(hana::not_equal(zero(), y), + hana::make_lazy([](auto x, auto y) { + BOOST_HANA_CHECK(hana::equal( + hana::div(hana::value(x), hana::value(y)), + hana::value(hana::div(x, y)) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::mod(hana::value(x), hana::value(y)), + hana::value(hana::mod(x, y)) + )); + + })(x, y)); + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_EUCLIDEAN_RING_HPP diff --git a/src/boost/libs/hana/test/_include/laws/foldable.hpp b/src/boost/libs/hana/test/_include/laws/foldable.hpp new file mode 100644 index 000000000..57411f416 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/foldable.hpp @@ -0,0 +1,1104 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_FOLDABLE_HPP +#define BOOST_HANA_TEST_LAWS_FOLDABLE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestFoldable : TestFoldable { + using TestFoldable::TestFoldable; + }; + + template + struct TestFoldable { + template + TestFoldable(Foldables foldables) { + hana::for_each(foldables, [](auto xs) { + static_assert(Foldable{}, ""); + + _injection<0> f{}; + ct_eq<999> s{}; + + // equivalence of size(xs) and length(xs) + BOOST_HANA_CHECK(hana::equal( + hana::length(xs), + hana::size(xs) + )); + + // equivalence of fold with fold_left and + // of reverse_fold with fold_right + BOOST_HANA_CHECK(hana::equal( + hana::fold(xs, s, f), + hana::fold_left(xs, s, f) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::reverse_fold(xs, s, f), + hana::fold_right(xs, s, hana::flip(f)) + )); + + only_when_(hana::not_equal(hana::length(xs), hana::size_c<0>), + hana::make_lazy([](auto f, auto xs) { + BOOST_HANA_CHECK(hana::equal( + hana::fold(xs, f), + hana::fold_left(xs, f) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::reverse_fold(xs, f), + hana::fold_right(xs, hana::flip(f)) + )); + })(f, xs)); + + // equivalence of count(xs, val) and count_if(xs, equal.to(val)) + struct not_there { }; + BOOST_HANA_CHECK(hana::equal( + hana::count(xs, not_there{}), + hana::count_if(xs, equal.to(not_there{})) + )); + + hana::for_each(xs, hana::capture(xs)([](auto xs, auto value) { + BOOST_HANA_CHECK(hana::equal( + hana::count(xs, value), + hana::count_if(xs, equal.to(value)) + )); + })); + }); + } + }; + + template + struct TestFoldable::value>> + : TestFoldable + { + template + TestFoldable(Products products) : TestFoldable{products} { + hana::for_each(products, [](auto p) { + _injection<0> f{}; + + BOOST_HANA_CHECK(hana::equal( + hana::unpack(p, f), + f(hana::first(p), hana::second(p)) + )); + }); + } + }; + + template + struct TestFoldable::value>> + : TestFoldable + { + template + using x = _constant; + + template + using ord = _constant; + + struct undefined { }; + + template + TestFoldable(Xs xs) : TestFoldable{xs} { + _injection<0> f{}; + auto z = x<999>{}; + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // fold_left (with initial state) + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(), z, undefined{}), + z + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(x<1>{}), z, f), + f(z, x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(x<1>{}, x<2>{}), z, f), + f(f(z, x<1>{}), x<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(x<1>{}, x<2>{}, x<3>{}), z, f), + f(f(f(z, x<1>{}), x<2>{}), x<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}), z, f), + f(f(f(f(z, x<1>{}), x<2>{}), x<3>{}), x<4>{}) + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_left(list(1), z, f), + f(z, 1) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_left(list(1, '2'), z, f), + f(f(z, 1), '2') + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_left(list(1, '2', 3.3), z, f), + f(f(f(z, 1), '2'), 3.3) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_left(list(1, '2', 3.3, 4.4f), z, f), + f(f(f(f(z, 1), '2'), 3.3), 4.4f) + )); + + ////////////////////////////////////////////////////////////////// + // fold_left (without initial state) + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(z), undefined{}), + z + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(z, x<2>{}), f), + f(z, x<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(z, x<2>{}, x<3>{}), f), + f(f(z, x<2>{}), x<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_left(list(z, x<2>{}, x<3>{}, x<4>{}), f), + f(f(f(z, x<2>{}), x<3>{}), x<4>{}) + )); + + ////////////////////////////////////////////////////////////////// + // fold_right (with initial state) + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(), z, undefined{}), + z + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(x<0>{}), z, f), + f(x<0>{}, z) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(x<0>{}, x<1>{}), z, f), + f(x<0>{}, f(x<1>{}, z)) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(x<0>{}, x<1>{}, x<2>{}), z, f), + f(x<0>{}, f(x<1>{}, f(x<2>{}, z))) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(x<0>{}, x<1>{}, x<2>{}, x<3>{}), z, f), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, z)))) + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_right(list(1), z, f), + f(1, z) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_right(list(1, '2'), z, f), + f(1, f('2', z)) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_right(list(1, '2', 3.3), z, f), + f(1, f('2', f(3.3, z))) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + fold_right(list(1, '2', 3.3, 4.4f), z, f), + f(1, f('2', f(3.3, f(4.4f, z)))) + )); + + ////////////////////////////////////////////////////////////////// + // fold_right (without initial state) + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(z), undefined{}), + z + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(x<1>{}, z), f), + f(x<1>{}, z) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(x<1>{}, x<2>{}, z), f), + f(x<1>{}, f(x<2>{}, z)) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + fold_right(list(x<1>{}, x<2>{}, x<3>{}, z), f), + f(x<1>{}, f(x<2>{}, f(x<3>{}, z))) + )); + + ////////////////////////////////////////////////////////////////// + // monadic_fold_left (with initial state) + ////////////////////////////////////////////////////////////////// + { + using M = ::Identity; + auto f = hana::demux(::identity)(test::_injection<0>{}); + auto s = x<999>{}; + auto fp = hana::curry<2>(hana::flip(f)); + constexpr auto mfold = monadic_fold_left; + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(), s, undefined{}), + lift(s) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}), s, f), + f(s, x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}), s, f), + chain(f(s, x<1>{}), fp(x<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}), s, f), + chain(chain(f(s, x<1>{}), fp(x<2>{})), fp(x<3>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}), s, f), + chain(chain(chain(f(s, x<1>{}), fp(x<2>{})), fp(x<3>{})), fp(x<4>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), s, f), + chain(chain(chain(chain(f(s, x<1>{}), fp(x<2>{})), fp(x<3>{})), fp(x<4>{})), fp(x<5>{})) + )); + } + + ////////////////////////////////////////////////////////////////// + // monadic_fold_left (without initial state) + ////////////////////////////////////////////////////////////////// + { + using M = ::Identity; + auto f = hana::demux(::identity)(test::_injection<0>{}); + auto fp = hana::curry<2>(hana::flip(f)); + constexpr auto mfold = monadic_fold_left; + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}), undefined{}), + lift(x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}), f), + f(x<1>{}, x<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}), f), + chain(f(x<1>{}, x<2>{}), fp(x<3>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}), f), + chain(chain(f(x<1>{}, x<2>{}), fp(x<3>{})), fp(x<4>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), f), + chain(chain(chain(f(x<1>{}, x<2>{}), fp(x<3>{})), fp(x<4>{})), fp(x<5>{})) + )); + } + + ////////////////////////////////////////////////////////////////// + // monadic_fold_right (with initial state) + ////////////////////////////////////////////////////////////////// + { + using M = ::Identity; + auto f = hana::demux(::identity)(test::_injection<0>{}); + auto s = x<999>{}; + auto fp = hana::curry<2>(f); + // flipping `chain` makes the right associativity easier to see + auto chain = hana::flip(hana::chain); + constexpr auto mfold = monadic_fold_right; + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(), s, undefined{}), + lift(s) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}), s, f), + f(x<1>{}, s) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}), s, f), + chain(fp(x<1>{}), f(x<2>{}, s)) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}), s, f), + chain(fp(x<1>{}), chain(fp(x<2>{}), f(x<3>{}, s))) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}), s, f), + chain(fp(x<1>{}), chain(fp(x<2>{}), chain(fp(x<3>{}), f(x<4>{}, s)))) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), s, f), + chain(fp(x<1>{}), chain(fp(x<2>{}), chain(fp(x<3>{}), chain(fp(x<4>{}), f(x<5>{}, s))))) + )); + } + + ////////////////////////////////////////////////////////////////// + // monadic_fold_right (without initial state) + ////////////////////////////////////////////////////////////////// + { + using M = ::Identity; + auto f = hana::demux(::identity)(test::_injection<0>{}); + auto fp = hana::curry<2>(f); + // flipping `chain` makes the right associativity easier to see + auto chain = hana::flip(hana::chain); + constexpr auto mfold = monadic_fold_right; + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}), undefined{}), + lift(x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}), f), + f(x<1>{}, x<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}), f), + chain(fp(x<1>{}), f(x<2>{}, x<3>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}), f), + chain(fp(x<1>{}), chain(fp(x<2>{}), f(x<3>{}, x<4>{}))) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + mfold(list(x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), f), + chain(fp(x<1>{}), chain(fp(x<2>{}), chain(fp(x<3>{}), f(x<4>{}, x<5>{})))) + )); + } + + ////////////////////////////////////////////////////////////////// + // length + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + length(list()), size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + length(list(undefined{})), size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + length(list(undefined{}, undefined{})), size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + length(list(undefined{}, undefined{}, undefined{})), size_c<3> + )); + + int i = 0; // non-constexpr + BOOST_HANA_CONSTANT_CHECK(equal( + length(list(i, i)), + size_c<2> + )); + + ////////////////////////////////////////////////////////////////// + // maximum (without a custom predicate) + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<0>{})), + ord<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<0>{}, ord<1>{})), + ord<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<1>{}, ord<0>{})), + ord<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<0>{}, ord<1>{}, ord<2>{})), + ord<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<1>{}, ord<0>{}, ord<2>{})), + ord<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<1>{}, ord<2>{}, ord<0>{})), + ord<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<2>{}, ord<1>{}, ord<0>{})), + ord<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<2>{}, ord<0>{}, ord<1>{})), + ord<2>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<0>{}, ord<1>{}, ord<2>{}, ord<3>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<1>{}, ord<0>{}, ord<2>{}, ord<3>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<1>{}, ord<2>{}, ord<0>{}, ord<3>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<1>{}, ord<2>{}, ord<3>{}, ord<0>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<2>{}, ord<1>{}, ord<3>{}, ord<0>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<2>{}, ord<3>{}, ord<1>{}, ord<0>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<2>{}, ord<3>{}, ord<0>{}, ord<1>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<3>{}, ord<2>{}, ord<0>{}, ord<1>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<3>{}, ord<0>{}, ord<2>{}, ord<1>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<3>{}, ord<0>{}, ord<1>{}, ord<2>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<0>{}, ord<2>{}, ord<3>{}, ord<1>{})), + ord<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + maximum(list(ord<0>{}, ord<3>{}, ord<1>{}, ord<2>{})), + ord<3>{} + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0})), + int{0} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0}, long{1})), + long{1} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{1}, long{0})), + int{1} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0}, 1ll, long{2})), + long{2} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{1}, 0ll, long{2})), + long{2} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{1}, 2ll, long{0})), + 2ll + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{2}, 1ll, long{0})), + int{2} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{2}, 0ll, long{1})), + int{2} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0}, 1ll, long{2}, short{3})), + short{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{1}, 0ll, long{2}, short{3})), + short{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{1}, 2ll, long{0}, short{3})), + short{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{1}, 2ll, long{3}, short{0})), + long{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{2}, 1ll, long{3}, short{0})), + long{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{2}, 3ll, long{1}, short{0})), + 3ll + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{2}, 3ll, long{0}, short{1})), + 3ll + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{3}, 2ll, long{0}, short{1})), + int{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{3}, 0ll, long{2}, short{1})), + int{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{3}, 0ll, long{1}, short{2})), + int{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0}, 2ll, long{3}, short{1})), + long{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0}, 3ll, long{1}, short{2})), + 3ll + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0}, 1ll, long_c<2>)), + long{2} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + maximum(list(int{0}, long_c<1>, 2ll)), + 2ll + )); + } + + ////////////////////////////////////////////////////////////////// + // minimum (without a custom predicate) + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<6>{})), + ord<6>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<6>{}, ord<7>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<7>{}, ord<6>{})), + ord<6>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<6>{}, ord<7>{}, ord<8>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<7>{}, ord<6>{}, ord<8>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<7>{}, ord<8>{}, ord<6>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<8>{}, ord<7>{}, ord<6>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<8>{}, ord<6>{}, ord<7>{})), + ord<6>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<6>{}, ord<7>{}, ord<8>{}, ord<9>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<7>{}, ord<6>{}, ord<8>{}, ord<9>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<7>{}, ord<8>{}, ord<6>{}, ord<9>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<7>{}, ord<8>{}, ord<9>{}, ord<6>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<8>{}, ord<7>{}, ord<9>{}, ord<6>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<8>{}, ord<9>{}, ord<7>{}, ord<6>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<8>{}, ord<9>{}, ord<6>{}, ord<7>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<9>{}, ord<8>{}, ord<6>{}, ord<7>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<9>{}, ord<6>{}, ord<8>{}, ord<7>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<9>{}, ord<6>{}, ord<7>{}, ord<8>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<6>{}, ord<8>{}, ord<9>{}, ord<7>{})), + ord<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + minimum(list(ord<6>{}, ord<9>{}, ord<7>{}, ord<8>{})), + ord<6>{} + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{4})), + int{4} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{4}, short{5})), + int{4} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{5}, short{4})), + short{4} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{4}, short{5}, long{6})), + int{4} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{7}, short{6}, long{8})), + short{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{7}, short{8}, long{6})), + long{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{8}, short{7}, long{6})), + long{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{8}, short{6}, long{7})), + short{6} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{6}, short{7}, long{8}, 9ll)), + int{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{7}, short{6}, long{8}, 9ll)), + short{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{7}, short{8}, long{6}, 9ll)), + long{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{7}, short{8}, long{9}, 6ll)), + 6ll + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{8}, short{7}, long{9}, 6ll)), + 6ll + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{8}, short{9}, long{7}, 6ll)), + 6ll + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{8}, short{9}, long{6}, 7ll)), + long{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{9}, short{8}, long{6}, 7ll)), + long{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{9}, short{6}, long{8}, 7ll)), + short{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{9}, short{6}, long{7}, 8ll)), + short{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{6}, short{8}, long{9}, 7ll)), + int{6} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{6}, short{9}, long{7}, 8ll)), + int{6} + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(int{3}, short{4}, long_c<5>)), + int{3} + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + minimum(list(ord<33>{}, short{45}, long{46})), + ord<33>{} + )); + } + + + ////////////////////////////////////////////////////////////////// + // count_if + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(), id), size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<1>), id), size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<0>), id), size_c<0> + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<1>, char_c<1>), id), size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<1>, char_c<0>), id), size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<0>, char_c<1>), id), size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<0>, char_c<0>), id), size_c<0> + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<1>, char_c<1>, long_c<1>), id), size_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<1>, char_c<1>, long_c<0>), id), size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<1>, char_c<0>, long_c<1>), id), size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<1>, char_c<0>, long_c<0>), id), size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<0>, char_c<1>, long_c<1>), id), size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<0>, char_c<1>, long_c<0>), id), size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<0>, char_c<0>, long_c<1>), id), size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + count_if(list(int_c<0>, char_c<0>, long_c<0>), id), size_c<0> + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{1}), id), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{0}), id), 0u + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{1}, char{1}), id), 2u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{1}, char{0}), id), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{0}, char{1}), id), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{0}, char{0}), id), 0u + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{1}, char{1}, double{1}), id), 3u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{1}, char{1}, double{0}), id), 2u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{1}, char{0}, double{1}), id), 2u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{1}, char{0}, double{0}), id), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{0}, char{1}, double{1}), id), 2u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{0}, char{1}, double{0}), id), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{0}, char{0}, double{1}), id), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(int{0}, char{0}, double{0}), id), 0u + )); + + + BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { + return x % 2 == 0; + }; + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(), is_even), 0u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(1), is_even), 0u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(2), is_even), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(1, 2), is_even), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(1, 2, 3), is_even), 1u + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + count_if(list(1, 2, 3, 4), is_even), 2u + )); + + ////////////////////////////////////////////////////////////////// + // count + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::count(list(), undefined{}), + size_c<0> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::count(list(ct_eq<0>{}), undefined{}), + size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::count(list(ct_eq<0>{}), ct_eq<0>{}), + size_c<1> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::count(list(ct_eq<0>{}, ct_eq<1>{}), undefined{}), + size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::count(list(ct_eq<0>{}, ct_eq<1>{}), ct_eq<0>{}), + size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::count(list(ct_eq<0>{}, ct_eq<1>{}), ct_eq<1>{}), + size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::count(list(ct_eq<0>{}, ct_eq<0>{}), ct_eq<0>{}), + size_c<2> + )); + + ////////////////////////////////////////////////////////////////// + // product + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + product>(list()), + int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + product>(list(int_c<2>)), + int_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + product>(list(int_c<2>, int_c<3>)), + int_c<2 * 3> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + product>(list(int_c<2>, int_c<3>, int_c<4>)), + int_c<2 * 3 * 4> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + product>(list(int_c<2>, int_c<3>, int_c<4>, int_c<5>)), + int_c<2 * 3 * 4 * 5> + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + product>(list()), + ulong_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + product>(list(ulong_c<2>, ulong_c<3>, ulong_c<4>)), + ulong_c<2 * 3 * 4> + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + product(list(2)), + 2 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + product(list(2, 3)), + 2 * 3 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + product(list(2, 3, 4)), + 2 * 3 * 4 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + product(list(2, 3, 4, 5)), + 2 * 3 * 4 * 5 + )); + + + ////////////////////////////////////////////////////////////////// + // sum + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + sum>(list()), + int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + sum>(list(int_c<1>)), + int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + sum>(list(int_c<1>, int_c<2>)), + int_c<1 + 2> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + sum>(list(int_c<1>, int_c<2>, int_c<3>)), + int_c<1 + 2 + 3> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + sum>(list(int_c<1>, int_c<2>, int_c<3>, int_c<4>)), + int_c<1 + 2 + 3 + 4> + )); + + + BOOST_HANA_CONSTANT_CHECK(equal( + sum>(list()), + ulong_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(equal( + sum>(list(ulong_c<1>, ulong_c<2>, ulong_c<3>)), + ulong_c<1 + 2 + 3> + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + sum(list(1)), 1 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + sum(list(1, 2)), 1 + 2 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + sum(list(1, 2, 3)), 1 + 2 + 3 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + sum(list(1, 2, 3, 4)), 1 + 2 + 3 + 4 + )); + + + ////////////////////////////////////////////////////////////////// + // unpack + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + unpack(list(), f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + unpack(list(x<0>{}), f), + f(x<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + unpack(list(x<0>{}, x<1>{}), f), + f(x<0>{}, x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + unpack(list(x<0>{}, x<1>{}, x<2>{}), f), + f(x<0>{}, x<1>{}, x<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + unpack(list(x<0>{}, x<1>{}, x<2>{}, x<3>{}), f), + f(x<0>{}, x<1>{}, x<2>{}, x<3>{}) + )); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_FOLDABLE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/functor.hpp b/src/boost/libs/hana/test/_include/laws/functor.hpp new file mode 100644 index 000000000..d1ddbb4de --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/functor.hpp @@ -0,0 +1,250 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_FUNCTOR_HPP +#define BOOST_HANA_TEST_LAWS_FUNCTOR_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestFunctor : TestFunctor { + using TestFunctor::TestFunctor; + }; + + template + struct TestFunctor { + template + TestFunctor(Xs xs, Elements elements) { + hana::for_each(xs, hana::capture(elements)([](auto elements, auto x) { + static_assert(Functor{}, ""); + + test::_injection<0> f{}; + test::_injection<1> g{}; + + // identity + BOOST_HANA_CHECK(hana::equal( + hana::transform(x, id), + x + )); + + // composition + BOOST_HANA_CHECK(hana::equal( + hana::transform(x, hana::compose(f, g)), + hana::transform(hana::transform(x, g), f) + )); + + // method definitions in terms of transform/adjust_if + hana::for_each(elements, hana::capture(x, f, elements)( + [](auto x, auto f, auto elements, auto value) { + BOOST_HANA_CHECK(hana::equal( + hana::adjust(x, value, f), + hana::adjust_if(x, hana::equal.to(value), f) + )); + + hana::for_each(elements, hana::capture(x, value)( + [](auto x, auto oldval, auto newval) { + BOOST_HANA_CHECK(hana::equal( + hana::replace(x, oldval, newval), + hana::replace_if(x, hana::equal.to(oldval), newval) + )); + })); + })); + + auto pred = hana::always(true_c); + BOOST_HANA_CHECK(hana::equal( + hana::adjust_if(x, pred, f), + hana::transform(x, [=](auto z) { + return hana::eval_if(pred(z), + hana::make_lazy(f)(z), + hana::make_lazy(z) + ); + }) + )); + + test::_constant<0> v{}; + BOOST_HANA_CHECK(hana::equal( + hana::replace_if(x, pred, v), + hana::adjust_if(x, pred, hana::always(v)) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::fill(x, v), + hana::replace_if(x, hana::always(true_c), v) + )); + + })); + } + }; + + template + struct TestFunctor::value>> + : TestFunctor + { + struct undefined { }; + + template + TestFunctor(Xs xs, Elements elements) + : TestFunctor{xs, elements} + { + using test::ct_eq; + using test::cx_eq; + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // replace_if + ////////////////////////////////////////////////////////////////// + { + auto a = ct_eq<888>{}; + auto b = ct_eq<999>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(), undefined{}, undefined{}), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(ct_eq<0>{}), equal.to(a), undefined{}), + list(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(a), equal.to(a), b), + list(b) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(ct_eq<0>{}, ct_eq<1>{}), equal.to(a), undefined{}), + list(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(a, ct_eq<1>{}), equal.to(a), b), + list(b, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(ct_eq<0>{}, a), equal.to(a), b), + list(ct_eq<0>{}, b) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(a, a), equal.to(a), b), + list(b, b) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), equal.to(a), undefined{}), + list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(a, ct_eq<1>{}, ct_eq<2>{}), equal.to(a), b), + list(b, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(ct_eq<0>{}, a, ct_eq<2>{}), equal.to(a), b), + list(ct_eq<0>{}, b, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(ct_eq<0>{}, ct_eq<1>{}, a), equal.to(a), b), + list(ct_eq<0>{}, ct_eq<1>{}, b) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(a, ct_eq<1>{}, a), equal.to(a), b), + list(b, ct_eq<1>{}, b) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(list(a, ct_eq<1>{}, a, ct_eq<3>{}, a), equal.to(a), b), + list(b, ct_eq<1>{}, b, ct_eq<3>{}, b) + )); + } + + ////////////////////////////////////////////////////////////////// + // replace + ////////////////////////////////////////////////////////////////// + { + auto a = ct_eq<888>{}; + auto b = ct_eq<999>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(), undefined{}, undefined{}), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(ct_eq<0>{}), a, undefined{}), + list(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(a), a, b), + list(b) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(ct_eq<0>{}, ct_eq<1>{}), a, undefined{}), + list(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(a, ct_eq<1>{}), a, b), + list(b, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(ct_eq<0>{}, a), a, b), + list(ct_eq<0>{}, b) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(a, a), a, b), + list(b, b) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), a, undefined{}), + list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(a, ct_eq<1>{}, ct_eq<2>{}), a, b), + list(b, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(ct_eq<0>{}, a, ct_eq<2>{}), a, b), + list(ct_eq<0>{}, b, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(ct_eq<0>{}, ct_eq<1>{}, a), a, b), + list(ct_eq<0>{}, ct_eq<1>{}, b) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(a, ct_eq<1>{}, a), a, b), + list(b, ct_eq<1>{}, b) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace(list(a, ct_eq<1>{}, a, ct_eq<3>{}, a), a, b), + list(b, ct_eq<1>{}, b, ct_eq<3>{}, b) + )); + } + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_FUNCTOR_HPP diff --git a/src/boost/libs/hana/test/_include/laws/group.hpp b/src/boost/libs/hana/test/_include/laws/group.hpp new file mode 100644 index 000000000..b9eeab776 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/group.hpp @@ -0,0 +1,93 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_GROUP_HPP +#define BOOST_HANA_TEST_LAWS_GROUP_HPP + +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestGroup : TestGroup { + using TestGroup::TestGroup; + }; + + template + struct TestGroup { + template + TestGroup(Xs xs) { + hana::for_each(xs, [](auto x) { + static_assert(Group{}, ""); + }); + +#ifdef BOOST_HANA_WORKAROUND_MSVC_DECLTYPEAUTO_RETURNTYPE_662735 + zero(); // force adding zero's member function to pending temploid list +#endif + + foreach2(xs, [](auto x, auto y) { + + // left inverse + BOOST_HANA_CHECK(hana::equal( + hana::plus(x, hana::negate(x)), + zero() + )); + + // right inverse + BOOST_HANA_CHECK(hana::equal( + hana::plus(hana::negate(x), x), + zero() + )); + + // default definition of minus + BOOST_HANA_CHECK(hana::equal( + hana::minus(x, y), + hana::plus(x, hana::negate(y)) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::minus(y, x), + hana::plus(y, hana::negate(x)) + )); + + // default definition of negate + BOOST_HANA_CHECK(hana::equal( + hana::negate(hana::negate(x)), + x + )); + }); + } + }; + + template + struct TestGroup::value>> + : TestGroup + { + template + TestGroup(Xs xs) : TestGroup{xs} { + foreach2(xs, [](auto x, auto y) { + + BOOST_HANA_CHECK(hana::equal( + hana::negate(hana::value(x)), + hana::value(hana::negate(x)) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::minus(hana::value(x), hana::value(y)), + hana::value(hana::minus(x, y)) + )); + + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_GROUP_HPP diff --git a/src/boost/libs/hana/test/_include/laws/hashable.hpp b/src/boost/libs/hana/test/_include/laws/hashable.hpp new file mode 100644 index 000000000..0fbd8f333 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/hashable.hpp @@ -0,0 +1,60 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_HASHABLE_HPP +#define BOOST_HANA_TEST_LAWS_HASHABLE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestHashable : TestHashable { + using TestHashable::TestHashable; + }; + + template + struct TestHashable { + template + TestHashable(Xs xs) { + hana::for_each(xs, [](auto x) { + static_assert(Hashable{}, ""); + }); + + hana::for_each(xs, [&](auto const& x) { + hana::for_each(xs, [&](auto const& y) { + using X = hana::tag_of_t; + using Y = hana::tag_of_t; + constexpr bool comparable = !hana::is_default< + hana::equal_impl + >::value; + + hana::if_(hana::bool_c, + [](auto const& x, auto const& y) { + BOOST_HANA_CHECK( + hana::equal(x, y) + ^implies^ + hana::equal(hana::hash(x), hana::hash(y)) + ); + }, + [](auto...) { } + )(x, y); + }); + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_HASHABLE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/iterable.hpp b/src/boost/libs/hana/test/_include/laws/iterable.hpp new file mode 100644 index 000000000..d6d84c5ec --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/iterable.hpp @@ -0,0 +1,195 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_ITERABLE_HPP +#define BOOST_HANA_TEST_LAWS_ITERABLE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestIterable : TestIterable { + using TestIterable::TestIterable; + }; + + template + struct TestIterable { + template + TestIterable(Xs xs) { + hana::for_each(xs, [](auto xs) { + static_assert(Iterable{}, ""); + + BOOST_HANA_CONSTANT_CHECK( + hana::is_empty(xs) ^iff^ hana::is_empty(hana::to(xs)) + ); + + only_when_(hana::not_(hana::is_empty(xs)), hana::make_lazy([](auto xs) { + BOOST_HANA_CHECK(hana::equal( + hana::front(xs), + hana::front(hana::to(xs)) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::to(hana::drop_front_exactly(xs)), + hana::drop_front_exactly(hana::to(xs)) + )); + + // methods + // back(xs) == at(xs, length(xs)-1) + BOOST_HANA_CHECK(hana::equal( + hana::back(xs), + hana::at(xs, hana::minus(hana::length(xs), hana::size_c<1>)) + )); + + })(xs)); + + // drop_front(xs, 0) == xs + BOOST_HANA_CHECK(hana::equal( + hana::drop_front(xs, size_c<0>), + xs + )); + + // at(xs, n) == front(drop_front(xs, n)) + hana::for_each(hana::make_range(size_c<0>, hana::length(xs)), + hana::capture(xs)([](auto xs, auto n) { + BOOST_HANA_CHECK(hana::equal( + hana::at(xs, n), + hana::front(hana::drop_front(xs, n)) + )); + })); + + // Searchable + hana::eval_if(hana::is_empty(xs), + hana::make_lazy([](auto xs) { + BOOST_HANA_CONSTANT_CHECK( + hana::not_(hana::any_of(xs, hana::always(true_c))) + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(xs, hana::always(true_c)), + nothing + )); + })(xs), + hana::make_lazy([](auto xs) { + BOOST_HANA_CHECK( + hana::any_of(xs, hana::always(true_c)) + ); + BOOST_HANA_CHECK( + hana::not_(hana::any_of(xs, hana::always(false_c))) + ); + + BOOST_HANA_CHECK(hana::equal( + hana::find_if(xs, hana::always(true_c)), + hana::just(hana::front(xs)) + )); + })(xs) + ); + + }); + } + }; + + template + struct TestIterable::value>> + : TestIterable + { + template + using x = ct_eq; + + template + struct invalid { }; + + struct undefined { }; + + template + TestIterable(Xs xs) : TestIterable{xs} { + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // front + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + front(list(x<0>{})), + x<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + front(list(x<0>{}, invalid<>{})), + x<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + front(list(x<0>{}, invalid<1>{}, invalid<2>{})), + x<0>{} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + front(list(1)), 1 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + front(list(1, '2')), 1 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + front(list(1, '2', 3.3)), 1 + )); + + ////////////////////////////////////////////////////////////////// + // back + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + back(list(x<0>{})), + x<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + back(list(invalid<0>{}, x<1>{})), + x<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + back(list(invalid<0>{}, invalid<1>{}, x<2>{})), + x<2>{} + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + back(list(1)), 1 + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + back(list(1, '2')), '2' + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + back(list(1, '2', 3.3)), 3.3 + )); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_ITERABLE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/logical.hpp b/src/boost/libs/hana/test/_include/laws/logical.hpp new file mode 100644 index 000000000..df9932766 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/logical.hpp @@ -0,0 +1,137 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_LOGICAL_HPP +#define BOOST_HANA_TEST_LAWS_LOGICAL_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestLogical : TestLogical { + using TestLogical::TestLogical; + }; + + template + struct TestLogical { + template + static void for_each_such_that(Xs xs, Pred pred, F f) { + hana::for_each(xs, [&pred, &f](auto x) { + hana::eval_if(pred(x), + hana::make_lazy(f)(x), + [](auto) { } + ); + }); + } + + template + TestLogical(Xs xs) { + hana::for_each(xs, [](auto x) { + static_assert(Logical{}, ""); + }); + + foreach3(xs, hana::capture(xs)([](auto xs, auto a, auto b, auto c) { + auto true_valued = [](auto x) { + return hana::if_(x, true_c, false_c); + }; + auto false_valued = [](auto x) { + return hana::if_(x, false_c, true_c); + }; + + // associativity + BOOST_HANA_CHECK(hana::equal( + hana::or_(a, hana::or_(b, c)), + hana::or_(hana::or_(a, b), c) + )); + BOOST_HANA_CHECK(hana::equal( + hana::and_(a, hana::and_(b, c)), + hana::and_(hana::and_(a, b), c) + )); + + // equivalence through commutativity + BOOST_HANA_CHECK( + hana::or_(a, b) ^iff^ hana::or_(b, a) + ); + BOOST_HANA_CHECK( + hana::and_(a, b) ^iff^ hana::and_(b, a) + ); + + // absorption + BOOST_HANA_CHECK(hana::equal( + hana::or_(a, hana::and_(a, b)), a + )); + BOOST_HANA_CHECK(hana::equal( + hana::and_(a, hana::or_(a, b)), a + )); + + // left identity + TestLogical::for_each_such_that(xs, true_valued, + hana::capture(a)([](auto a, auto t) { + BOOST_HANA_CHECK(hana::equal( + hana::and_(t, a), a + )); + })); + TestLogical::for_each_such_that(xs, false_valued, + hana::capture(a)([](auto a, auto f) { + BOOST_HANA_CHECK(hana::equal( + hana::or_(f, a), a + )); + })); + + // distributivity + BOOST_HANA_CHECK(hana::equal( + hana::or_(a, hana::and_(b, c)), + hana::and_(hana::or_(a, b), hana::or_(a, c)) + )); + BOOST_HANA_CHECK(hana::equal( + hana::and_(a, hana::or_(b, c)), + hana::or_(hana::and_(a, b), hana::and_(a, c)) + )); + + // complements + BOOST_HANA_CHECK(true_valued(hana::or_(a, hana::not_(a)))); + BOOST_HANA_CHECK(false_valued(hana::and_(a, hana::not_(a)))); + + })); + } + }; + + template + struct TestLogical::value>> + : TestLogical + { + template + TestLogical(Xs xs) : TestLogical{xs} { + foreach2(xs, [](auto x, auto y) { + + BOOST_HANA_CHECK(hana::equal( + hana::value(hana::not_(x)), + hana::not_(hana::value(x)) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::value(hana::and_(x, y)), + hana::and_(hana::value(x), hana::value(y)) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::value(hana::or_(x, y)), + hana::or_(hana::value(x), hana::value(y)) + )); + + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_LOGICAL_HPP diff --git a/src/boost/libs/hana/test/_include/laws/monad.hpp b/src/boost/libs/hana/test/_include/laws/monad.hpp new file mode 100644 index 000000000..25a23d417 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/monad.hpp @@ -0,0 +1,222 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_MONAD_HPP +#define BOOST_HANA_TEST_LAWS_MONAD_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestMonad : TestMonad { + using TestMonad::TestMonad; + }; + + template + struct TestMonad { + // Xs are Monads over something + // XXs are Monads over Monads over something + template + TestMonad(Xs xs, XXs xxs) { + hana::for_each(xs, [](auto m) { + static_assert(Monad{}, ""); + + auto f = hana::compose(lift, test::_injection<0>{}); + auto g = hana::compose(lift, test::_injection<1>{}); + auto h = hana::compose(lift, test::_injection<2>{}); + auto x = test::ct_eq<0>{}; + + ////////////////////////////////////////////////////////////// + // Laws formulated with `monadic_compose` + ////////////////////////////////////////////////////////////// + // associativity + BOOST_HANA_CHECK(hana::equal( + hana::monadic_compose(h, hana::monadic_compose(g, f))(x), + hana::monadic_compose(hana::monadic_compose(h, g), f)(x) + )); + + // left identity + BOOST_HANA_CHECK(hana::equal( + hana::monadic_compose(lift, f)(x), + f(x) + )); + + // right identity + BOOST_HANA_CHECK(hana::equal( + hana::monadic_compose(f, lift)(x), + f(x) + )); + + ////////////////////////////////////////////////////////////// + // Laws formulated with `chain` + // + // This just provides us with some additional cross-checking, + // but the documentation does not mention those. + ////////////////////////////////////////////////////////////// + BOOST_HANA_CHECK(hana::equal( + hana::chain(hana::lift(x), f), + f(x) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::chain(m, lift), + m + )); + + BOOST_HANA_CHECK(hana::equal( + hana::chain(m, [f, g](auto x) { + return hana::chain(f(x), g); + }), + hana::chain(hana::chain(m, f), g) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::transform(m, f), + hana::chain(m, hana::compose(lift, f)) + )); + + ////////////////////////////////////////////////////////////// + // Consistency of method definitions + ////////////////////////////////////////////////////////////// + // consistency of `chain` + BOOST_HANA_CHECK(hana::equal( + hana::chain(m, f), + hana::flatten(hana::transform(m, f)) + )); + + // consistency of `monadic_compose` + BOOST_HANA_CHECK(hana::equal( + hana::monadic_compose(f, g)(x), + hana::chain(g(x), f) + )); + }); + + // consistency of `flatten` + hana::for_each(xxs, [](auto mm) { + BOOST_HANA_CHECK(hana::equal( + hana::flatten(mm), + hana::chain(mm, hana::id) + )); + }); + } + }; + + template + struct TestMonad::value>> + : TestMonad + { + template + TestMonad(Xs xs, XXs xxs) + : TestMonad{xs, xxs} + { + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // flatten + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(list(list(), list())), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(list(list(ct_eq<0>{}), list())), + list(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(list(list(), list(ct_eq<0>{}))), + list(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(list(list(ct_eq<0>{}), list(ct_eq<1>{}))), + list(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(list( + list(ct_eq<0>{}, ct_eq<1>{}), + list(), + list(ct_eq<2>{}, ct_eq<3>{}), + list(ct_eq<4>{}) + )), + list(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + + // just make sure we don't double move; this happened in hana::tuple + hana::flatten(list(list(Tracked{1}, Tracked{2}))); + + ////////////////////////////////////////////////////////////////// + // chain + ////////////////////////////////////////////////////////////////// + { + test::_injection<0> f{}; + auto g = hana::compose(list, f); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(list(), g), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(list(ct_eq<1>{}), g), + list(f(ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(list(ct_eq<1>{}, ct_eq<2>{}), g), + list(f(ct_eq<1>{}), f(ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(list(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), g), + list(f(ct_eq<1>{}), f(ct_eq<2>{}), f(ct_eq<3>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(list(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), g), + list(f(ct_eq<1>{}), f(ct_eq<2>{}), f(ct_eq<3>{}), f(ct_eq<4>{})) + )); + } + + ////////////////////////////////////////////////////////////////// + // monadic_compose + ////////////////////////////////////////////////////////////////// + { + test::_injection<0> f{}; + test::_injection<1> g{}; + + auto mf = [=](auto x) { return list(f(x), f(f(x))); }; + auto mg = [=](auto x) { return list(g(x), g(g(x))); }; + + auto x = test::ct_eq<0>{}; + BOOST_HANA_CHECK(hana::equal( + hana::monadic_compose(mf, mg)(x), + list(f(g(x)), f(f(g(x))), f(g(g(x))), f(f(g(g(x))))) + )); + } + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_MONAD_HPP diff --git a/src/boost/libs/hana/test/_include/laws/monad_plus.hpp b/src/boost/libs/hana/test/_include/laws/monad_plus.hpp new file mode 100644 index 000000000..406320c91 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/monad_plus.hpp @@ -0,0 +1,616 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_MONAD_PLUS_HPP +#define BOOST_HANA_TEST_LAWS_MONAD_PLUS_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestMonadPlus : TestMonadPlus { + using TestMonadPlus::TestMonadPlus; + }; + + template + struct TestMonadPlus { + template + TestMonadPlus(Xs xs, Predicates predicates, Values values) { +#ifdef BOOST_HANA_WORKAROUND_MSVC_DECLTYPEAUTO_RETURNTYPE_662735 + empty(); // force adding empty's member function to pending temploid list +#endif + + hana::for_each(xs, [](auto a) { + static_assert(MonadPlus{}, ""); + + // left identity + BOOST_HANA_CHECK(hana::equal( + hana::concat(hana::empty(), a), + a + )); + + // right identity + BOOST_HANA_CHECK(hana::equal( + hana::concat(a, hana::empty()), + a + )); + + // absorption + auto f = hana::compose(lift, test::_injection<0>{}); + BOOST_HANA_CHECK(hana::equal( + hana::chain(hana::empty(), f), + hana::empty() + )); + + BOOST_HANA_CHECK(hana::equal( + hana::chain(a, hana::always(hana::empty())), + hana::empty() + )); + + }); + + // associativity + foreach3(xs, [](auto a, auto b, auto c) { + BOOST_HANA_CHECK(hana::equal( + hana::concat(a, hana::concat(b, c)), + hana::concat(hana::concat(a, b), c) + )); + }); + + // Default method definitions + hana::for_each(xs, hana::capture(predicates, values)( + [](auto predicates, auto values, auto x) { + + // remove_if(x, pred) == filter(x, negated pred) + hana::for_each(predicates, hana::capture(x)([](auto x, auto pred) { + BOOST_HANA_CHECK(hana::equal( + hana::remove_if(x, pred), + hana::filter(x, hana::compose(hana::not_, pred)) + )); + })); + + // remove(x, value) == remove_if(x, equal.to(value)) + hana::for_each(values, hana::capture(x)([](auto x, auto value) { + BOOST_HANA_CHECK(hana::equal( + hana::remove(x, value), + hana::remove_if(x, hana::equal.to(value)) + )); + })); + })); + } + }; + + template + struct TestMonadPlus::value>> + : TestMonadPlus + { + template + using eq = test::ct_eq; + + struct undefined { }; + + template + TestMonadPlus(Xs xs, Predicates predicates, Values values) + : TestMonadPlus{xs, predicates, values} + { + auto z = eq<999>{}; + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // empty + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + hana::empty(), list() + )); + + ////////////////////////////////////////////////////////////////// + // concat + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(), list()), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(), list(eq<0>{})), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(), list(eq<0>{}, eq<1>{})), + list(eq<0>{}, eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(eq<0>{}), list()), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(eq<0>{}), list(eq<1>{})), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(eq<0>{}), list(eq<1>{}, eq<2>{})), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(eq<0>{}, eq<1>{}), list()), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(eq<0>{}, eq<1>{}), list(eq<2>{})), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(eq<0>{}, eq<1>{}), list(eq<2>{}, eq<3>{})), + list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(equal( + concat(list(), list()), + list() + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + concat(list(1), list()), + list(1) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + concat(list(), list(1)), + list(1) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + concat(list(1), list('2')), + list(1, '2') + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + concat(list(1, '2'), list(3.3)), + list(1, '2', 3.3) + )); + + + ////////////////////////////////////////////////////////////////// + // filter + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(), undefined{}), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(z), not_equal.to(z)), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(eq<1>{}), not_equal.to(z)), + list(eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(eq<1>{}, eq<2>{}), not_equal.to(z)), + list(eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(z, eq<2>{}), not_equal.to(z)), + list(eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(eq<1>{}, z), not_equal.to(z)), + list(eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(z, eq<2>{}, eq<3>{}), not_equal.to(z)), + list(eq<2>{}, eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(eq<1>{}, z, eq<3>{}), not_equal.to(z)), + list(eq<1>{}, eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(eq<1>{}, eq<2>{}, z), not_equal.to(z)), + list(eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(eq<1>{}, z, z), not_equal.to(z)), + list(eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(z, eq<2>{}, z), not_equal.to(z)), + list(eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(z, z, eq<3>{}), not_equal.to(z)), + list(eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + filter(list(eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}, z), not_equal.to(z)), + list(eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}) + )); + + ////////////////////////////////////////////////////////////////// + // prepend + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + prepend(list(), eq<0>{}), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + prepend(list(eq<1>{}), eq<0>{}), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + prepend(list(eq<1>{}, eq<2>{}), eq<0>{}), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + prepend(list(eq<1>{}, eq<2>{}, eq<3>{}), eq<0>{}), + list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}) + )); + + + BOOST_HANA_CONSTEXPR_CHECK(equal( + prepend(list(), 1), + list(1) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + prepend(list('2'), 1), + list(1, '2') + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + prepend(list('2', 3.3), 1), + list(1, '2', 3.3) + )); + + ////////////////////////////////////////////////////////////////// + // append + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + append(list(), eq<0>{}), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + append(list(eq<0>{}), eq<1>{}), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + append(list(eq<0>{}, eq<1>{}), eq<2>{}), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + + BOOST_HANA_CONSTEXPR_CHECK(equal( + append(list(), 1), list(1) + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + append(list(1), '2'), list(1, '2') + )); + BOOST_HANA_CONSTEXPR_CHECK(equal( + append(list(1, '2'), 3.3), list(1, '2', 3.3) + )); + + + ////////////////////////////////////////////////////////////////// + // cycle + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(), size_c<0>), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(), size_c<1>), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(), size_c<2>), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(), size_c<3>), + list() + )); + + + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}), size_c<0>), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}), size_c<1>), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}), size_c<2>), + list(eq<0>{}, eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}), size_c<3>), + list(eq<0>{}, eq<0>{}, eq<0>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}), size_c<0>), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}), size_c<1>), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}), size_c<2>), + list(eq<0>{}, eq<1>{}, eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}), size_c<3>), + list(eq<0>{}, eq<1>{}, eq<0>{}, eq<1>{}, eq<0>{}, eq<1>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}, eq<2>{}), size_c<0>), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}, eq<2>{}), size_c<1>), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}, eq<2>{}), size_c<2>), + list(eq<0>{}, eq<1>{}, eq<2>{}, eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + cycle(list(eq<0>{}, eq<1>{}, eq<2>{}), size_c<3>), + list(eq<0>{}, eq<1>{}, eq<2>{}, eq<0>{}, eq<1>{}, eq<2>{}, eq<0>{}, eq<1>{}, eq<2>{}) + )); + + ////////////////////////////////////////////////////////////////// + // remove_if + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(), undefined{}), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(eq<0>{}), equal.to(z)), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(z), equal.to(z)), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(eq<0>{}, eq<1>{}), equal.to(z)), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(z, eq<1>{}), equal.to(z)), + list(eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(eq<0>{}, z), equal.to(z)), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(z, z), equal.to(z)), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(eq<0>{}, eq<1>{}, eq<2>{}), equal.to(z)), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(eq<0>{}, eq<1>{}, z), equal.to(z)), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(eq<0>{}, z, eq<2>{}), equal.to(z)), + list(eq<0>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(z, eq<1>{}, eq<2>{}), equal.to(z)), + list(eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(z, z, eq<2>{}), equal.to(z)), + list(eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(eq<0>{}, z, z), equal.to(z)), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + remove_if(list(z, z, z), equal.to(z)), + list() + )); + + ////////////////////////////////////////////////////////////////// + // remove + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(), undefined{}), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(eq<0>{}), z), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(z), z), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(eq<0>{}, eq<1>{}), z), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(z, eq<1>{}), z), + list(eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(eq<0>{}, z), z), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(z, z), z), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(eq<0>{}, eq<1>{}, eq<2>{}), z), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(eq<0>{}, eq<1>{}, z), z), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(eq<0>{}, z, eq<2>{}), z), + list(eq<0>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(z, eq<1>{}, eq<2>{}), z), + list(eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(z, z, eq<2>{}), z), + list(eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(eq<0>{}, z, z), z), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + hana::remove(list(z, z, z), z), + list() + )); + + ////////////////////////////////////////////////////////////////// + // replicate + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + replicate(eq<0>{}, size_c<0>), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + replicate(eq<0>{}, size_c<1>), + list(eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + replicate(eq<0>{}, size_c<2>), + list(eq<0>{}, eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + replicate(eq<0>{}, size_c<3>), + list(eq<0>{}, eq<0>{}, eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + replicate(eq<0>{}, size_c<4>), + list(eq<0>{}, eq<0>{}, eq<0>{}, eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + replicate(eq<0>{}, size_c<5>), + list(eq<0>{}, eq<0>{}, eq<0>{}, eq<0>{}, eq<0>{}) + )); + + + ////////////////////////////////////////////////////////////////// + // prefix + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + prefix(list(), z), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + prefix(list(eq<0>{}), z), + list(z, eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + prefix(list(eq<0>{}, eq<1>{}), z), + list(z, eq<0>{}, z, eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + prefix(list(eq<0>{}, eq<1>{}, eq<2>{}), z), + list(z, eq<0>{}, z, eq<1>{}, z, eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + prefix(list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}), z), + list(z, eq<0>{}, z, eq<1>{}, z, eq<2>{}, z, eq<3>{}) + )); + + + ////////////////////////////////////////////////////////////////// + // suffix + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + suffix(list(), z), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + suffix(list(eq<0>{}), z), + list(eq<0>{}, z) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + suffix(list(eq<0>{}, eq<1>{}), z), + list(eq<0>{}, z, eq<1>{}, z) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + suffix(list(eq<0>{}, eq<1>{}, eq<2>{}), z), + list(eq<0>{}, z, eq<1>{}, z, eq<2>{}, z) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + suffix(list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}), z), + list(eq<0>{}, z, eq<1>{}, z, eq<2>{}, z, eq<3>{}, z) + )); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_MONAD_PLUS_HPP diff --git a/src/boost/libs/hana/test/_include/laws/monoid.hpp b/src/boost/libs/hana/test/_include/laws/monoid.hpp new file mode 100644 index 000000000..d500992a0 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/monoid.hpp @@ -0,0 +1,86 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_MONOID_HPP +#define BOOST_HANA_TEST_LAWS_MONOID_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestMonoid : TestMonoid { + using TestMonoid::TestMonoid; + }; + + template + struct TestMonoid { + template + TestMonoid(Xs xs) { +#ifdef BOOST_HANA_WORKAROUND_MSVC_DECLTYPEAUTO_RETURNTYPE_662735 + zero(); // force adding zero's member function to pending temploid list +#endif + + hana::for_each(xs, hana::capture(xs)([](auto xs, auto a) { + static_assert(Monoid{}, ""); + + // left identity + BOOST_HANA_CHECK(hana::equal( + hana::plus(zero(), a), + a + )); + + // right identity + BOOST_HANA_CHECK(hana::equal( + hana::plus(a, zero()), + a + )); + + hana::for_each(xs, + hana::capture(xs, a)([](auto xs, auto a, auto b) { + hana::for_each(xs, + hana::capture(a, b)([](auto a, auto b, auto c) { + // associativity + BOOST_HANA_CHECK(equal( + hana::plus(a, hana::plus(b, c)), + hana::plus(hana::plus(a, b), c) + )); + })); + })); + + })); + } + }; + + template + struct TestMonoid::value>> + : TestMonoid + { + template + TestMonoid(Xs xs) : TestMonoid{xs} { + + BOOST_HANA_CHECK(hana::equal( + hana::value(zero()), + zero() + )); + + foreach2(xs, [](auto x, auto y) { + BOOST_HANA_CHECK(hana::equal( + hana::plus(hana::value(x), hana::value(y)), + hana::value(hana::plus(x, y)) + )); + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_MONOID_HPP diff --git a/src/boost/libs/hana/test/_include/laws/orderable.hpp b/src/boost/libs/hana/test/_include/laws/orderable.hpp new file mode 100644 index 000000000..f49ea7f8a --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/orderable.hpp @@ -0,0 +1,182 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_ORDERABLE_HPP +#define BOOST_HANA_TEST_LAWS_ORDERABLE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestOrderable : TestOrderable { + using TestOrderable::TestOrderable; + }; + + template + struct TestOrderable { + template + TestOrderable(Xs xs) { + hana::for_each(xs, [](auto x) { + static_assert(Orderable{}, ""); + }); + + foreach2(xs, [](auto a, auto b) { + + // antisymmetry + BOOST_HANA_CHECK( + hana::and_(hana::less_equal(a, b), hana::less_equal(b, a)) + ^implies^ hana::equal(a, b) + ); + + // totality + BOOST_HANA_CHECK( + hana::or_(hana::less_equal(a, b), hana::less_equal(b, a)) + ); + + // other methods in terms of `less_equal` + BOOST_HANA_CHECK( + hana::less(a, b) ^iff^ hana::not_(hana::less_equal(b, a)) + ); + + BOOST_HANA_CHECK( + hana::greater(a, b) ^iff^ hana::less(b, a) + ); + + BOOST_HANA_CHECK( + hana::greater_equal(a, b) ^iff^ hana::not_(hana::less(a, b)) + ); + + // less.than & al. + BOOST_HANA_CHECK(hana::less.than(a)(b) ^iff^ hana::less(b, a)); + BOOST_HANA_CHECK(hana::greater.than(a)(b) ^iff^ hana::greater(b, a)); + BOOST_HANA_CHECK(hana::less_equal.than(a)(b) ^iff^ hana::less_equal(b, a)); + BOOST_HANA_CHECK(hana::greater_equal.than(a)(b) ^iff^ hana::greater_equal(b, a)); + + // ordering + _injection<0> f{}; // test::_injection is also monotonic + BOOST_HANA_CHECK( + hana::ordering(f)(a, b) ^iff^ hana::less(f(a), f(b)) + ); + }); + + // transitivity + foreach3(xs, [](auto a, auto b, auto c) { + BOOST_HANA_CHECK( + hana::and_(hana::less_equal(a, b), hana::less_equal(b, c)) + ^implies^ hana::less_equal(a, c) + ); + }); + } + }; + + template + struct TestOrderable::value>> + : TestOrderable + { + template + TestOrderable(Xs xs) : TestOrderable{xs} { + foreach2(xs, [](auto a, auto b) { + + BOOST_HANA_CHECK( + hana::value(hana::less(a, b)) ^iff^ + hana::less(hana::value(a), hana::value(b)) + ); + + }); + } + }; + + template + struct TestOrderable::value>> + : TestOrderable + { + template + TestOrderable(Products products) + : TestOrderable{products} + { + foreach2(products, [](auto x, auto y) { + BOOST_HANA_CHECK( + hana::less(x, y) ^iff^ + hana::or_( + hana::less(hana::first(x), hana::first(y)), + hana::and_( + hana::equal(hana::first(x), hana::first(y)), + hana::less(hana::second(x), hana::second(y)) + ) + ) + ); + }); + } + }; + + template + struct TestOrderable::value>> + : TestOrderable + { + struct invalid { }; + + template + TestOrderable(Xs xs) : TestOrderable{xs} { + constexpr auto list = make; + + ////////////////////////////////////////////////////////////////// + // less + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + list(), + list() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + list(), + list(invalid{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + list(invalid{}), + list() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::less( + list(ct_ord<0>{}), + list(ct_ord<7>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + list(ct_ord<1>{}), + list(ct_ord<0>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + list(ct_ord<0>{}, ct_ord<1>{}, ct_ord<8>{}), + list(ct_ord<0>{}, ct_ord<1>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + list(ct_ord<0>{}, ct_ord<0>{}, ct_ord<8>{}), + list(ct_ord<0>{}, ct_ord<1>{}) + )); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_ORDERABLE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/product.hpp b/src/boost/libs/hana/test/_include/laws/product.hpp new file mode 100644 index 000000000..18e5a15d2 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/product.hpp @@ -0,0 +1,46 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_PRODUCT_HPP +#define BOOST_HANA_TEST_LAWS_PRODUCT_HPP + +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestProduct : TestProduct { + using TestProduct::TestProduct; + }; + + template + struct TestProduct { + template + TestProduct(Elements elements) { + foreach2(elements, [](auto x, auto y) { + static_assert(Product(x, y))>{}, ""); + + BOOST_HANA_CHECK(hana::equal( + hana::first(hana::make

(x, y)), + x + )); + + BOOST_HANA_CHECK(hana::equal( + hana::second(hana::make

(x, y)), + y + )); + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_PRODUCT_HPP diff --git a/src/boost/libs/hana/test/_include/laws/ring.hpp b/src/boost/libs/hana/test/_include/laws/ring.hpp new file mode 100644 index 000000000..4afbca05c --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/ring.hpp @@ -0,0 +1,125 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_RING_HPP +#define BOOST_HANA_TEST_LAWS_RING_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestRing : TestRing { + using TestRing::TestRing; + }; + + template + struct TestRing { + template + TestRing(Xs xs) { +#ifdef BOOST_HANA_WORKAROUND_MSVC_DECLTYPEAUTO_RETURNTYPE_662735 + one(); // force adding one's member function to pending temploid list +#endif + + hana::for_each(xs, hana::capture(xs)([](auto xs, auto x) { + static_assert(Ring{}, ""); + + foreach2(xs, hana::capture(x)([](auto x, auto y, auto z) { + // associativity + BOOST_HANA_CHECK(hana::equal( + hana::mult(x, hana::mult(y, z)), + hana::mult(hana::mult(x, y), z) + )); + + // distributivity + BOOST_HANA_CHECK(hana::equal( + hana::mult(x, hana::plus(y, z)), + hana::plus(hana::mult(x, y), hana::mult(x, z)) + )); + })); + + // right identity + BOOST_HANA_CHECK(hana::equal( + hana::mult(x, one()), x + )); + + // left identity + BOOST_HANA_CHECK(hana::equal( + hana::mult(one(), x), x + )); + + // power + BOOST_HANA_CHECK(hana::equal( + hana::power(x, int_c<0>), + one() + )); + + BOOST_HANA_CHECK(hana::equal( + hana::power(x, int_c<1>), + x + )); + + BOOST_HANA_CHECK(hana::equal( + hana::power(x, int_c<2>), + hana::mult(x, x) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::power(x, int_c<3>), + hana::mult(hana::mult(x, x), x) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::power(x, int_c<4>), + hana::mult(hana::mult(hana::mult(x, x), x), x) + )); + + BOOST_HANA_CHECK(hana::equal( + hana::power(x, int_c<5>), + hana::mult(hana::mult(hana::mult(hana::mult(x, x), x), x), x) + )); + + })); + } + }; + + template + struct TestRing::value>> + : TestRing + { + template + TestRing(Xs xs) : TestRing{xs} { + BOOST_HANA_CHECK(hana::equal( + hana::value(one()), + one() + )); + + foreach2(xs, [](auto x, auto y) { + BOOST_HANA_CHECK(hana::equal( + hana::mult(hana::value(x), hana::value(y)), + hana::value(hana::mult(x, y)) + )); + }); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_RING_HPP diff --git a/src/boost/libs/hana/test/_include/laws/searchable.hpp b/src/boost/libs/hana/test/_include/laws/searchable.hpp new file mode 100644 index 000000000..ae55b06eb --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/searchable.hpp @@ -0,0 +1,611 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_SEARCHABLE_HPP +#define BOOST_HANA_TEST_LAWS_SEARCHABLE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestSearchable : TestSearchable { + using TestSearchable::TestSearchable; + }; + + template + struct TestSearchable { + template + TestSearchable(Searchables searchables, Keys keys) { + hana::for_each(searchables, [](auto xs) { + static_assert(Searchable{}, ""); + }); + + auto predicates = hana::concat( + hana::to_tuple(hana::transform(keys, equal.to)), + hana::make_tuple( + hana::always(false_c), + hana::always(true_c) + ) + ); + + hana::for_each(searchables, hana::capture(searchables, keys, predicates)( + [](auto searchables, auto keys, auto predicates, auto xs) { + hana::for_each(predicates, hana::capture(xs)( + [](auto xs, auto p) { + // any_of(xs, p) <=> !all_of(xs, negated p) + // <=> !none_of(xs, p) + BOOST_HANA_CHECK( + hana::any_of(xs, p) ^iff^ + hana::not_(hana::all_of(xs, hana::compose(not_, p))) + ); + + BOOST_HANA_CHECK( + hana::any_of(xs, p) ^iff^ + hana::not_(hana::none_of(xs, p)) + ); + })); + + // any(xs) <=> any_of(xs, id) + // all(xs) <=> all_of(xs, id) + // none(xs) <=> none_of(xs, id) + auto all_logicals = hana::all_of(xs, [](auto x) { + return hana::bool_c::value>; + }); + only_when_(all_logicals, hana::make_lazy([](auto xs) { + BOOST_HANA_CHECK( + hana::any(xs) ^iff^ hana::any_of(xs, id) + ); + + BOOST_HANA_CHECK( + hana::all(xs) ^iff^ hana::all_of(xs, hana::id) + ); + + BOOST_HANA_CHECK( + hana::none(xs) ^iff^ hana::none_of(xs, hana::id) + ); + })(xs)); + + // find_if(xs, always(false_c)) == nothing + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(xs, hana::always(hana::false_c)), + hana::nothing + )); + + hana::for_each(searchables, hana::capture(xs)([](auto xs, auto ys) { + // is_subset(xs, ys) <=> all_of(xs, [](auto x) { return contains(ys, x); }) + BOOST_HANA_CHECK( + hana::is_subset(xs, ys) ^iff^ + hana::all_of(xs, hana::partial(hana::contains, ys)) + ); + + // is_disjoint(xs, ys) <=> none_of(xs, [](auto x) { return contains(ys, x); }) + BOOST_HANA_CHECK( + hana::is_disjoint(xs, ys) ^iff^ + hana::none_of(xs, hana::partial(hana::contains, ys)) + ); + })); + + hana::for_each(keys, hana::capture(xs)([](auto xs, auto key) { + // find(xs, x) == find_if(xs, [](auto y) { return y == x; }) + BOOST_HANA_CHECK(hana::equal( + hana::find(xs, key), + hana::find_if(xs, hana::equal.to(key)) + )); + + // contains(xs, x) <=> any_of(xs, [](auto y) { return y == x; }) + BOOST_HANA_CHECK( + hana::contains(xs, key) ^iff^ + hana::any_of(xs, hana::equal.to(key)) + ); + + only_when_(hana::contains(xs, key), + hana::make_lazy([](auto xs, auto key) { + // at_key(xs, key) == find(xs, key).value() + BOOST_HANA_CHECK(hana::equal( + hana::at_key(xs, key), + hana::find(xs, key).value() + )); + })(xs, key) + ); + })); + })); + } + }; + + template + struct TestSearchable::value>> + : TestSearchable + { + template + using x = _constant; + + template + struct invalid { }; + + struct undefined { }; + + template + TestSearchable(Xs xs, Keys keys) + : TestSearchable{xs, keys} + { + constexpr auto list = make; + + BOOST_HANA_CONSTEXPR_LAMBDA auto is_even = [](auto x) { + return x % 2 == 0; + }; + + auto c = numeric; // a minimal comparable + auto logical = numeric; + + ////////////////////////////////////////////////////////////////// + // any_of + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK( + hana::not_(hana::any_of(list(), equal.to(x<9>{}))) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::not_(hana::any_of(list(x<0>{}), equal.to(x<9>{}))) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}), equal.to(x<0>{})) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, invalid<1>{}), equal.to(x<0>{})) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, invalid<1>{}, invalid<2>{}), equal.to(x<0>{})) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::not_(hana::any_of(list(x<0>{}, x<1>{}), equal.to(x<9>{}))) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, x<1>{}), equal.to(x<1>{})) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, x<1>{}, invalid<2>{}), equal.to(x<1>{})) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, x<1>{}, invalid<2>{}, invalid<3>{}), equal.to(x<1>{})) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::not_(hana::any_of(list(x<0>{}, x<1>{}, x<2>{}), equal.to(x<9>{}))) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, x<1>{}, x<2>{}), equal.to(x<2>{})) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, x<1>{}, x<2>{}, nothing), equal.to(x<2>{})) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::any_of(list(x<0>{}, x<1>{}, x<2>{}, nothing, nothing), equal.to(x<2>{})) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::not_(hana::any_of(list(), invalid<>{})) + ); + + + BOOST_HANA_CONSTEXPR_CHECK( + hana::any_of(list(c(0)), equal.to(c(0))) + ); + BOOST_HANA_CONSTEXPR_CHECK( + hana::not_(hana::any_of(list(c(0)), equal.to(c(1)))) + ); + BOOST_HANA_CONSTEXPR_CHECK( + hana::not_(hana::any_of(list(1), is_even)) + ); + BOOST_HANA_CONSTEXPR_CHECK( + hana::any_of(list(2), is_even) + ); + BOOST_HANA_CONSTEXPR_CHECK( + hana::any_of(list(1, 2), is_even) + ); + BOOST_HANA_CONSTEXPR_CHECK( + hana::not_(hana::any_of(list(1, 3), is_even)) + ); + BOOST_HANA_CONSTEXPR_CHECK( + hana::any_of(list(1, 3, 4), is_even) + ); + + ////////////////////////////////////////////////////////////////// + // any + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any(list()))); + BOOST_HANA_CONSTEXPR_CHECK(hana::any(list(logical(true)))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::any(list(logical(false))))); + + + ////////////////////////////////////////////////////////////////// + // all_of + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK( + all_of(list(), invalid<>{}) + ); + BOOST_HANA_CONSTEXPR_CHECK( + all_of(list(c(0)), equal.to(c(0))) + ); + BOOST_HANA_CONSTEXPR_CHECK( + not_(all_of(list(c(0)), equal.to(c(1)))) + ); + BOOST_HANA_CONSTEXPR_CHECK(not_( + all_of(list(c(0), c(1)), equal.to(c(0))) + )); + BOOST_HANA_CONSTEXPR_CHECK( + all_of(list(c(0), c(0)), equal.to(c(0))) + ); + + BOOST_HANA_CONSTEXPR_CHECK(not_(all_of(list(1), is_even))); + BOOST_HANA_CONSTEXPR_CHECK(all_of(list(2), is_even)); + BOOST_HANA_CONSTEXPR_CHECK(all_of(list(2, 4), is_even)); + BOOST_HANA_CONSTEXPR_CHECK(not_(all_of(list(1, 2), is_even))); + BOOST_HANA_CONSTEXPR_CHECK(not_(all_of(list(1, 3), is_even))); + BOOST_HANA_CONSTEXPR_CHECK(not_(all_of(list(1, 3, 4), is_even))); + + + ////////////////////////////////////////////////////////////////// + // all + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(all(list())); + BOOST_HANA_CONSTEXPR_CHECK(all(list(logical(true)))); + BOOST_HANA_CONSTEXPR_CHECK(not_(all(list(logical(false))))); + BOOST_HANA_CONSTEXPR_CHECK(all(list(logical(true), logical(true)))); + BOOST_HANA_CONSTEXPR_CHECK(not_(all(list(logical(true), logical(false))))); + + ////////////////////////////////////////////////////////////////// + // none_of + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(none_of(list(), invalid<>{})); + BOOST_HANA_CONSTEXPR_CHECK(none_of(list(c(0)), equal.to(c(1)))); + BOOST_HANA_CONSTEXPR_CHECK(not_(none_of(list(c(0)), equal.to(c(0))))); + + BOOST_HANA_CONSTEXPR_CHECK(none_of(list(1), is_even)); + BOOST_HANA_CONSTEXPR_CHECK(not_(none_of(list(2), is_even))); + BOOST_HANA_CONSTEXPR_CHECK(not_(none_of(list(1, 2), is_even))); + BOOST_HANA_CONSTEXPR_CHECK(none_of(list(1, 3), is_even)); + BOOST_HANA_CONSTEXPR_CHECK(not_(none_of(list(1, 3, 4), is_even))); + + + ////////////////////////////////////////////////////////////////// + // none + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(none(list())); + BOOST_HANA_CONSTEXPR_CHECK(none(list(logical(false)))); + BOOST_HANA_CONSTEXPR_CHECK(not_(none(list(logical(true))))); + + ////////////////////////////////////////////////////////////////// + // find_if + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(), equal.to(x<9>{})), + nothing + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}), equal.to(x<9>{})), + nothing + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}), equal.to(x<0>{})), + just(x<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, invalid<1>{}), equal.to(x<0>{})), + just(x<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, invalid<1>{}, invalid<2>{}), equal.to(x<0>{})), + just(x<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}), equal.to(x<9>{})), + nothing + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}), equal.to(x<1>{})), + just(x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}, invalid<2>{}), equal.to(x<1>{})), + just(x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}, invalid<2>{}, invalid<3>{}), equal.to(x<1>{})), + just(x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}, x<2>{}), equal.to(x<9>{})), + nothing + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}, x<2>{}), equal.to(x<2>{})), + just(x<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}, x<2>{}, nothing), equal.to(x<2>{})), + just(x<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(list(x<0>{}, x<1>{}, x<2>{}, nothing, nothing), equal.to(x<2>{})), + just(x<2>{}) + )); + + // Make sure find_if works with an lvalue sequence. hana::tuple + // used to have a bug that broke this. + auto const const_lvalue = list(x<0>{}, x<1>{}, x<2>{}); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(const_lvalue, equal.to(x<1>{})), + just(x<1>{}) + )); + + auto lvalue = list(x<0>{}, x<1>{}, x<2>{}); + BOOST_HANA_CONSTANT_CHECK(equal( + find_if(lvalue, equal.to(x<1>{})), + just(x<1>{}) + )); + } + + ////////////////////////////////////////////////////////////////// + // find + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(), invalid<>{}), + nothing + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}), x<9>{}), + nothing + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}), x<0>{}), + just(x<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, invalid<1>{}), x<0>{}), + just(x<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, invalid<1>{}, invalid<2>{}), x<0>{}), + just(x<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}), x<9>{}), + nothing + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}), x<1>{}), + just(x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}, invalid<2>{}), x<1>{}), + just(x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}, invalid<2>{}, invalid<3>{}), x<1>{}), + just(x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}, x<2>{}), x<9>{}), + nothing + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}, x<2>{}), x<2>{}), + just(x<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}, x<2>{}, nothing), x<2>{}), + just(x<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + find(list(x<0>{}, x<1>{}, x<2>{}, nothing, nothing), x<2>{}), + just(x<2>{}) + )); + } + + ////////////////////////////////////////////////////////////////// + // at_key + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(equal( + at_key(list(x<0>{}), x<0>{}), + x<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + at_key(list(x<0>{}, x<1>{}), x<0>{}), + x<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + at_key(list(x<0>{}, x<1>{}), x<1>{}), + x<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(equal( + at_key(list(x<0>{}, x<1>{}, x<2>{}), x<0>{}), + x<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + at_key(list(x<0>{}, x<1>{}, x<2>{}), x<1>{}), + x<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(equal( + at_key(list(x<0>{}, x<1>{}, x<2>{}), x<2>{}), + x<2>{} + )); + } + + ////////////////////////////////////////////////////////////////// + // contains + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(not_( + contains(list(), undefined{}) + )); + + BOOST_HANA_CONSTANT_CHECK(not_( + contains(list(x<0>{}), x<999>{}) + )); + + BOOST_HANA_CONSTANT_CHECK( + contains(list(x<0>{}), x<0>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + contains(list(x<0>{}, x<1>{}), x<1>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + contains(list(x<0>{}, x<1>{}, x<3>{}), x<3>{}) + ); + + BOOST_HANA_CONSTEXPR_CHECK(contains(list(c(0)), c(0))); + BOOST_HANA_CONSTEXPR_CHECK(not_(contains(list(c(0)), c(1)))); + + // infix application + BOOST_HANA_CONSTANT_CHECK( + list(x<0>{}, x<1>{}) ^contains^ x<1>{} + ); + } + + ////////////////////////////////////////////////////////////////// + // in + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTEXPR_CHECK(c(0) ^in^ list(c(0))); + BOOST_HANA_CONSTEXPR_CHECK(not_(c(1) ^in^ list(c(0)))); + + ////////////////////////////////////////////////////////////////// + // is_subset + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(is_subset( + list(), list(undefined{}) + )); + + BOOST_HANA_CONSTANT_CHECK(not_(is_subset( + list(undefined{}), list() + ))); + + BOOST_HANA_CONSTEXPR_CHECK(is_subset( + list(c(0)), list(c(0)) + )); + + BOOST_HANA_CONSTEXPR_CHECK(is_subset( + list(c(0)), list(c(0), c(1)) + )); + + BOOST_HANA_CONSTEXPR_CHECK(not_(is_subset( + list(c(0)), list(c(1)) + ))); + + // infix application + BOOST_HANA_CONSTANT_CHECK( + list(x<0>{}) ^is_subset^ list(x<1>{}, x<0>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + list(x<0>{}, x<1>{}) ^is_subset^ list(x<1>{}, x<0>{}) + ); + } + + ////////////////////////////////////////////////////////////////// + // is_disjoint + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(is_disjoint( + list(), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(is_disjoint( + list(), + list(undefined{}) + )); + BOOST_HANA_CONSTANT_CHECK(is_disjoint( + list(undefined{}), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(is_disjoint( + list(x<0>{}), + list(x<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(is_disjoint( + list(x<1>{}), + list(x<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(not_(is_disjoint( + list(x<0>{}), + list(x<0>{}) + ))); + + + BOOST_HANA_CONSTANT_CHECK(not_(is_disjoint( + list(x<0>{}, x<1>{}), + list(x<0>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(not_(is_disjoint( + list(x<0>{}), + list(x<0>{}, x<1>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(not_(is_disjoint( + list(x<1>{}, x<0>{}), + list(x<0>{}, x<1>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(not_(is_disjoint( + list(x<0>{}, x<1>{}), + list(x<1>{}, x<2>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(is_disjoint( + list(x<0>{}, x<1>{}), + list(x<2>{}, x<3>{}) + )); + } + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_SEARCHABLE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/sequence.hpp b/src/boost/libs/hana/test/_include/laws/sequence.hpp new file mode 100644 index 000000000..cc04590ea --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/sequence.hpp @@ -0,0 +1,133 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_LAWS_SEQUENCE_HPP +#define BOOST_HANA_TEST_LAWS_SEQUENCE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + + +namespace boost { namespace hana { namespace test { + template > + struct TestSequence : TestSequence { + using TestSequence::TestSequence; + }; + + template + struct TestSequence { + template + using eq = integer; + + template + using cx_eq = integer; + + template + using ord = integer; + + struct undefined { }; + + TestSequence() { + constexpr auto list = make; (void)list; + constexpr auto foldable = ::seq; (void)foldable; + + ////////////////////////////////////////////////////////////////// + // Check for Sequence<...> + ////////////////////////////////////////////////////////////////// + static_assert(Sequence{}, ""); + static_assert(Sequence{}, ""); + static_assert(Sequence{}, ""); + static_assert(Sequence{}, ""); + + ////////////////////////////////////////////////////////////////// + // Check for basic tag consistency + ////////////////////////////////////////////////////////////////// + struct Random; + static_assert(std::is_same, S>{}, ""); + static_assert(std::is_same, S>{}, ""); + static_assert(std::is_same, S>{}, ""); + static_assert(std::is_same, S>{}, ""); + static_assert(!std::is_same, S>{}, ""); + + ////////////////////////////////////////////////////////////////// + // Foldable -> Sequence conversion + ////////////////////////////////////////////////////////////////// + { + BOOST_HANA_CONSTANT_CHECK(equal( + to(foldable()), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + to(foldable(eq<0>{})), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + to(foldable(eq<0>{}, eq<1>{})), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + to(foldable(eq<0>{}, eq<1>{}, eq<2>{})), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + to(foldable(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{})), + list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}) + )); + } + + ////////////////////////////////////////////////////////////////// + // make (tautological given our definition of `list`) + ////////////////////////////////////////////////////////////////// + BOOST_HANA_CONSTANT_CHECK(equal( + make(), + list() + )); + BOOST_HANA_CONSTANT_CHECK(equal( + make(eq<0>{}), + list(eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + make(eq<0>{}, eq<1>{}), + list(eq<0>{}, eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + make(eq<0>{}, eq<1>{}, eq<2>{}), + list(eq<0>{}, eq<1>{}, eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(equal( + make(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}), + list(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}) + )); + } + }; +}}} // end namespace boost::hana::test + +#endif // !BOOST_HANA_TEST_LAWS_SEQUENCE_HPP diff --git a/src/boost/libs/hana/test/_include/laws/templates/seq.hpp b/src/boost/libs/hana/test/_include/laws/templates/seq.hpp new file mode 100644 index 000000000..72438fc50 --- /dev/null +++ b/src/boost/libs/hana/test/_include/laws/templates/seq.hpp @@ -0,0 +1,132 @@ +// 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; +using hana::test::ct_ord; + + +int main() { + auto eqs = hana::make_tuple( + ::seq() + , ::seq(ct_eq<0>{}) + , ::seq(ct_eq<0>{}, ct_eq<1>{}) + , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + ); + (void)eqs; + + auto nested_eqs = hana::make_tuple( + ::seq() + , ::seq( + ::seq(ct_eq<0>{})) + , ::seq( + ::seq(ct_eq<0>{}), + ::seq(ct_eq<1>{}, ct_eq<2>{})) + , ::seq( + ::seq(ct_eq<0>{}), + ::seq(ct_eq<1>{}, ct_eq<2>{}), + ::seq(ct_eq<3>{}, ct_eq<4>{})) + ); + (void)nested_eqs; + + auto eq_keys = hana::make_tuple(ct_eq<0>{}, ct_eq<3>{}, ct_eq<10>{}); + (void)eq_keys; + + auto predicates = hana::make_tuple( + hana::equal.to(ct_eq<0>{}), hana::equal.to(ct_eq<3>{}), hana::equal.to(ct_eq<10>{}), + hana::always(hana::true_c), hana::always(hana::false_c) + ); + (void)predicates; + + auto ords = hana::make_tuple( + ::seq() + , ::seq(ct_ord<0>{}) + , ::seq(ct_ord<0>{}, ct_ord<1>{}) + , ::seq(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) + , ::seq(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}) + ); + (void)ords; + + ////////////////////////////////////////////////////////////////////////// + // Comparable, Orderable + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_ORDERABLE + hana::test::TestComparable<::Seq>{eqs}; + hana::test::TestOrderable<::Seq>{ords}; +#endif + +#ifdef BOOST_HANA_TEST_ITERABLE + ////////////////////////////////////////////////////////////////////////// + // Foldable + ////////////////////////////////////////////////////////////////////////// + hana::test::TestFoldable<::Seq>{eqs}; + + ////////////////////////////////////////////////////////////////////////// + // Iterable + ////////////////////////////////////////////////////////////////////////// + { + hana::test::TestIterable<::Seq>{eqs}; + } +#endif + + ////////////////////////////////////////////////////////////////////////// + // Searchable + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_SEARCHABLE + { + hana::test::TestSearchable<::Seq>{eqs, eq_keys}; + + auto bools = hana::make_tuple( + ::seq(hana::true_c) + , ::seq(hana::false_c) + , ::seq(hana::true_c, hana::true_c) + , ::seq(hana::true_c, hana::false_c) + , ::seq(hana::false_c, hana::true_c) + , ::seq(hana::false_c, hana::false_c) + ); + hana::test::TestSearchable<::Seq>{bools, hana::make_tuple(hana::true_c, hana::false_c)}; + } +#endif + + ////////////////////////////////////////////////////////////////////////// + // Functor, Applicative, Monad + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_MONAD + hana::test::TestFunctor<::Seq>{eqs, eq_keys}; + hana::test::TestApplicative<::Seq>{eqs}; + hana::test::TestMonad<::Seq>{eqs, nested_eqs}; +#endif + + ////////////////////////////////////////////////////////////////////////// + // MonadPlus + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_MONAD_PLUS + hana::test::TestMonadPlus<::Seq>{eqs, predicates, eq_keys}; +#endif + + ////////////////////////////////////////////////////////////////////////// + // Sequence + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_SEQUENCE + hana::test::TestSequence<::Seq>{}; +#endif +} diff --git a/src/boost/libs/hana/test/_include/support/cnumeric.hpp b/src/boost/libs/hana/test/_include/support/cnumeric.hpp new file mode 100644 index 000000000..51575a40f --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/cnumeric.hpp @@ -0,0 +1,66 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef TEST_SUPPORT_CNUMERIC_HPP +#define TEST_SUPPORT_CNUMERIC_HPP + +#include +#include +#include +#include +#include + + +template +struct CNumeric { using value_type = T; }; + +template +struct cnumeric_t { + static constexpr T value = v; + using hana_tag = CNumeric; + constexpr operator T() const { return value; } +}; + +template +constexpr cnumeric_t cnumeric{}; + +template +constexpr cnumeric_t make_cnumeric() { return {}; } + +namespace boost { namespace hana { + // Constant and IntegralConstant + template + struct IntegralConstant> { + static constexpr bool value = true; + }; + + template + struct to_impl, C, when< + hana::IntegralConstant::value + >> + : embedding::value> + { + template + static constexpr auto apply(N const&) + { return cnumeric; } + }; + + // Comparable + template + struct equal_impl, CNumeric> { + template + static constexpr auto apply(X const&, Y const&) + { return cnumeric; } + }; + + // Orderable + template + struct less_impl, CNumeric> { + template + static constexpr auto apply(X const&, Y const&) + { return cnumeric; } + }; +}} // end namespace boost::hana + +#endif // !TEST_SUPPORT_CNUMERIC_HPP diff --git a/src/boost/libs/hana/test/_include/support/constexpr_move_only.hpp b/src/boost/libs/hana/test/_include/support/constexpr_move_only.hpp new file mode 100644 index 000000000..bdc234afe --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/constexpr_move_only.hpp @@ -0,0 +1,41 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef TEST_SUPPORT_CONSTEXPR_MOVE_ONLY_HPP +#define TEST_SUPPORT_CONSTEXPR_MOVE_ONLY_HPP + +#include +#include +#include + +#include + + +// A move-only type that's also a literal type. It is also Comparable and +// Hashable so it can be used in associative containers. +template +struct ConstexprMoveOnly { + constexpr ConstexprMoveOnly() { } + constexpr ConstexprMoveOnly(ConstexprMoveOnly const&) = delete; + constexpr ConstexprMoveOnly& operator=(ConstexprMoveOnly const&) = delete; + constexpr ConstexprMoveOnly(ConstexprMoveOnly&&) { } +}; + +template +constexpr auto operator==(ConstexprMoveOnly const&, ConstexprMoveOnly const&) +{ return boost::hana::bool_c; } + +template +constexpr auto operator!=(ConstexprMoveOnly const&, ConstexprMoveOnly const&) +{ return boost::hana::bool_c; } + +namespace boost { namespace hana { + template + struct hash_impl> { + static constexpr auto apply(ConstexprMoveOnly const&) + { return hana::type_c>; }; + }; +}} + +#endif // !TEST_SUPPORT_CONSTEXPR_MOVE_ONLY_HPP diff --git a/src/boost/libs/hana/test/_include/support/counter.hpp b/src/boost/libs/hana/test/_include/support/counter.hpp new file mode 100644 index 000000000..4640363d7 --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/counter.hpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef TEST_SUPPORT_COUNTER_HPP +#define TEST_SUPPORT_COUNTER_HPP + +#include +#include +#include +#include +#include + + +// Counter - an infinite iterable for the masses + +struct Counter_tag { }; + +template +struct Counter { + using hana_tag = Counter_tag; + static constexpr std::size_t value = N; +}; + + +namespace boost { namespace hana { + ////////////////////////////////////////////////////////////////////////// + // Iterable + ////////////////////////////////////////////////////////////////////////// + template <> + struct at_impl { + template + static constexpr decltype(auto) apply(T, N) { + return hana::size_c; + } + }; + + template <> + struct drop_front_impl { + template + static constexpr auto apply(T, N) { + return Counter{}; + } + }; + + template <> + struct is_empty_impl { + template + static constexpr auto apply(Xs) + -> hana::false_ + { return {}; } + }; +}} // end namespace boost::hana + +#endif // !TEST_SUPPORT_COUNTER_HPP diff --git a/src/boost/libs/hana/test/_include/support/equivalence_class.hpp b/src/boost/libs/hana/test/_include/support/equivalence_class.hpp new file mode 100644 index 000000000..c5e8d72e6 --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/equivalence_class.hpp @@ -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) + +#ifndef TEST_SUPPORT_EQUIVALENCE_CLASS_HPP +#define TEST_SUPPORT_EQUIVALENCE_CLASS_HPP + +#include + + +struct EquivalenceClass { }; + +template +struct equivalence_class_impl { + Token equivalence_class; + T unwrap; + using hana_tag = EquivalenceClass; +}; + +template +constexpr equivalence_class_impl equivalence_class(Token token, X x) { + return {token, x}; +} + +namespace boost { namespace hana { + template <> + struct equal_impl { + template + static constexpr auto apply(X x, Y y) + { return hana::equal(x.equivalence_class, y.equivalence_class); } + }; +}} // end namespace boost::hana + +#endif // !TEST_SUPPORT_EQUIVALENCE_CLASS_HPP diff --git a/src/boost/libs/hana/test/_include/support/identity.hpp b/src/boost/libs/hana/test/_include/support/identity.hpp new file mode 100644 index 000000000..c6799cbe8 --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/identity.hpp @@ -0,0 +1,159 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef TEST_SUPPORT_IDENTITY_HPP +#define TEST_SUPPORT_IDENTITY_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +struct Identity; + +template +struct identity_t { + T value; + using hana_tag = Identity; +}; + +struct make_identity { + template + constexpr identity_t::type> operator()(T&& t) const { + return {static_cast(t)}; + } +}; + +constexpr make_identity identity{}; + + +namespace boost { namespace hana { + ////////////////////////////////////////////////////////////////////////// + // Comparable + ////////////////////////////////////////////////////////////////////////// + template <> + struct equal_impl { + template + static constexpr auto apply(Id1 x, Id2 y) + { return hana::equal(x.value, y.value); } + }; + + ////////////////////////////////////////////////////////////////////////// + // Orderable + ////////////////////////////////////////////////////////////////////////// + template <> + struct less_impl { + template + static constexpr auto apply(Id1 x, Id2 y) + { return hana::less(x.value, y.value); } + }; + + ////////////////////////////////////////////////////////////////////////// + // Functor + // + // Define either one to select which MCD is used: + // BOOST_HANA_TEST_FUNCTOR_TRANSFORM_MCD + // BOOST_HANA_TEST_FUNCTOR_ADJUST_MCD_MCD + // + // If neither is defined, the MCD used is unspecified. + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_FUNCTOR_TRANSFORM_MCD + template <> + struct transform_impl { + template + static constexpr auto apply(Id self, F f) + { return ::identity(f(self.value)); } + }; +#else + template <> + struct adjust_if_impl { + struct get_value { + template + constexpr auto operator()(T t) const { return t.value; } + }; + + template + static constexpr auto apply(Id self, P p, F f) { + auto x = hana::eval_if(p(self.value), + hana::make_lazy(hana::compose(f, get_value{}))(self), + hana::make_lazy(get_value{})(self) + ); + return ::identity(x); + } + }; +#endif + + ////////////////////////////////////////////////////////////////////////// + // Applicative + // + // Define either one to select which MCD is used: + // BOOST_HANA_TEST_APPLICATIVE_FULL_MCD + // BOOST_HANA_TEST_APPLICATIVE_MONAD_MCD + // + // If neither is defined, the MCD used is unspecified. + ////////////////////////////////////////////////////////////////////////// + template <> + struct lift_impl { + template + static constexpr auto apply(X x) + { return ::identity(x); } + }; +#ifdef BOOST_HANA_TEST_APPLICATIVE_FULL_MCD + template <> + struct ap_impl { + template + static constexpr auto apply(F f, X x) + { return ::identity(f.value(x.value)); } + }; +#else + template <> + struct ap_impl { + template + static constexpr decltype(auto) apply(F&& f, X&& x) { + return hana::chain( + static_cast(f), + hana::partial(hana::transform, static_cast(x)) + ); + } + }; +#endif + + ////////////////////////////////////////////////////////////////////////// + // Monad + // + // Define either one to select which MCD is used: + // BOOST_HANA_TEST_MONAD_FLATTEN_MCD + // BOOST_HANA_TEST_MONAD_CHAIN_MCD + // + // If neither is defined, the MCD used is unspecified. + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_MONAD_FLATTEN_MCD + template <> + struct flatten_impl { + template + static constexpr auto apply(Id self) + { return self.value; } + }; +#else + template <> + struct chain_impl { + template + static constexpr auto apply(X x, F f) + { return f(x.value); } + }; +#endif +}} // end namespace boost::hana + +#endif // !TEST_SUPPORT_IDENTITY_HPP diff --git a/src/boost/libs/hana/test/_include/support/minimal_product.hpp b/src/boost/libs/hana/test/_include/support/minimal_product.hpp new file mode 100644 index 000000000..1fe39f786 --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/minimal_product.hpp @@ -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) + +#ifndef TEST_SUPPORT_MINIMAL_PRODUCT_HPP +#define TEST_SUPPORT_MINIMAL_PRODUCT_HPP + +#include +#include +#include + +#include + + +struct MinimalProduct; + +template +struct product_t { + X fst; + Y snd; + using hana_tag = MinimalProduct; +}; + +struct make_minimal_product { + template + constexpr product_t::type, + typename std::decay::type> + operator()(T&& t, U&& u) const { + return {static_cast(t), static_cast(u)}; + } +}; + +constexpr make_minimal_product minimal_product{}; + +namespace boost { namespace hana { + ////////////////////////////////////////////////////////////////////////// + // Product + ////////////////////////////////////////////////////////////////////////// + template <> + struct make_impl { + template + static constexpr auto apply(X x, Y y) + { return ::minimal_product(x, y); } + }; + + template <> + struct first_impl { + template + static constexpr decltype(auto) apply(P&& p) + { return p.fst; } + }; + + template <> + struct second_impl { + template + static constexpr decltype(auto) apply(P&& p) + { return p.snd; } + }; +}} // end namespace boost::hana + +#endif // !TEST_SUPPORT_MINIMAL_PRODUCT_HPP diff --git a/src/boost/libs/hana/test/_include/support/numeric.hpp b/src/boost/libs/hana/test/_include/support/numeric.hpp new file mode 100644 index 000000000..2aebe7664 --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/numeric.hpp @@ -0,0 +1,175 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef TEST_SUPPORT_NUMERIC_HPP +#define TEST_SUPPORT_NUMERIC_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +struct numeric_type { + constexpr explicit numeric_type(int v) : value(v) { } + int value; + constexpr operator int() const { return value; } +}; + +using Numeric = boost::hana::tag_of_t; + +struct numeric_t { + constexpr numeric_type operator()(int x) const { + return numeric_type{x}; + } +}; +constexpr numeric_t numeric{}; + + +namespace boost { namespace hana { + ////////////////////////////////////////////////////////////////////////// + // Comparable + ////////////////////////////////////////////////////////////////////////// + template <> + struct equal_impl { + template + static constexpr auto apply(X x, Y y) + { return numeric(x.value == y.value); } + }; + + ////////////////////////////////////////////////////////////////////////// + // Orderable + ////////////////////////////////////////////////////////////////////////// + template <> + struct less_impl { + template + static constexpr auto apply(X x, Y y) { + // Workaround a _weird_ GCC bug: + // error: parse error in template argument list + // bool cmp = (x.value < y.value); + // ^ + int xv = x.value, yv = y.value; + return numeric(xv < yv); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Logical + ////////////////////////////////////////////////////////////////////////// + template <> + struct eval_if_impl { + template + static constexpr auto apply(C const& c, T&& t, E&& e) { + return c.value ? hana::eval(static_cast(t)) + : hana::eval(static_cast(e)); + } + }; + + template <> + struct not_impl { + template + static constexpr auto apply(X x) + { return numeric(!x.value); } + }; + + template <> + struct while_impl { + template + static constexpr auto apply(Pred pred, State state, F f) + -> decltype(true ? f(state) : state) + { + if (pred(state)) + return hana::while_(pred, f(state), f); + else + return state; + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Monoid + ////////////////////////////////////////////////////////////////////////// + template <> + struct plus_impl { + template + static constexpr auto apply(X x, Y y) + { return numeric(x.value + y.value); } + }; + + template <> + struct zero_impl { + static constexpr auto apply() + { return numeric(0); } + }; + + ////////////////////////////////////////////////////////////////////////// + // Group + // + // Define either one to select which MCD is used: + // BOOST_HANA_TEST_GROUP_NEGATE_MCD + // BOOST_HANA_TEST_GROUP_MINUS_MCD + // + // If neither is defined, the MCD used is unspecified. + ////////////////////////////////////////////////////////////////////////// +#if defined(BOOST_HANA_TEST_GROUP_NEGATE_MCD) + template <> + struct negate_impl { + template + static constexpr auto apply(X x) + { return numeric(-x.value); } + }; +#else + template <> + struct minus_impl { + template + static constexpr auto apply(X x, Y y) + { return numeric(x.value - y.value); } + }; +#endif + + ////////////////////////////////////////////////////////////////////////// + // Ring + ////////////////////////////////////////////////////////////////////////// + template <> + struct mult_impl { + template + static constexpr auto apply(X x, Y y) + { return numeric(x.value * y.value); } + }; + + template <> + struct one_impl { + static constexpr auto apply() + { return numeric(1); } + }; + + ////////////////////////////////////////////////////////////////////////// + // EuclideanRing + ////////////////////////////////////////////////////////////////////////// + template <> + struct div_impl { + template + static constexpr auto apply(X x, Y y) + { return numeric(x.value / y.value); } + }; + + template <> + struct mod_impl { + template + static constexpr auto apply(X x, Y y) + { return numeric(x.value % y.value); } + }; +}} // end namespace boost::hana + +#endif //! TEST_SUPPORT_NUMERIC_HPP diff --git a/src/boost/libs/hana/test/_include/support/seq.hpp b/src/boost/libs/hana/test/_include/support/seq.hpp new file mode 100644 index 000000000..ee222dc01 --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/seq.hpp @@ -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) + +#ifndef TEST_SUPPORT_SEQ_HPP +#define TEST_SUPPORT_SEQ_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +struct Seq; + +template +struct seq_type { + explicit constexpr seq_type(Storage s) : storage(s) { } + Storage storage; + using hana_tag = Seq; +}; + +struct seq_t { + template + constexpr auto operator()(Xs&& ...xs) const { + auto storage = boost::hana::make_tuple(xs...); + return seq_type(storage); + } +}; +constexpr seq_t seq{}; + +namespace boost { namespace hana { + ////////////////////////////////////////////////////////////////////////// + // Foldable + // + // Define either one to select which MCD is used: + // BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD + // BOOST_HANA_TEST_FOLDABLE_UNPACK_MCD + // BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD + // + // If neither is defined, the MCD used is unspecified. + ////////////////////////////////////////////////////////////////////////// +#ifdef BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD + template <> + struct fold_left_impl { + template + static constexpr auto apply(Xs xs, S s, F f) { + return hana::fold_left(xs.storage, s, f); + } + + template + static constexpr auto apply(Xs xs, F f) { + return hana::fold_left(xs.storage, f); + } + }; +#elif defined(BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD) + template <> + struct length_impl { + template + static constexpr auto apply(Xs const& xs) { + return hana::length(xs.storage); + } + }; +#else + template <> + struct unpack_impl { + template + static constexpr auto apply(Xs xs, F f) + { return hana::unpack(xs.storage, f); } + }; +#endif + + ////////////////////////////////////////////////////////////////////////// + // Iterable + ////////////////////////////////////////////////////////////////////////// + template <> + struct at_impl { + template + static constexpr decltype(auto) apply(Xs&& xs, N&& n) { + return hana::at(static_cast(xs).storage, n); + } + }; + + template <> + struct drop_front_impl { + template + static constexpr auto apply(Xs xs, N n) { + return hana::unpack(hana::drop_front(xs.storage, n), ::seq); + } + }; + + template <> + struct is_empty_impl { + template + static constexpr auto apply(Xs xs) { + return hana::is_empty(xs.storage); + } + }; + + ////////////////////////////////////////////////////////////////////////// + // Sequence + ////////////////////////////////////////////////////////////////////////// + template <> + struct Sequence { + static constexpr bool value = true; + }; + + template <> + struct make_impl { + template + static constexpr auto apply(Xs&& ...xs) { + return ::seq(static_cast(xs)...); + } + }; +}} // end namespace boost::hana + +#endif // !TEST_SUPPORT_SEQ_HPP diff --git a/src/boost/libs/hana/test/_include/support/tracked.hpp b/src/boost/libs/hana/test/_include/support/tracked.hpp new file mode 100644 index 000000000..215ffba4d --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/tracked.hpp @@ -0,0 +1,120 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef TEST_SUPPORT_TRACKED_HPP +#define TEST_SUPPORT_TRACKED_HPP + +// Define this if you want Tracked objects to print information to stderr. +// #define TRACKED_PRINT_STUFF + +#include + +#ifdef TRACKED_PRINT_STUFF +# include +#endif + +#include + + +struct Tracked { + enum class State { CONSTRUCTED, MOVED_FROM, DESTROYED }; + + int value; + State state; + + explicit Tracked(int k) : value{k}, state{State::CONSTRUCTED} { +#ifdef TRACKED_PRINT_STUFF + std::cerr << "constructing " << *this << '\n'; +#endif + } + + Tracked(Tracked const& t) : value{t.value}, state{State::CONSTRUCTED} { + BOOST_HANA_RUNTIME_CHECK(t.state != State::MOVED_FROM && + "copying a moved-from object"); + + BOOST_HANA_RUNTIME_CHECK(t.state != State::DESTROYED && + "copying a destroyed object"); + +#ifdef TRACKED_PRINT_STUFF + std::cerr << "copying " << *this << '\n'; +#endif + } + + Tracked(Tracked&& t) : value{t.value}, state{State::CONSTRUCTED} { + BOOST_HANA_RUNTIME_CHECK(t.state != State::MOVED_FROM && + "double moving from an object"); + + BOOST_HANA_RUNTIME_CHECK(t.state != State::DESTROYED && + "moving from a destroyed object"); + +#ifdef TRACKED_PRINT_STUFF + std::cerr << "moving " << t << '\n'; +#endif + t.state = State::MOVED_FROM; + } + + Tracked& operator=(Tracked const& other) { + BOOST_HANA_RUNTIME_CHECK(this->state != State::DESTROYED && + "assigning to a destroyed object"); + + BOOST_HANA_RUNTIME_CHECK(other.state != State::MOVED_FROM && + "assigning a moved-from object"); + + BOOST_HANA_RUNTIME_CHECK(other.state != State::DESTROYED && + "assigning a destroyed object"); + +#ifdef TRACKED_PRINT_STUFF + std::cerr << "assigning " << other << " to " << *this << '\n'; +#endif + this->value = other.value; + return *this; + } + + Tracked& operator=(Tracked&& other) { + BOOST_HANA_RUNTIME_CHECK(this->state != State::DESTROYED && + "assigning to a destroyed object"); + + BOOST_HANA_RUNTIME_CHECK(other.state != State::MOVED_FROM && + "double-moving from an object"); + + BOOST_HANA_RUNTIME_CHECK(other.state != State::DESTROYED && + "assigning a destroyed object"); + +#ifdef TRACKED_PRINT_STUFF + std::cerr << "assigning " << other << " to " << *this << '\n'; +#endif + this->value = other.value; + other.state = State::MOVED_FROM; + return *this; + } + + ~Tracked() { + BOOST_HANA_RUNTIME_CHECK(state != State::DESTROYED && + "double-destroying an object"); + +#ifdef TRACKED_PRINT_STUFF + std::cerr << "destructing " << *this << '\n'; +#endif + state = State::DESTROYED; + } + + template + friend std::basic_ostream& + operator<<(std::basic_ostream& os, Tracked const& t) { + os << "Tracked{" << t.value << "}"; + switch (t.state) { + case State::CONSTRUCTED: + os << "[ok]"; break; + case State::MOVED_FROM: + os << "[moved from]"; break; + case State::DESTROYED: + os << "[destroyed]"; break; + default: + BOOST_HANA_RUNTIME_CHECK(false && "never reached"); + } + return os; + } +}; + +#endif // !TEST_SUPPORT_TRACKED_HPP diff --git a/src/boost/libs/hana/test/_include/support/tracked_move_only.hpp b/src/boost/libs/hana/test/_include/support/tracked_move_only.hpp new file mode 100644 index 000000000..03e9d5da6 --- /dev/null +++ b/src/boost/libs/hana/test/_include/support/tracked_move_only.hpp @@ -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) + +#ifndef TEST_SUPPORT_TRACKED_MOVE_ONLY_HPP +#define TEST_SUPPORT_TRACKED_MOVE_ONLY_HPP + +#include +#include +#include + +#include + +#include + + +// A move-only type that's Tracked. It is also Comparable and Hashable so it +// can be used in associative containers. +template +struct TrackedMoveOnly : Tracked { + TrackedMoveOnly() : Tracked(i) { } + TrackedMoveOnly(TrackedMoveOnly const&) = delete; + TrackedMoveOnly& operator=(TrackedMoveOnly const&) = delete; + TrackedMoveOnly(TrackedMoveOnly&& x) + : Tracked(std::move(x)) + { } +}; + +template +constexpr auto operator==(TrackedMoveOnly const&, TrackedMoveOnly const&) +{ return boost::hana::bool_c; } + +template +constexpr auto operator!=(TrackedMoveOnly const&, TrackedMoveOnly const&) +{ return boost::hana::bool_c; } + +namespace boost { namespace hana { + template + struct hash_impl> { + static constexpr auto apply(TrackedMoveOnly const&) + { return hana::type_c>; }; + }; +}} + +#endif // !TEST_SUPPORT_TRACKED_MOVE_ONLY_HPP diff --git a/src/boost/libs/hana/test/assert/commas.cpp b/src/boost/libs/hana/test/assert/commas.cpp new file mode 100644 index 000000000..0027c4801 --- /dev/null +++ b/src/boost/libs/hana/test/assert/commas.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 + +#include +namespace hana = boost::hana; + + +// This test makes sure that we can use conditions with multiple comma-separated +// arguments to the non-MSG versions of the BOOST_HANA_XXX_ASSERT macros. + +template +bool runtime_bool() { return value; } + +template +auto constant_bool() { return make_cnumeric(); } + +int main() { + BOOST_HANA_CONSTANT_ASSERT(constant_bool()); + BOOST_HANA_CONSTANT_ASSERT(constant_bool()); + BOOST_HANA_CONSTANT_ASSERT(constant_bool()); + + BOOST_HANA_RUNTIME_ASSERT(runtime_bool()); + BOOST_HANA_RUNTIME_ASSERT(runtime_bool()); + BOOST_HANA_RUNTIME_ASSERT(runtime_bool()); + + BOOST_HANA_ASSERT(runtime_bool()); + BOOST_HANA_ASSERT(runtime_bool()); + BOOST_HANA_ASSERT(runtime_bool()); + BOOST_HANA_ASSERT(constant_bool()); + BOOST_HANA_ASSERT(constant_bool()); + BOOST_HANA_ASSERT(constant_bool()); +} diff --git a/src/boost/libs/hana/test/assert/constant.cpp b/src/boost/libs/hana/test/assert/constant.cpp new file mode 100644 index 000000000..3eca58c18 --- /dev/null +++ b/src/boost/libs/hana/test/assert/constant.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 + +#include +namespace hana = boost::hana; + + +template +auto constant_bool() { return make_cnumeric(); } + +template +constexpr auto constexpr_constant_bool() { return make_cnumeric(); } + + +// Make sure it works at global scope +BOOST_HANA_CONSTANT_ASSERT(constant_bool()); +BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool(), "message"); + +// Make sure it works at namespace scope +namespace ns { + BOOST_HANA_CONSTANT_ASSERT(constant_bool()); + BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool(), "message"); +} + +// Make sure it works in a constexpr context +constexpr bool constexpr_context() { + BOOST_HANA_CONSTANT_ASSERT(constexpr_constant_bool()); + BOOST_HANA_CONSTANT_ASSERT_MSG(constexpr_constant_bool(), "message"); + return true; +} +static_assert(constexpr_context(), ""); + + +int main() { + // Make sure it works at function scope + BOOST_HANA_CONSTANT_ASSERT(constant_bool()); + BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool(), "message"); + + // Make sure it works inside a lambda + auto lambda = []{ + BOOST_HANA_CONSTANT_ASSERT(constant_bool()); + BOOST_HANA_CONSTANT_ASSERT_MSG(constant_bool(), "message"); + }; + lambda(); + + // Make sure we can reference a local variable + auto yes = constant_bool(); + BOOST_HANA_CONSTANT_ASSERT(yes); + BOOST_HANA_CONSTANT_ASSERT_MSG(yes, "message"); +} diff --git a/src/boost/libs/hana/test/assert/constexpr.cpp b/src/boost/libs/hana/test/assert/constexpr.cpp new file mode 100644 index 000000000..dd26c34cd --- /dev/null +++ b/src/boost/libs/hana/test/assert/constexpr.cpp @@ -0,0 +1,30 @@ +// 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 +namespace hana = boost::hana; + + +template +bool runtime_bool() { return value; } + +template +constexpr bool constexpr_bool() { return value; } + + +int main() { + // Make sure it works at function scope + BOOST_HANA_CONSTEXPR_ASSERT(runtime_bool()); + BOOST_HANA_CONSTEXPR_ASSERT(constexpr_bool()); + BOOST_HANA_CONSTEXPR_ASSERT_MSG(runtime_bool(), "message"); + BOOST_HANA_CONSTEXPR_ASSERT_MSG(constexpr_bool(), "message"); + + // Make sure we can reference a local variable + auto rt_yes = runtime_bool(); + constexpr auto cx_yes = constexpr_bool(); + BOOST_HANA_CONSTEXPR_ASSERT(rt_yes); + BOOST_HANA_CONSTEXPR_ASSERT(cx_yes); + BOOST_HANA_CONSTEXPR_ASSERT_MSG(rt_yes, "message"); + BOOST_HANA_CONSTEXPR_ASSERT_MSG(cx_yes, "message"); +} diff --git a/src/boost/libs/hana/test/assert/flexible.cpp b/src/boost/libs/hana/test/assert/flexible.cpp new file mode 100644 index 000000000..207eb4d8b --- /dev/null +++ b/src/boost/libs/hana/test/assert/flexible.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 + +#include +namespace hana = boost::hana; + + +template +bool runtime_bool() { return value; } + +template +auto constant_bool() { return make_cnumeric(); } + + +int main() { + // Make sure it works at function scope + BOOST_HANA_ASSERT(runtime_bool()); + BOOST_HANA_ASSERT(constant_bool()); + + BOOST_HANA_ASSERT_MSG(runtime_bool(), "message"); + BOOST_HANA_ASSERT_MSG(constant_bool(), "message"); + + // Make sure we can reference a local variable + auto ct_yes = constant_bool(); + BOOST_HANA_ASSERT(ct_yes); + BOOST_HANA_ASSERT_MSG(ct_yes, "message"); + + auto rt_yes = runtime_bool(); + BOOST_HANA_ASSERT(rt_yes); + BOOST_HANA_ASSERT_MSG(rt_yes, "message"); +} diff --git a/src/boost/libs/hana/test/assert/lambdas.cpp b/src/boost/libs/hana/test/assert/lambdas.cpp new file mode 100644 index 000000000..900dbd4e5 --- /dev/null +++ b/src/boost/libs/hana/test/assert/lambdas.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 + +#include +namespace hana = boost::hana; + + +// This test makes sure that we can use lambdas inside the various +// BOOST_HANA_XXX_ASSERT macros. + +template +bool runtime_bool() { return value; } + +template +auto constant_bool() { return make_cnumeric(); } + +int main() { + BOOST_HANA_CONSTANT_ASSERT([]{ return constant_bool(); }()); + BOOST_HANA_RUNTIME_ASSERT([]{ return runtime_bool(); }()); + BOOST_HANA_ASSERT([] { return constant_bool(); }()); + BOOST_HANA_ASSERT([] { return runtime_bool(); }()); +} diff --git a/src/boost/libs/hana/test/assert/runtime.cpp b/src/boost/libs/hana/test/assert/runtime.cpp new file mode 100644 index 000000000..7db4e4bef --- /dev/null +++ b/src/boost/libs/hana/test/assert/runtime.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 +namespace hana = boost::hana; + + +template +bool runtime_bool() { return value; } + + +int main() { + // Make sure it works at function scope + BOOST_HANA_RUNTIME_ASSERT(runtime_bool()); + BOOST_HANA_RUNTIME_ASSERT_MSG(runtime_bool(), "message"); + + // Make sure we can reference a local variable + auto yes = runtime_bool(); + BOOST_HANA_RUNTIME_ASSERT(yes); + BOOST_HANA_RUNTIME_ASSERT_MSG(yes, "message"); +} diff --git a/src/boost/libs/hana/test/basic_tuple/auto/_specs.hpp b/src/boost/libs/hana/test/basic_tuple/auto/_specs.hpp new file mode 100644 index 000000000..a54b04663 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/_specs.hpp @@ -0,0 +1,15 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_BASIC_TUPLE_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_BASIC_TUPLE_AUTO_SPECS_HPP + +#include + + +#define MAKE_TUPLE(...) ::boost::hana::make_basic_tuple(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::hana::basic_tuple<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::basic_tuple_tag + +#endif // !BOOST_HANA_TEST_BASIC_TUPLE_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/basic_tuple/auto/all_of.cpp b/src/boost/libs/hana/test/basic_tuple/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/any_of.cpp b/src/boost/libs/hana/test/basic_tuple/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/ap.cpp b/src/boost/libs/hana/test/basic_tuple/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/at.cpp b/src/boost/libs/hana/test/basic_tuple/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/cartesian_product.cpp b/src/boost/libs/hana/test/basic_tuple/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/drop_back.cpp b/src/boost/libs/hana/test/basic_tuple/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/drop_front.cpp b/src/boost/libs/hana/test/basic_tuple/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/drop_while.cpp b/src/boost/libs/hana/test/basic_tuple/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/for_each.cpp b/src/boost/libs/hana/test/basic_tuple/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/group.cpp b/src/boost/libs/hana/test/basic_tuple/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/index_if.cpp b/src/boost/libs/hana/test/basic_tuple/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/insert.cpp b/src/boost/libs/hana/test/basic_tuple/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/insert_range.cpp b/src/boost/libs/hana/test/basic_tuple/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/intersperse.cpp b/src/boost/libs/hana/test/basic_tuple/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/is_empty.cpp b/src/boost/libs/hana/test/basic_tuple/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/length.cpp b/src/boost/libs/hana/test/basic_tuple/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/basic_tuple/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/make.cpp b/src/boost/libs/hana/test/basic_tuple/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/none_of.cpp b/src/boost/libs/hana/test/basic_tuple/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/partition.cpp b/src/boost/libs/hana/test/basic_tuple/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/permutations.cpp b/src/boost/libs/hana/test/basic_tuple/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/permutations.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/remove_at.cpp b/src/boost/libs/hana/test/basic_tuple/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/remove_range.cpp b/src/boost/libs/hana/test/basic_tuple/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/reverse.cpp b/src/boost/libs/hana/test/basic_tuple/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/scans.cpp b/src/boost/libs/hana/test/basic_tuple/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/sequence.cpp b/src/boost/libs/hana/test/basic_tuple/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/slice.cpp b/src/boost/libs/hana/test/basic_tuple/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/sort.cpp b/src/boost/libs/hana/test/basic_tuple/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/span.cpp b/src/boost/libs/hana/test/basic_tuple/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/take_back.cpp b/src/boost/libs/hana/test/basic_tuple/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/take_front.cpp b/src/boost/libs/hana/test/basic_tuple/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/take_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/take_while.cpp b/src/boost/libs/hana/test/basic_tuple/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/transform.cpp b/src/boost/libs/hana/test/basic_tuple/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/unfolds.cpp b/src/boost/libs/hana/test/basic_tuple/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/unique.cpp b/src/boost/libs/hana/test/basic_tuple/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/auto/zips.cpp b/src/boost/libs/hana/test/basic_tuple/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/basic_tuple/cnstr.copy.cpp b/src/boost/libs/hana/test/basic_tuple/cnstr.copy.cpp new file mode 100644 index 000000000..5949156f7 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/cnstr.copy.cpp @@ -0,0 +1,86 @@ +// 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 +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +struct Empty { }; + +int main() { + { + using T = hana::basic_tuple<>; + T t0; + T t_implicit = t0; + T t_explicit(t0); + + (void)t_explicit; + (void)t_implicit; + } + { + using T = hana::basic_tuple; + T t0(2); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + using T = hana::basic_tuple; + T t0(2, 'a'); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + } + { + using T = hana::basic_tuple; + const T t0(2, 'a', "some text"); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "some text"); + } + { + using T = hana::basic_tuple; + constexpr T t0(2); + constexpr T t = t0; + static_assert(hana::at_c<0>(t) == 2, ""); + } + { + using T = hana::basic_tuple; + constexpr T t0{}; + constexpr T t = t0; + constexpr Empty e = hana::at_c<0>(t); (void)e; + } + { + struct T { }; + struct U { }; + + constexpr hana::basic_tuple binary{}; + constexpr hana::basic_tuple copy_implicit = binary; + constexpr hana::basic_tuple copy_explicit(binary); + + (void)copy_implicit; + (void)copy_explicit; + } + + // This used to fail + { + hana::basic_tuple< + hana::test::ct_eq<0>, + hana::test::ct_eq<2>, + hana::test::ct_eq<4> + > tuple{}; + + hana::basic_tuple< + hana::test::ct_eq<0>, + hana::test::ct_eq<2>, + hana::test::ct_eq<4> + > copy(tuple); + } +} diff --git a/src/boost/libs/hana/test/basic_tuple/construct.cpp b/src/boost/libs/hana/test/basic_tuple/construct.cpp new file mode 100644 index 000000000..38b5e0a5b --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/construct.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 +namespace hana = boost::hana; + + +template +struct x { }; + + +int main() { + constexpr hana::basic_tuple<> empty{}; (void)empty; + + constexpr hana::basic_tuple xs{1, 2.3f}; (void)xs; + constexpr auto ys = hana::basic_tuple{1, 2.3f}; + constexpr auto copy = ys; (void)copy; +} diff --git a/src/boost/libs/hana/test/basic_tuple/laws.cpp b/src/boost/libs/hana/test/basic_tuple/laws.cpp new file mode 100644 index 000000000..d6a299be2 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/laws.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 + +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto eq_tuples = hana::make_basic_tuple( + hana::make_basic_tuple() + , hana::make_basic_tuple(ct_eq<0>{}) + , hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}) + , hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + , hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + , hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + ); + + auto eq_values = hana::make_basic_tuple( + ct_eq<0>{}, + ct_eq<2>{}, + ct_eq<4>{} + ); + + hana::test::TestFunctor{eq_tuples, eq_values}; + hana::test::TestFoldable{eq_tuples}; + hana::test::TestIterable{eq_tuples}; +} diff --git a/src/boost/libs/hana/test/basic_tuple/length.cpp b/src/boost/libs/hana/test/basic_tuple/length.cpp new file mode 100644 index 000000000..53d252563 --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/length.cpp @@ -0,0 +1,41 @@ +// 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_basic_tuple()), + hana::size_c<0> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_basic_tuple(ct_eq<0>{})), + hana::size_c<1> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{})), + hana::size_c<2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + hana::size_c<3> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})), + hana::size_c<4> + )); +} diff --git a/src/boost/libs/hana/test/basic_tuple/make.cpp b/src/boost/libs/hana/test/basic_tuple/make.cpp new file mode 100644 index 000000000..92e49543b --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/make.cpp @@ -0,0 +1,18 @@ +// 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 +#include +namespace hana = boost::hana; + + +template +struct x { }; + +int main() { + auto xs1 = hana::make(); (void)xs1; + auto xs2 = hana::make(x<0>{}); (void)xs2; + auto xs3 = hana::make(x<0>{}, x<1>{}); (void)xs3; + auto xs4 = hana::make(x<0>{}, x<1>{}, x<2>{}); (void)xs4; +} diff --git a/src/boost/libs/hana/test/basic_tuple/unpack.cpp b/src/boost/libs/hana/test/basic_tuple/unpack.cpp new file mode 100644 index 000000000..012bb007c --- /dev/null +++ b/src/boost/libs/hana/test/basic_tuple/unpack.cpp @@ -0,0 +1,37 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_basic_tuple(), f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_basic_tuple(ct_eq<0>{}), f), + f(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}), f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_basic_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); +} diff --git a/src/boost/libs/hana/test/builtin_array.cpp b/src/boost/libs/hana/test/builtin_array.cpp new file mode 100644 index 000000000..f3e26957c --- /dev/null +++ b/src/boost/libs/hana/test/builtin_array.cpp @@ -0,0 +1,121 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +using array = T[n]; + +int main() { + // We can't check the laws because builtin arrays can't be passed + // to functions. + + ////////////////////////////////////////////////////////////////////////// + // Foldable + ////////////////////////////////////////////////////////////////////////// + { + int a[] = {1}; + int b[] = {1, 2}; + int c[] = {1, 2, 3}; + int d[] = {1, 2, 3, 4}; + + // unpack + { + hana::test::_injection<0> f{}; + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::unpack(a, f), + f(1) + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::unpack(b, f), + f(1, 2) + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::unpack(c, f), + f(1, 2, 3) + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::unpack(d, f), + f(1, 2, 3, 4) + )); + } + + static_assert(hana::Foldable::value, ""); + } + + ////////////////////////////////////////////////////////////////////////// + // Searchable + ////////////////////////////////////////////////////////////////////////// + { + // any_of + { + static_assert( + hana::not_(hana::any_of(array{0}, hana::equal.to(1))) + , ""); + + static_assert( + hana::any_of(array{0, 1}, hana::equal.to(0)) + , ""); + static_assert( + hana::any_of(array{0, 1}, hana::equal.to(1)) + , ""); + static_assert( + hana::not_(hana::any_of(array{0, 1}, hana::equal.to(2))) + , ""); + + static_assert( + hana::any_of(array{0, 1, 2}, hana::equal.to(0)) + , ""); + static_assert( + hana::any_of(array{0, 1, 2}, hana::equal.to(1)) + , ""); + static_assert( + hana::any_of(array{0, 1, 2}, hana::equal.to(2)) + , ""); + static_assert( + hana::not_(hana::any_of(array{0, 1, 2}, hana::equal.to(3))) + , ""); + } + + // find_if + // Note: Because we need the predicate to return a Constant, this + // is incredibly not powerful. + { + static_assert(hana::equal( + hana::find_if(array{0}, hana::always(hana::true_c)), + hana::just(0) + ), ""); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(array{0}, hana::always(hana::false_c)), + hana::nothing + )); + } + + static_assert(hana::Searchable::value, ""); + } +} diff --git a/src/boost/libs/hana/test/comparable.cpp b/src/boost/libs/hana/test/comparable.cpp new file mode 100644 index 000000000..0c968a35f --- /dev/null +++ b/src/boost/libs/hana/test/comparable.cpp @@ -0,0 +1,70 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +// Minimal EqualityComparable types +struct eq1 { int value; }; +struct eq2 { + int value; + constexpr operator eq1() const { return {value}; } +}; + +template {} || std::is_same{}) && + (std::is_same{} || std::is_same{}) +>> +constexpr bool operator==(T a, U b) +{ return a.value == b.value; } + +template {} || std::is_same{}) && + (std::is_same{} || std::is_same{}) +>> +constexpr bool operator!=(T a, U b) +{ return !(a == b); } + + +int main() { + // equal + { + // Two objects of different data types are unequal by default, + // and no model is provided for two objects of the same data type. + struct Random1 { }; struct Random2 { }; + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(Random1{}, Random2{}))); + static_assert(!hana::Comparable::value, ""); + static_assert(!hana::Comparable::value, ""); + + // Provided model for EqualityComparable types + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(eq1{0}, eq1{0})); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::equal(eq1{0}, eq1{1}))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::equal(eq1{1}, eq1{0}))); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(eq1{0}, eq2{0})); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::equal(eq1{0}, eq2{1}))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::equal(eq1{1}, eq2{0}))); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(eq2{0}, eq1{0})); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::equal(eq2{0}, eq1{1}))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::equal(eq2{1}, eq1{0}))); + } + + // laws + hana::test::TestComparable{hana::make_tuple(0,1,2,3,4,5)}; + hana::test::TestComparable{hana::make_tuple(0u,1u,2u,3u,4u,5u)}; + hana::test::TestComparable{hana::make_tuple(0l,1l,2l,3l,4l,5l)}; + hana::test::TestComparable{hana::make_tuple(0ul,1ul,2ul,3ul,4ul,5ul)}; + hana::test::TestComparable{hana::make_tuple(eq1{0}, eq1{1}, eq1{2}, eq1{3}, eq1{4})}; +} diff --git a/src/boost/libs/hana/test/concept/constant/arithmetic.cpp b/src/boost/libs/hana/test/concept/constant/arithmetic.cpp new file mode 100644 index 000000000..e01403ba3 --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/arithmetic.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 "minimal.hpp" + +#include + +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{} + ); + + hana::test::TestMonoid>{ints}; + hana::test::TestGroup>{ints}; + hana::test::TestRing>{ints}; + hana::test::TestEuclideanRing>{ints}; +} diff --git a/src/boost/libs/hana/test/concept/constant/comparable.cpp b/src/boost/libs/hana/test/concept/constant/comparable.cpp new file mode 100644 index 000000000..697a2389a --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/comparable.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 "minimal.hpp" + +#include + +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{} + ); + + hana::test::TestComparable>{ints}; +} diff --git a/src/boost/libs/hana/test/concept/constant/laws.cpp b/src/boost/libs/hana/test/concept/constant/laws.cpp new file mode 100644 index 000000000..5b132e3f7 --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/laws.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 "minimal.hpp" + +#include + +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{} + ); + + constexpr auto convertible_types = hana::tuple_t; + + hana::test::TestConstant>{ints, convertible_types}; +} diff --git a/src/boost/libs/hana/test/concept/constant/logical.cpp b/src/boost/libs/hana/test/concept/constant/logical.cpp new file mode 100644 index 000000000..980273aa8 --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/logical.cpp @@ -0,0 +1,191 @@ +// 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 "minimal.hpp" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct invalid { }; + +int main() { + constexpr auto bools = hana::make_tuple( + minimal_constant{}, + minimal_constant{} + ); + + hana::test::TestLogical>{bools}; + + + constexpr auto true_ = minimal_constant{}; + constexpr auto false_ = minimal_constant{}; + + // not_ + { + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::not_(true_), false_)); + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::not_(false_), true_)); + } + + // and_ + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(true_), + true_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(false_), + false_ + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(true_, true_), + true_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(true_, false_), + false_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(false_, invalid{}), + false_ + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(true_, true_, true_), + true_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(true_, true_, false_), + false_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(true_, false_, invalid{}), + false_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::and_(false_, invalid{}, invalid{}), + false_ + )); + } + + // or_ + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(true_), + true_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(false_), + false_ + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(false_, false_), + false_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(false_, true_), + true_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(true_, invalid{}), + true_ + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(false_, false_, false_), + false_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(false_, false_, true_), + true_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(false_, true_, invalid{}), + true_ + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::or_(true_, invalid{}, invalid{}), + true_ + )); + } + + // if_ + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::if_(true_, hana::test::ct_eq<3>{}, hana::test::ct_eq<4>{}), + hana::test::ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::if_(false_, hana::test::ct_eq<3>{}, hana::test::ct_eq<4>{}), + hana::test::ct_eq<4>{} + )); + } + + // eval_if + { + auto t = [](auto) { return hana::test::ct_eq<2>{}; }; + auto e = [](auto) { return hana::test::ct_eq<3>{}; }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(true_, t, invalid{}), + hana::test::ct_eq<2>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(false_, invalid{}, e), + hana::test::ct_eq<3>{} + )); + } + + // while_ + { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::while_(hana::not_equal.to(hana::test::ct_eq<0>{}), hana::test::ct_eq<0>{}, invalid{}), + hana::test::ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::while_(hana::not_equal.to(f(hana::test::ct_eq<0>{})), hana::test::ct_eq<0>{}, f), + f(hana::test::ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::while_(hana::not_equal.to(f(f(hana::test::ct_eq<0>{}))), hana::test::ct_eq<0>{}, f), + f(f(hana::test::ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::while_(hana::not_equal.to(f(f(f(hana::test::ct_eq<0>{})))), hana::test::ct_eq<0>{}, f), + f(f(f(hana::test::ct_eq<0>{}))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::while_(hana::not_equal.to(f(f(f(f(hana::test::ct_eq<0>{}))))), hana::test::ct_eq<0>{}, f), + f(f(f(f(hana::test::ct_eq<0>{})))) + )); + + // Make sure it can be called with an lvalue state: + auto state = hana::test::ct_eq<0>{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::while_(hana::not_equal.to(f(f(f(f(hana::test::ct_eq<0>{}))))), state, f), + f(f(f(f(hana::test::ct_eq<0>{})))) + )); + } +} diff --git a/src/boost/libs/hana/test/concept/constant/mcd.cpp b/src/boost/libs/hana/test/concept/constant/mcd.cpp new file mode 100644 index 000000000..f45327cdb --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/mcd.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 "minimal.hpp" + +#include +#include +namespace hana = boost::hana; + + +// Make sure we really satisfy Constant. +static_assert(hana::Constant>::value, ""); +static_assert(hana::Constant>::value, ""); +static_assert(hana::Constant>::value, ""); +static_assert(hana::Constant>::value, ""); + +// Make sure we can use hana::value<> properly. +static_assert(hana::value>() == 0, ""); +static_assert(hana::value>() == 1, ""); +static_assert(hana::value>() == 2, ""); +static_assert(hana::value>() == 3, ""); + +// Check the equivalence between `value(...)` and `value()`. +static_assert(hana::value(minimal_constant{}) == hana::value>(), ""); +static_assert(hana::value(minimal_constant{}) == hana::value>(), ""); +static_assert(hana::value(minimal_constant{}) == hana::value>(), ""); +static_assert(hana::value(minimal_constant{}) == hana::value>(), ""); + + +int main() { } diff --git a/src/boost/libs/hana/test/concept/constant/minimal.hpp b/src/boost/libs/hana/test/concept/constant/minimal.hpp new file mode 100644 index 000000000..ebc2ae11b --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/minimal.hpp @@ -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) + +#ifndef TEST_CONCEPT_CONSTANT_MINIMAL_HPP +#define TEST_CONCEPT_CONSTANT_MINIMAL_HPP + +#include +#include +#include +#include + + +template +struct minimal_constant_tag { + using value_type = T; +}; + +template +struct minimal_constant { + using hana_tag = minimal_constant_tag; + static constexpr T value_ = v; +}; + +namespace boost { namespace hana { + template + struct value_impl> { + template + static constexpr T apply() { return N::value_; } + }; + + template + struct to_impl, C, hana::when< + hana::Constant::value && + hana::is_convertible::value + >> + : hana::embedding::value> + { + template + static constexpr auto apply(N const&) + { return minimal_constant()>{}; } + }; +}} // end namespace boost::hana + +#endif // !TEST_CONCEPT_CONSTANT_MINIMAL_HPP diff --git a/src/boost/libs/hana/test/concept/constant/orderable.cpp b/src/boost/libs/hana/test/concept/constant/orderable.cpp new file mode 100644 index 000000000..08aba261d --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/orderable.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 "minimal.hpp" + +#include + +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{}, + minimal_constant{} + ); + + hana::test::TestOrderable>{ints}; +} diff --git a/src/boost/libs/hana/test/concept/constant/to.cpp b/src/boost/libs/hana/test/concept/constant/to.cpp new file mode 100644 index 000000000..8500b1d90 --- /dev/null +++ b/src/boost/libs/hana/test/concept/constant/to.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 "minimal.hpp" + +#include +#include +namespace hana = boost::hana; + + +static_assert(hana::is_convertible, bool>::value, ""); +static_assert(hana::to(minimal_constant{}) == true, ""); + +static_assert(hana::is_convertible, int>::value, ""); +static_assert(hana::to(minimal_constant{}) == 1, ""); + +static_assert(hana::is_convertible, long>::value, ""); +static_assert(hana::to(minimal_constant{}) == 1l, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/concept/integral_constant.cpp b/src/boost/libs/hana/test/concept/integral_constant.cpp new file mode 100644 index 000000000..ad69759fc --- /dev/null +++ b/src/boost/libs/hana/test/concept/integral_constant.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +// Define a simple model of IntegralConstant +struct constant_tag { using value_type = int; }; +template +struct constant { + static constexpr int value = i; + using hana_tag = constant_tag; +}; + +namespace boost { namespace hana { + template <> + struct IntegralConstant { + static constexpr bool value = true; + }; + + template + struct to_impl::value>> { + template + static constexpr auto apply(N const&) + { return constant{}; } + }; +}} + +// Make sure we really satisfy IntegralConstant<>. +static_assert(hana::IntegralConstant>::value, ""); +static_assert(hana::IntegralConstant>::value, ""); +static_assert(hana::IntegralConstant>::value, ""); + +// Make sure we're also a model of Constant automatically. +static_assert(hana::Constant>::value, ""); +static_assert(hana::Constant>::value, ""); +static_assert(hana::Constant>::value, ""); + +// Make sure we have the hana::value<> function defined automatically. +static_assert(hana::value>() == 0, ""); +static_assert(hana::value>() == 1, ""); +static_assert(hana::value>() == 2, ""); +static_assert(hana::value>() == 3, ""); + + +int main() { } diff --git a/src/boost/libs/hana/test/concept/sequence/iterable.cpp b/src/boost/libs/hana/test/concept/sequence/iterable.cpp new file mode 100644 index 000000000..75df0b1b8 --- /dev/null +++ b/src/boost/libs/hana/test/concept/sequence/iterable.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_ITERABLE +#include diff --git a/src/boost/libs/hana/test/concept/sequence/monad.cpp b/src/boost/libs/hana/test/concept/sequence/monad.cpp new file mode 100644 index 000000000..8de1861ff --- /dev/null +++ b/src/boost/libs/hana/test/concept/sequence/monad.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_MONAD +#include diff --git a/src/boost/libs/hana/test/concept/sequence/monad_plus.cpp b/src/boost/libs/hana/test/concept/sequence/monad_plus.cpp new file mode 100644 index 000000000..3af644d25 --- /dev/null +++ b/src/boost/libs/hana/test/concept/sequence/monad_plus.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_MONAD_PLUS +#include diff --git a/src/boost/libs/hana/test/concept/sequence/orderable.cpp b/src/boost/libs/hana/test/concept/sequence/orderable.cpp new file mode 100644 index 000000000..802ae2891 --- /dev/null +++ b/src/boost/libs/hana/test/concept/sequence/orderable.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_ORDERABLE +#include diff --git a/src/boost/libs/hana/test/concept/sequence/searchable.cpp b/src/boost/libs/hana/test/concept/sequence/searchable.cpp new file mode 100644 index 000000000..29a815cd7 --- /dev/null +++ b/src/boost/libs/hana/test/concept/sequence/searchable.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_SEARCHABLE +#include diff --git a/src/boost/libs/hana/test/concept/sequence/sequence.cpp b/src/boost/libs/hana/test/concept/sequence/sequence.cpp new file mode 100644 index 000000000..2a096973d --- /dev/null +++ b/src/boost/libs/hana/test/concept/sequence/sequence.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_SEQUENCE +#include diff --git a/src/boost/libs/hana/test/concept/struct/any_of.cpp b/src/boost/libs/hana/test/concept/struct/any_of.cpp new file mode 100644 index 000000000..8dd9082a8 --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/any_of.cpp @@ -0,0 +1,46 @@ +// 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 +#include +#include +#include +#include +#include + +#include "minimal_struct.hpp" +namespace hana = boost::hana; + + +template +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + obj(), + undefined<>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + obj(undefined<0>{}), + hana::equal.to(hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + obj(undefined<0>{}), + hana::equal.to(hana::int_c<1>) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + obj(undefined<0>{}, undefined<1>{}), + hana::equal.to(hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + obj(undefined<0>{}, undefined<1>{}), + hana::equal.to(hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + obj(undefined<0>{}, undefined<1>{}), + hana::equal.to(hana::int_c<2>) + ))); +} diff --git a/src/boost/libs/hana/test/concept/struct/at_key.cpp b/src/boost/libs/hana/test/concept/struct/at_key.cpp new file mode 100644 index 000000000..2a9d757be --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/at_key.cpp @@ -0,0 +1,55 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct Person { + BOOST_HANA_DEFINE_STRUCT(Person, + (std::string, name), + (std::string, last_name), + (int, age) + ); +}; + +int main() { + // non-const ref + { + Person john{"John", "Doe", 30}; + std::string& name = hana::at_key(john, BOOST_HANA_STRING("name")); + std::string& last_name = hana::at_key(john, BOOST_HANA_STRING("last_name")); + int& age = hana::at_key(john, BOOST_HANA_STRING("age")); + + name = "Bob"; + last_name = "Foo"; + age = 99; + + BOOST_HANA_RUNTIME_CHECK(john.name == "Bob"); + BOOST_HANA_RUNTIME_CHECK(john.last_name == "Foo"); + BOOST_HANA_RUNTIME_CHECK(john.age == 99); + } + + // const ref + { + Person john{"John", "Doe", 30}; + Person const& const_john = john; + std::string const& name = hana::at_key(const_john, BOOST_HANA_STRING("name")); + std::string const& last_name = hana::at_key(const_john, BOOST_HANA_STRING("last_name")); + int const& age = hana::at_key(const_john, BOOST_HANA_STRING("age")); + + john.name = "Bob"; + john.last_name = "Foo"; + john.age = 99; + + BOOST_HANA_RUNTIME_CHECK(name == "Bob"); + BOOST_HANA_RUNTIME_CHECK(last_name == "Foo"); + BOOST_HANA_RUNTIME_CHECK(age == 99); + } +} diff --git a/src/boost/libs/hana/test/concept/struct/equal.cpp b/src/boost/libs/hana/test/concept/struct/equal.cpp new file mode 100644 index 000000000..3bd916897 --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/equal.cpp @@ -0,0 +1,47 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include "minimal_struct.hpp" +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + obj(), + obj() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + obj(ct_eq<0>{}), + obj(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + obj(ct_eq<0>{}), + obj(ct_eq<1>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + obj(ct_eq<0>{}, ct_eq<1>{}), + obj(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + obj(ct_eq<1>{}, ct_eq<0>{}), + obj(ct_eq<0>{}, ct_eq<1>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + obj(ct_eq<0>{}, ct_eq<99>{}), + obj(ct_eq<0>{}, ct_eq<1>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + obj(ct_eq<99>{}, ct_eq<1>{}), + obj(ct_eq<0>{}, ct_eq<1>{}) + ))); +} diff --git a/src/boost/libs/hana/test/concept/struct/find_if.cpp b/src/boost/libs/hana/test/concept/struct/find_if.cpp new file mode 100644 index 000000000..3e249239b --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/find_if.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 +#include +#include +#include +#include +#include + +#include "minimal_struct.hpp" +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +template +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(obj(), undefined<>{}), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(obj(ct_eq<0>{}), hana::equal.to(hana::int_c<0>)), + hana::just(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(obj(undefined<1>{}), hana::equal.to(hana::int_c<1>)), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(obj(ct_eq<0>{}, ct_eq<1>{}), hana::equal.to(hana::int_c<0>)), + hana::just(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(obj(ct_eq<0>{}, ct_eq<1>{}), hana::equal.to(hana::int_c<1>)), + hana::just(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(obj(undefined<0>{}, undefined<1>{}), hana::equal.to(hana::int_c<2>)), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/concept/struct/fold_left.cpp b/src/boost/libs/hana/test/concept/struct/fold_left.cpp new file mode 100644 index 000000000..f7b63814d --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/fold_left.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 +#include +#include +#include +#include + +#include "minimal_struct.hpp" +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +template +struct undefined { }; + +struct MoveOnly { + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly const&) = delete; +}; + +int main() { + constexpr auto pair = ::minimal_product; + ct_eq<999> s{}; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(obj(), s, undefined<>{}), + s + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(obj(ct_eq<0>{}), s, f), + f(s, pair(hana::int_c<0>, ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(obj(ct_eq<0>{}, ct_eq<1>{}), s, f), + f(f(s, pair(hana::int_c<0>, ct_eq<0>{})), pair(hana::int_c<1>, ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(obj(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), s, f), + f(f(f(s, pair(hana::int_c<0>, ct_eq<0>{})), + pair(hana::int_c<1>, ct_eq<1>{})), + pair(hana::int_c<2>, ct_eq<2>{})) + )); + + // fold_left with move-only members + hana::fold_left(obj(MoveOnly{}), 0, [](int, auto) { return 0; }); + hana::fold_left(obj(MoveOnly{}, MoveOnly{}), 0, [](int, auto) { return 0; }); +} diff --git a/src/boost/libs/hana/test/concept/struct/fold_right.cpp b/src/boost/libs/hana/test/concept/struct/fold_right.cpp new file mode 100644 index 000000000..3db67def9 --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/fold_right.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 +#include +#include +#include +#include + +#include "minimal_struct.hpp" +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +template +struct undefined { }; + +struct MoveOnly { + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly const&) = delete; +}; + +int main() { + constexpr auto pair = ::minimal_product; + ct_eq<999> s{}; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(obj(), s, undefined<>{}), + s + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(obj(ct_eq<0>{}), s, f), + f(pair(hana::int_c<0>, ct_eq<0>{}), s) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(obj(ct_eq<0>{}, ct_eq<1>{}), s, f), + f(pair(hana::int_c<0>, ct_eq<0>{}), f(pair(hana::int_c<1>, ct_eq<1>{}), s)) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(obj(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), s, f), + f(pair(hana::int_c<0>, ct_eq<0>{}), + f(pair(hana::int_c<1>, ct_eq<1>{}), + f(pair(hana::int_c<2>, ct_eq<2>{}), s))) + )); + + // fold_right with move-only members + hana::fold_right(obj(MoveOnly{}), 0, [](auto, int) { return 0; }); + hana::fold_right(obj(MoveOnly{}, MoveOnly{}), 0, [](auto, int) { return 0; }); +} diff --git a/src/boost/libs/hana/test/concept/struct/keys.cpp b/src/boost/libs/hana/test/concept/struct/keys.cpp new file mode 100644 index 000000000..c07de9e12 --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/keys.cpp @@ -0,0 +1,46 @@ +// 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 +#include +#include +#include +#include + +#include "minimal_struct.hpp" +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +template +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::keys(obj()), + ::seq() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::keys(obj(undefined<0>{})), + ::seq(hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::keys(obj(undefined<0>{}, undefined<1>{})), + ::seq(hana::int_c<0>, hana::int_c<1>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::keys(obj(undefined<0>{}, undefined<1>{}, undefined<2>{})), + ::seq(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::keys(obj(undefined<0>{}, undefined<1>{}, undefined<2>{}, undefined<3>{})), + ::seq(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>, hana::int_c<3>) + )); +} diff --git a/src/boost/libs/hana/test/concept/struct/laws.cpp b/src/boost/libs/hana/test/concept/struct/laws.cpp new file mode 100644 index 000000000..b10955dbe --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/laws.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 +#include +#include + +#include "minimal_struct.hpp" +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto eq0 = hana::make_tuple(obj()); + auto eq1 = hana::make_tuple( + obj(ct_eq<0>{}), obj(ct_eq<1>{}), obj(ct_eq<2>{}) + ); + auto eq2 = hana::make_tuple( + obj(ct_eq<0>{}, ct_eq<0>{}), + obj(ct_eq<0>{}, ct_eq<1>{}), + obj(ct_eq<1>{}, ct_eq<0>{}), + obj(ct_eq<1>{}, ct_eq<1>{}), + obj(ct_eq<0>{}, ct_eq<2>{}), + obj(ct_eq<2>{}, ct_eq<3>{}) + ); + + hana::test::TestComparable>{eq0}; + hana::test::TestComparable>{eq1}; + hana::test::TestComparable>{eq2}; + + hana::test::TestFoldable>{eq0}; + hana::test::TestFoldable>{eq1}; + hana::test::TestFoldable>{eq2}; + + hana::test::TestSearchable>{eq0, hana::make_tuple()}; + hana::test::TestSearchable>{eq1, hana::make_tuple(hana::int_c<0>)}; + hana::test::TestSearchable>{eq2, hana::make_tuple(hana::int_c<0>, hana::int_c<1>)}; +} diff --git a/src/boost/libs/hana/test/concept/struct/macro.adapt_adt.cpp b/src/boost/libs/hana/test/concept/struct/macro.adapt_adt.cpp new file mode 100644 index 000000000..dc759b425 --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/macro.adapt_adt.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +namespace ns { + struct Data0 { }; + struct Data1 { + ct_eq<1> get_member1() const { return {}; } + }; + struct Data2 { + ct_eq<1> get_member1() const { return {}; } + ct_eq<2> get_member2() const { return {}; } + }; + struct Data3 { + ct_eq<1> get_member1() const { return {}; } + ct_eq<2> get_member2() const { return {}; } + ct_eq<3> get_member3() const { return {}; } + }; +} + +// Note: We use commas in the lambdas to make sure the macro can handle it. +BOOST_HANA_ADAPT_ADT(ns::Data0); +BOOST_HANA_ADAPT_ADT(ns::Data1, + (member1, [](auto const& d) { return 0, d.get_member1(); }) +); +BOOST_HANA_ADAPT_ADT(ns::Data2, + (member1, [](auto const& d) { return 0, d.get_member1(); }), + (member2, [](auto const& d) { return d.get_member2(); }) +); +BOOST_HANA_ADAPT_ADT(ns::Data3, + (member1, [](auto const& d) { return 0, d.get_member1(); }), + (member2, [](auto const& d) { return d.get_member2(); }), + (member3, [](auto const& d) { return d.get_member3(); }) +); + +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data1{}, BOOST_HANA_STRING("member1"))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data2{}, BOOST_HANA_STRING("member1"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data2{}, BOOST_HANA_STRING("member2"))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member1"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member2"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member3"))); +} diff --git a/src/boost/libs/hana/test/concept/struct/macro.adapt_struct.cpp b/src/boost/libs/hana/test/concept/struct/macro.adapt_struct.cpp new file mode 100644 index 000000000..6aec33d5c --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/macro.adapt_struct.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +namespace ns { + struct Data0 { }; + struct Data1 { + ct_eq<1> member1; + }; + struct Data2 { + ct_eq<1> member1; + ct_eq<2> member2; + }; + struct Data3 { + ct_eq<1> member1; + ct_eq<2> member2; + ct_eq<3> member3; + }; + struct MemberArray { + int array[10]; + }; +} + +BOOST_HANA_ADAPT_STRUCT(ns::Data0); +BOOST_HANA_ADAPT_STRUCT(ns::Data1, member1); +BOOST_HANA_ADAPT_STRUCT(ns::Data2, member1, member2); +BOOST_HANA_ADAPT_STRUCT(ns::Data3, member1, member2, member3); +BOOST_HANA_ADAPT_STRUCT(ns::MemberArray, array); + +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data1{}, BOOST_HANA_STRING("member1"))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data2{}, BOOST_HANA_STRING("member1"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data2{}, BOOST_HANA_STRING("member2"))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member1"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member2"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::Data3{}, BOOST_HANA_STRING("member3"))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(ns::MemberArray{}, BOOST_HANA_STRING("array"))); +} diff --git a/src/boost/libs/hana/test/concept/struct/macro.define_struct.cpp b/src/boost/libs/hana/test/concept/struct/macro.define_struct.cpp new file mode 100644 index 000000000..29ddbfddb --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/macro.define_struct.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +// This allows us to make sure we can enter template types +// containing commas in the macro. +template +using commas = T; + +struct Data0 { + BOOST_HANA_DEFINE_STRUCT(Data0); +}; +struct Data1 { + BOOST_HANA_DEFINE_STRUCT(Data1, + (commas, void>, member1) + ); +}; +struct Data2 { + BOOST_HANA_DEFINE_STRUCT(Data2, + (commas, void, void>, member1), + (ct_eq<2>, member2) + ); +}; +struct Data3 { + BOOST_HANA_DEFINE_STRUCT(Data3, + (ct_eq<1>, member1), + (ct_eq<2>, member2), + (commas, void, void, void>, member3) + ); +}; + +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); +static_assert(hana::Struct::value, ""); + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::contains(Data1{}, BOOST_HANA_STRING("member1"))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(Data2{}, BOOST_HANA_STRING("member1"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(Data2{}, BOOST_HANA_STRING("member2"))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(Data3{}, BOOST_HANA_STRING("member1"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(Data3{}, BOOST_HANA_STRING("member2"))); + BOOST_HANA_CONSTANT_CHECK(hana::contains(Data3{}, BOOST_HANA_STRING("member3"))); +} diff --git a/src/boost/libs/hana/test/concept/struct/member_function.cpp b/src/boost/libs/hana/test/concept/struct/member_function.cpp new file mode 100644 index 000000000..1e3ab6ecb --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/member_function.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 +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +// +// Unit test inspired by http://stackoverflow.com/q/32678647/627587 +// + +struct Foo { + std::string get_name() const { return "louis"; } +}; + +namespace boost { namespace hana { + template <> + struct accessors_impl { + static auto apply() { + return hana::make_tuple( + hana::make_pair(BOOST_HANA_STRING("get_name"), [](auto const& foo) { + return foo.get_name(); + }) + ); + } + }; +}} + +int main() { + Foo foo; + hana::for_each(foo, hana::fuse([](auto /*key*/, std::string const& name) { + BOOST_HANA_RUNTIME_CHECK(name == "louis"); + })); +} diff --git a/src/boost/libs/hana/test/concept/struct/members.cpp b/src/boost/libs/hana/test/concept/struct/members.cpp new file mode 100644 index 000000000..1734b519b --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/members.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 +#include +#include +#include + +#include "minimal_struct.hpp" +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct MoveOnly { + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly const&) = delete; +}; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::members(obj()), + ::seq() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::members(obj(ct_eq<0>{})), + ::seq(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::members(obj(ct_eq<0>{}, ct_eq<1>{})), + ::seq(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::members(obj(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})), + ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + // make sure it works with move only types + auto z1 = hana::members(obj(MoveOnly{})); + auto z2 = hana::members(obj(MoveOnly{}, MoveOnly{})); + (void)z1; + (void)z2; +} diff --git a/src/boost/libs/hana/test/concept/struct/minimal_struct.hpp b/src/boost/libs/hana/test/concept/struct/minimal_struct.hpp new file mode 100644 index 000000000..4eea80dfb --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/minimal_struct.hpp @@ -0,0 +1,54 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_STRUCT_MINIMAL_STRUCT_HPP +#define BOOST_HANA_TEST_STRUCT_MINIMAL_STRUCT_HPP + +#include +#include +#include +#include +#include +#include + + +template +struct minimal_struct_tag; + +template +struct minimal_struct_t { + boost::hana::tuple members; + using hana_tag = minimal_struct_tag; +}; + +struct obj_t { + template + constexpr minimal_struct_t operator()(Members ...members) const { + return {{static_cast(members)...}}; + } +}; +constexpr obj_t obj{}; + +namespace boost { namespace hana { + template + struct accessors_impl> { + template + struct get_member { + template + constexpr decltype(auto) operator()(Struct&& s) const { + return hana::at_c(static_cast(s).members); + } + }; + + static auto apply() { + return hana::unpack(hana::range_c, [](auto ...k) { + return hana::make_tuple( + hana::make_pair(k, get_member{})... + ); + }); + } + }; +}} + +#endif // !BOOST_HANA_TEST_STRUCT_MINIMAL_STRUCT_HPP diff --git a/src/boost/libs/hana/test/concept/struct/unpack.cpp b/src/boost/libs/hana/test/concept/struct/unpack.cpp new file mode 100644 index 000000000..30b8982f5 --- /dev/null +++ b/src/boost/libs/hana/test/concept/struct/unpack.cpp @@ -0,0 +1,44 @@ +// 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 +#include +#include +#include +#include + +#include "minimal_struct.hpp" +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + constexpr auto pair = ::minimal_product; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(obj(), f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(obj(ct_eq<0>{}), f), + f(pair(hana::int_c<0>, ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(obj(ct_eq<0>{}, ct_eq<1>{}), f), + f(pair(hana::int_c<0>, ct_eq<0>{}), + pair(hana::int_c<1>, ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(obj(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f), + f(pair(hana::int_c<0>, ct_eq<0>{}), + pair(hana::int_c<1>, ct_eq<1>{}), + pair(hana::int_c<2>, ct_eq<2>{})) + )); +} diff --git a/src/boost/libs/hana/test/core/common.cpp b/src/boost/libs/hana/test/core/common.cpp new file mode 100644 index 000000000..c3b24f900 --- /dev/null +++ b/src/boost/libs/hana/test/core/common.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +template +struct ImplicitConvertibleTo { + constexpr operator T() const { return {}; } +}; + +struct T { }; +struct invalid; + +static_assert(std::is_same, T>{}, ""); +static_assert(std::is_same, invalid>{}, ""); +static_assert(std::is_same, void>{}, ""); + +static_assert(std::is_same, T>, T>{}, ""); +static_assert(std::is_same>, T>{}, ""); + +static_assert(hana::has_common{}, ""); +static_assert(!hana::has_common{}, ""); +static_assert(!hana::has_common{}, ""); +static_assert(!hana::has_common{}, ""); +static_assert(!hana::has_common{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/core/default.cpp b/src/boost/libs/hana/test/core/default.cpp new file mode 100644 index 000000000..9846c22b8 --- /dev/null +++ b/src/boost/libs/hana/test/core/default.cpp @@ -0,0 +1,18 @@ +// 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 +namespace hana = boost::hana; + + +template +struct method_impl : hana::default_ { }; + +template <> +struct method_impl { }; + +static_assert(hana::is_default>{}, ""); +static_assert(!hana::is_default>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/core/is_a.cpp b/src/boost/libs/hana/test/core/is_a.cpp new file mode 100644 index 000000000..08d390030 --- /dev/null +++ b/src/boost/libs/hana/test/core/is_a.cpp @@ -0,0 +1,18 @@ +// 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 +namespace hana = boost::hana; + + +int main() { + // This used to trigger a compilation error on Clang 3.5. + { + auto f = [](auto i) { + constexpr auto result = hana::is_an(i); + (void)result; + }; + f(1); + } +} diff --git a/src/boost/libs/hana/test/core/is_embedded.cpp b/src/boost/libs/hana/test/core/is_embedded.cpp new file mode 100644 index 000000000..12a440901 --- /dev/null +++ b/src/boost/libs/hana/test/core/is_embedded.cpp @@ -0,0 +1,62 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +// This test makes sure that fundamental types are properly embedded in +// each other, when sensible. + +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); + +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); + +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); +static_assert(hana::is_embedded{}, ""); + +#if CHAR_MIN < 0 // char is signed + + static_assert(hana::is_embedded{}, ""); + static_assert(hana::is_embedded{}, ""); + static_assert(hana::is_embedded{}, ""); + static_assert(hana::is_embedded{}, ""); + + static_assert(hana::equal('a', static_cast('a')), ""); + +#else // char is unsigned + + static_assert(hana::is_embedded{}, ""); + static_assert(hana::is_embedded{}, ""); + static_assert(hana::is_embedded{}, ""); + static_assert(hana::is_embedded{}, ""); + + static_assert(hana::equal('a', static_cast('a')), ""); + +#endif + + +int main() { } diff --git a/src/boost/libs/hana/test/core/make.cpp b/src/boost/libs/hana/test/core/make.cpp new file mode 100644 index 000000000..01677f7b0 --- /dev/null +++ b/src/boost/libs/hana/test/core/make.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 +namespace hana = boost::hana; + + +struct udt { + int value; + constexpr explicit udt(int v) : value(v) { } +}; + +static_assert(hana::make(1).value == 1, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/core/tag_of.cpp b/src/boost/libs/hana/test/core/tag_of.cpp new file mode 100644 index 000000000..99afe5c7e --- /dev/null +++ b/src/boost/libs/hana/test/core/tag_of.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 +#include + +#include +namespace hana = boost::hana; + + +template +struct test { + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); + static_assert(std::is_same, ExpectedDatatype>::value, ""); +}; + +struct NestedDatatype; +struct Nested { struct hana_tag; }; +template struct test; + +struct NoNestedDatatype { }; +template struct test; + +struct NoNestedHana { }; +template struct test; + + +struct FullySpecializedDatatype; +struct FullySpecialized; +namespace boost { namespace hana { + template <> + struct tag_of { + using type = FullySpecializedDatatype; + }; +}} +template struct test; + + +struct PartiallySpecializedDatatype; +template struct PartiallySpecialized; +namespace boost { namespace hana { + template + struct tag_of> { + using type = PartiallySpecializedDatatype; + }; +}} +template struct test, PartiallySpecializedDatatype>; + + +struct PredicatedDatatype; +struct Predicated { static constexpr bool predicate = true; }; +namespace boost { namespace hana { + template + struct tag_of> { + using type = PredicatedDatatype; + }; +}} +template struct test; + + +int main() { } diff --git a/src/boost/libs/hana/test/core/to.cpp b/src/boost/libs/hana/test/core/to.cpp new file mode 100644 index 000000000..f4dd54ef7 --- /dev/null +++ b/src/boost/libs/hana/test/core/to.cpp @@ -0,0 +1,106 @@ +// 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 + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +constexpr auto operator==(X x, Y y) +{ return x.value == y.value; } + +struct Datatype { + int value; + using hana_tag = Datatype; +}; + +struct Other { + int value; + using hana_tag = Datatype; +}; + +struct SpecializedFrom; +struct specialized_from { + int value; + using hana_tag = SpecializedFrom; +}; + +struct SpecializedTo; +struct specialized_to { + int value; + using hana_tag = SpecializedTo; +}; + +namespace boost { namespace hana { + template <> + struct to_impl { + template + static constexpr auto apply(T t) + { return specialized_to{t.value}; } + }; +}} + +template +void check_convert(F f, T t) { + using From = hana::tag_of_t; + using To = hana::tag_of_t; + + // Check From -> To conversion + BOOST_HANA_RUNTIME_CHECK(hana::to(f) == t); + static_assert(std::is_same< + hana::tag_of_t(f))>, To + >{}, ""); + + static_assert(hana::is_convertible{}, ""); + + + // Make sure From -> From and To -> To are the identity. + BOOST_HANA_RUNTIME_CHECK(hana::to(f) == f); + static_assert(std::is_same< + hana::tag_of_t(f))>, From + >{}, ""); + + BOOST_HANA_RUNTIME_CHECK(hana::to(t) == t); + static_assert(std::is_same< + hana::tag_of_t(t))>, To + >{}, ""); + + static_assert(hana::is_convertible{}, ""); + static_assert(hana::is_convertible{}, ""); + + static_assert(hana::is_embedded{}, ""); + static_assert(hana::is_embedded{}, ""); +} + +template +void check_variable_template_in_dependent_context(X x) { + hana::to(x); +} + +int main() { + // Clang used to assert in the code generation when we used variable + // templates inside a lambda; this is to catch this. + check_variable_template_in_dependent_context(3); + + check_convert("abcdef", std::string{"abcdef"}); + check_convert(int{1}, double{1}); + check_convert(double{1}, int{1}); + check_convert(std::true_type{}, int{1}); + check_convert(std::false_type{}, int{0}); + check_convert(Datatype{1}, Datatype{1}); + check_convert(Other{1}, Other{1}); + check_convert(specialized_from{1}, specialized_to{1}); + + static_assert(!hana::is_convertible{}, ""); + static_assert(!hana::is_embedded{}, ""); + + static_assert(hana::is_convertible{}, ""); + static_assert(!hana::is_embedded{}, ""); +} diff --git a/src/boost/libs/hana/test/core/when.cpp b/src/boost/libs/hana/test/core/when.cpp new file mode 100644 index 000000000..c8fead5e0 --- /dev/null +++ b/src/boost/libs/hana/test/core/when.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 +namespace hana = boost::hana; + + +template > +struct base_template; + +template +struct base_template> { }; + +template +struct base_template> { }; + +struct First { struct first_type; }; +struct Second { struct second_type; }; + +template struct base_template; +template struct base_template; + +int main() { } diff --git a/src/boost/libs/hana/test/deploy/CMakeLists.txt b/src/boost/libs/hana/test/deploy/CMakeLists.txt new file mode 100644 index 000000000..186d5def7 --- /dev/null +++ b/src/boost/libs/hana/test/deploy/CMakeLists.txt @@ -0,0 +1,10 @@ +# 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) + +cmake_minimum_required(VERSION 3.0) +project(external CXX) +find_package(Hana REQUIRED) + +add_executable(main main.cpp) +target_link_libraries(main hana) diff --git a/src/boost/libs/hana/test/deploy/main.cpp b/src/boost/libs/hana/test/deploy/main.cpp new file mode 100644 index 000000000..e35e81350 --- /dev/null +++ b/src/boost/libs/hana/test/deploy/main.cpp @@ -0,0 +1,8 @@ +// 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 + + +int main() { } diff --git a/src/boost/libs/hana/test/detail/algorithm.cpp b/src/boost/libs/hana/test/detail/algorithm.cpp new file mode 100644 index 000000000..af885ceaf --- /dev/null +++ b/src/boost/libs/hana/test/detail/algorithm.cpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +// The algorithms are taken from the suggested implementations on cppreference. +// Hence, we assume them to be correct and we only make sure they compile, to +// avoid stupid mistakes I could have made when copy/pasting and editing. +// +// Oh, and we also make sure they can be used in a constexpr context. +constexpr bool constexpr_context() { + int x = 0, y = 1; + hana::detail::constexpr_swap(x, y); + + int array[6] = {1, 2, 3, 4, 5, 6}; + int* first = array; + int* last = array + 6; + + hana::detail::reverse(first, last); + + hana::detail::next_permutation(first, last, hana::less); + hana::detail::next_permutation(first, last); + + hana::detail::lexicographical_compare(first, last, first, last, hana::less); + hana::detail::lexicographical_compare(first, last, first, last); + + hana::detail::equal(first, last, first, last, hana::equal); + hana::detail::equal(first, last, first, last); + + hana::detail::sort(first, last, hana::equal); + hana::detail::sort(first, last); + + hana::detail::find(first, last, 3); + hana::detail::find_if(first, last, hana::equal.to(3)); + + hana::detail::iota(first, last, 0); + + hana::detail::count(first, last, 2); + + hana::detail::accumulate(first, last, 0); + hana::detail::accumulate(first, last, 1, hana::mult); + + hana::detail::min_element(first, last); + + return true; +} + +static_assert(constexpr_context(), ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/any_of.cpp b/src/boost/libs/hana/test/detail/any_of.cpp new file mode 100644 index 000000000..3d71cc29e --- /dev/null +++ b/src/boost/libs/hana/test/detail/any_of.cpp @@ -0,0 +1,45 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +namespace hana = boost::hana; + + +template +struct is_even { + static constexpr bool value = I::value % 2 == 0; +}; + + +static_assert(!hana::detail::any_of::value, ""); +static_assert(!hana::detail::any_of>::value, ""); +static_assert(!hana::detail::any_of, hana::int_<3>>::value, ""); +static_assert(!hana::detail::any_of, hana::int_<3>, hana::int_<5>>::value, ""); +static_assert(!hana::detail::any_of, hana::int_<3>, hana::int_<5>, hana::int_<7>>::value, ""); + +static_assert(hana::detail::any_of>::value, ""); +static_assert(hana::detail::any_of, hana::int_<2>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<2>, hana::int_<4>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<2>, hana::int_<4>, hana::int_<6>>::value, ""); + +static_assert(hana::detail::any_of, hana::int_<1>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<1>, hana::int_<2>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<1>, hana::int_<2>, hana::int_<3>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<1>, hana::int_<2>, hana::int_<3>, hana::int_<4>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<3>, hana::int_<5>, hana::int_<8>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<8>, hana::int_<5>, hana::int_<7>>::value, ""); + +// Make sure we short-circuit properly +template +struct fail { + static_assert(hana::detail::wrong::value, + "this must never be instantiated"); +}; +static_assert(hana::detail::any_of, hana::int_<2>, fail<>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<2>, fail<>, hana::int_<3>>::value, ""); +static_assert(hana::detail::any_of, hana::int_<2>, fail<>, hana::int_<4>>::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp b/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp new file mode 100644 index 000000000..9dffcb526 --- /dev/null +++ b/src/boost/libs/hana/test/detail/canonical_constant/laws.cpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct canonical { + static constexpr T value = v; + using hana_tag = hana::detail::CanonicalConstant; +}; + +int main() { + auto ints = hana::make_tuple( + canonical{}, canonical{}, canonical{}, + canonical{}, canonical{}, canonical{} + ); + + auto bools = hana::make_tuple(canonical{}, canonical{}); + + // Constant + hana::test::TestConstant>{ints, hana::tuple_t}; + hana::test::TestConstant>{bools, hana::tuple_t}; + + // Monoid, Group, Ring, EuclideanRing + hana::test::TestMonoid>{ints}; + hana::test::TestGroup>{ints}; + hana::test::TestRing>{ints}; + hana::test::TestEuclideanRing>{ints}; + + // Logical + { + auto ints = hana::make_tuple( + canonical{}, canonical{}, + canonical{}, canonical{} + ); + hana::test::TestLogical>{ints}; + hana::test::TestLogical>{bools}; + } + + // Comparable and Orderable + hana::test::TestComparable>{ints}; + hana::test::TestOrderable>{ints}; +} diff --git a/src/boost/libs/hana/test/detail/create.cpp b/src/boost/libs/hana/test/detail/create.cpp new file mode 100644 index 000000000..e17002f10 --- /dev/null +++ b/src/boost/libs/hana/test/detail/create.cpp @@ -0,0 +1,38 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +constexpr hana::detail::create make_tuple{}; +constexpr hana::detail::create make_pair{}; + +template +struct empty { }; + +template +struct single_holder { T x; }; + +template +struct identity { using type = T; }; + +template +using identity_t = typename identity::type; + +int main() { + static_assert(make_tuple(1, '2', 3.3) == std::make_tuple(1, '2', 3.3), ""); + static_assert(make_pair(1, '2') == std::make_pair(1, '2'), ""); + + // should work + hana::detail::create{}(); + hana::detail::create{}(1); + hana::detail::create{}([]{}); + hana::detail::create{}(1); + hana::detail::create{}([]{}); +} diff --git a/src/boost/libs/hana/test/detail/decay.cpp b/src/boost/libs/hana/test/detail/decay.cpp new file mode 100644 index 000000000..bc1ec5b60 --- /dev/null +++ b/src/boost/libs/hana/test/detail/decay.cpp @@ -0,0 +1,54 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +template +void check() { + static_assert(std::is_same< + typename hana::detail::decay::type, + Decayed + >::value, ""); +} + +int main() { + // void is untouched + check(); + + // normal types lose cv-qualifiers + check(); + check(); + check(); + + // [cv-qualified] references are stripped + check(); + check(); + check(); + check(); + + // pointers are untouched + check(); + check(); + check(); + check(); + + // arrays decay to pointers + check(); + check(); + check(); + check(); + check(); + + // functions decay to function pointers + check(); + check(); + check(); + check(); + check(); + check(); +} diff --git a/src/boost/libs/hana/test/detail/ebo.cpp b/src/boost/libs/hana/test/detail/ebo.cpp new file mode 100644 index 000000000..6f174be40 --- /dev/null +++ b/src/boost/libs/hana/test/detail/ebo.cpp @@ -0,0 +1,95 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +namespace hana = boost::hana; +using hana::detail::ebo; + + +template struct empty { }; +template struct idx; +#ifdef BOOST_HANA_WORKAROUND_MSVC_EMPTYBASE +template struct __declspec(empty_bases) inherit : Bases... { }; +#else +template struct inherit : Bases... { }; +#endif + +static_assert(sizeof(inherit<>) == sizeof(inherit, empty<0>>>), ""); +static_assert(sizeof(inherit<>) == sizeof(inherit, empty<0>>, ebo, empty<1>>>), ""); +static_assert(sizeof(inherit<>) == sizeof(inherit, empty<0>>, ebo, empty<1>>, ebo, empty<2>>>), ""); + + +int main() { + // Test default-construction + { + constexpr ebo, int> e; + static_assert(hana::detail::ebo_get>(e) == 0, ""); + } + + // Test construction of a non-empty object + { + ebo, std::string> e{"foobar"}; + BOOST_HANA_RUNTIME_CHECK(hana::detail::ebo_get>(e) == "foobar"); + } + + { + ebo, std::string> e{}; + BOOST_HANA_RUNTIME_CHECK(hana::detail::ebo_get>(e) == ""); + } + + // Test construction of a non default-constructible type + { + struct nodefault { + nodefault() = delete; + explicit nodefault(char const*) { } + }; + ebo, nodefault> e{"foobar"}; + } + + // Get lvalue, const lvalue and rvalue with a non-empty type + { + ebo, std::string> e{"foobar"}; + std::string& s = hana::detail::ebo_get>(e); + BOOST_HANA_RUNTIME_CHECK(s == "foobar"); + s = "foobaz"; + BOOST_HANA_RUNTIME_CHECK(hana::detail::ebo_get>(e) == "foobaz"); + } + + { + ebo, std::string> const e{"foobar"}; + std::string const& s = hana::detail::ebo_get>(e); + BOOST_HANA_RUNTIME_CHECK(s == "foobar"); + } + + { + ebo, std::string> e{"foobar"}; + std::string&& s = hana::detail::ebo_get>(std::move(e)); + BOOST_HANA_RUNTIME_CHECK(s == "foobar"); + } + + // Get lvalue, const lvalue and rvalue with an empty type + { + ebo, empty<0>> e{}; + empty<0>& s = hana::detail::ebo_get>(e); + (void)s; + } + + { + ebo, empty<0>> const e{}; + empty<0> const& s = hana::detail::ebo_get>(e); + (void)s; + } + + { + ebo, empty<0>> e{}; + empty<0>&& s = hana::detail::ebo_get>(std::move(e)); + (void)s; + } +} diff --git a/src/boost/libs/hana/test/detail/fast_and.cpp b/src/boost/libs/hana/test/detail/fast_and.cpp new file mode 100644 index 000000000..fadb168f7 --- /dev/null +++ b/src/boost/libs/hana/test/detail/fast_and.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +namespace hana = boost::hana; + + +static_assert(hana::detail::fast_and<>::value, ""); +static_assert(hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); + +static_assert(hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); + +static_assert(hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); + +static_assert(hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); +static_assert(!hana::detail::fast_and::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp b/src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp new file mode 100644 index 000000000..dd2eff55d --- /dev/null +++ b/src/boost/libs/hana/test/detail/first_unsatisfied_index.cpp @@ -0,0 +1,47 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct poison { + poison() = default; + poison(poison const&) = delete; +}; + +int main() { + auto predicate = [](auto x) { + static_assert(!std::is_same::value, ""); + return hana::not_equal(x, ct_eq<9>{}); + }; + + using Find = hana::detail::first_unsatisfied_index; + + static_assert(decltype(Find{}())::value == 0, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}))::value == 1, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}, poison{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}))::value == 1, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}))::value == 2, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}, poison{}, poison{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}, poison{}))::value == 1, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<9>{}))::value == 2, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}))::value == 3, ""); + + static_assert(decltype(Find{}(ct_eq<9>{}, poison{}, poison{}, poison{}))::value == 0, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<9>{}, poison{}, poison{}))::value == 1, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<9>{}, poison{}))::value == 2, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<9>{}))::value == 3, ""); + static_assert(decltype(Find{}(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}))::value == 4, ""); +} diff --git a/src/boost/libs/hana/test/detail/has_duplicates.cpp b/src/boost/libs/hana/test/detail/has_duplicates.cpp new file mode 100644 index 000000000..fab5d7df6 --- /dev/null +++ b/src/boost/libs/hana/test/detail/has_duplicates.cpp @@ -0,0 +1,57 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +namespace hana = boost::hana; + + +static_assert(!hana::detail::has_duplicates<>::value, ""); + +static_assert(!hana::detail::has_duplicates< + hana::int_<0> +>::value, ""); + +static_assert(!hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1> +>::value, ""); + +static_assert(!hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<0>, hana::int_<2> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<0> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<1> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<2> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<1>, hana::int_<1> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::int_<1>, hana::int_<2> +>::value, ""); + +// Make sure it uses deep equality +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::long_<0>, hana::int_<2>, hana::int_<3> +>::value, ""); + +static_assert(hana::detail::has_duplicates< + hana::int_<0>, hana::int_<1>, hana::int_<2>, hana::long_<1> +>::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/preprocessor.cpp b/src/boost/libs/hana/test/detail/preprocessor.cpp new file mode 100644 index 000000000..0ce69549f --- /dev/null +++ b/src/boost/libs/hana/test/detail/preprocessor.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include + + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_CONCAT +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_CONCAT(1, 2) == 12, ""); + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_FRONT +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_FRONT(0) == 0, ""); +static_assert(BOOST_HANA_PP_FRONT(0, 1) == 0, ""); +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2) == 0, ""); +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2, 3) == 0, ""); + +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2, 3, 4, 5, 6, 6, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 16, 18) == 0, ""); + +static_assert(BOOST_HANA_PP_FRONT(0, 1, 2, 3, 4, 5, 6, 6, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 16, 18, 19) == 0, ""); + + +int main() { + using Vector = std::vector; + + ////////////////////////////////////////////////////////////////////////// + // BOOST_HANA_PP_STRINGIZE + ////////////////////////////////////////////////////////////////////////// + { + constexpr char const* xyz = BOOST_HANA_PP_STRINGIZE(xyz); + BOOST_HANA_RUNTIME_CHECK(std::string{xyz} == "xyz"); + }{ + constexpr char const* xyz = BOOST_HANA_PP_STRINGIZE(foo{bar, baz}); + BOOST_HANA_RUNTIME_CHECK(std::string{xyz} == "foo{bar, baz}"); + }{ + constexpr char const* xyz = BOOST_HANA_PP_STRINGIZE(foo, bar, baz); + BOOST_HANA_RUNTIME_CHECK(std::string{xyz} == "foo, bar, baz"); + } + + ////////////////////////////////////////////////////////////////////////// + // BOOST_HANA_PP_DROP_FRONT + ////////////////////////////////////////////////////////////////////////// + { + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1}); + }{ + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1, 2)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2}); + }{ + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1, 2, 3)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3}); + }{ + Vector args = {BOOST_HANA_PP_DROP_FRONT(0, 1, 2, 3, 4)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3, 4}); + } +} diff --git a/src/boost/libs/hana/test/detail/struct_macros.cpp b/src/boost/libs/hana/test/detail/struct_macros.cpp new file mode 100644 index 000000000..71904ac49 --- /dev/null +++ b/src/boost/libs/hana/test/detail/struct_macros.cpp @@ -0,0 +1,108 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +#include + + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_NARG +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_NARG(x) == 1, ""); +static_assert(BOOST_HANA_PP_NARG(x, x) == 2, ""); +static_assert(BOOST_HANA_PP_NARG(x, x, x) == 3, ""); +static_assert(BOOST_HANA_PP_NARG(x, x, x, x) == 4, ""); +static_assert(BOOST_HANA_PP_NARG( + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x) == 38, ""); +static_assert(BOOST_HANA_PP_NARG( + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x) == 39, ""); +static_assert(BOOST_HANA_PP_NARG( + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x, + x, x, x, x, x, x, x, x, x, x) == 40, ""); + + +////////////////////////////////////////////////////////////////////////////// +// BOOST_HANA_PP_BACK +////////////////////////////////////////////////////////////////////////////// +static_assert(BOOST_HANA_PP_BACK(1) == 1, ""); +static_assert(BOOST_HANA_PP_BACK(1, 2) == 2, ""); +static_assert(BOOST_HANA_PP_BACK(1, 2, 3) == 3, ""); +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4) == 4, ""); + +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39) == 39, ""); + +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38) == 38, ""); + +static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40) == 40, ""); + + +int main() { + using Vector = std::vector; + + ////////////////////////////////////////////////////////////////////////// + // BOOST_HANA_PP_DROP_BACK + ////////////////////////////////////////////////////////////////////////// + { + Vector args = {BOOST_HANA_PP_DROP_BACK(1)}; + BOOST_HANA_RUNTIME_CHECK(args.empty()); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3, 4)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3, 4, 5)}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3, 4}); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39 + )}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38 + }); + }{ + Vector args = {BOOST_HANA_PP_DROP_BACK( + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 + )}; + BOOST_HANA_RUNTIME_CHECK(args == Vector{ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39 + }); + } +} diff --git a/src/boost/libs/hana/test/detail/type_at.cpp b/src/boost/libs/hana/test/detail/type_at.cpp new file mode 100644 index 000000000..3297a55ed --- /dev/null +++ b/src/boost/libs/hana/test/detail/type_at.cpp @@ -0,0 +1,102 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +template +struct x; + +static_assert(std::is_same< + hana::detail::type_at<0, x<0>>::type, + x<0> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<0, x<0>, x<1>>::type, + x<0> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<0, x<0>, x<1>, x<2>>::type, + x<0> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<1, x<0>, x<1>>::type, + x<1> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<1, x<0>, x<1>, x<2>>::type, + x<1> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<1, x<0>, x<1>, x<2>, x<3>>::type, + x<1> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<2, x<0>, x<1>, x<2>>::type, + x<2> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<2, x<0>, x<1>, x<2>, x<3>>::type, + x<2> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<2, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + x<2> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<3, x<0>, x<1>, x<2>, x<3>>::type, + x<3> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<3, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + x<3> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<3, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + x<3> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<4, x<0>, x<1>, x<2>, x<3>, x<4>>::type, + x<4> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<4, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + x<4> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<4, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + x<4> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<5, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + x<5> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<5, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + x<5> +>{}, ""); +static_assert(std::is_same< + hana::detail::type_at<5, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + x<5> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<6, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + x<6> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_at<7, x<0>, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + x<7> +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/type_foldl1.cpp b/src/boost/libs/hana/test/detail/type_foldl1.cpp new file mode 100644 index 000000000..47c58572f --- /dev/null +++ b/src/boost/libs/hana/test/detail/type_foldl1.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +template +struct f { + struct type; +}; + +template +struct x; + +static_assert(std::is_same< + hana::detail::type_foldl1>::type, + x<0> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>>::type, + f, x<1>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>, x<2>>::type, + f, x<1>>::type, x<2>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>, x<2>, x<3>>::type, + f, x<1>>::type, x<2>>::type, x<3>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>, x<2>, x<3>, x<4>>::type, + f, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + f, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + f, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type, x<6>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + f, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type, x<6>>::type, x<7>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldl1, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>>::type, + f, x<1>>::type, x<2>>::type, x<3>>::type, x<4>>::type, x<5>>::type, x<6>>::type, x<7>>::type, x<8>>::type +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/type_foldr1.cpp b/src/boost/libs/hana/test/detail/type_foldr1.cpp new file mode 100644 index 000000000..eefa6a99f --- /dev/null +++ b/src/boost/libs/hana/test/detail/type_foldr1.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +template +struct f { + struct type; +}; + +template +struct x; + +static_assert(std::is_same< + hana::detail::type_foldr1>::type, + x<0> +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>>::type, + f, x<1>>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>, x<2>>::type, + f, f, x<2>>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>, x<2>, x<3>>::type, + f, f, f, x<3>>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>, x<2>, x<3>, x<4>>::type, + f, f, f, f, x<4>>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>, x<2>, x<3>, x<4>, x<5>>::type, + f, f, f, f, f, x<5>>::type>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>>::type, + f, f, f, f, f, f, x<6>>::type>::type>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>>::type, + f, f, f, f, f, f, f, x<7>>::type>::type>::type>::type>::type>::type>::type +>{}, ""); + +static_assert(std::is_same< + hana::detail::type_foldr1, x<1>, x<2>, x<3>, x<4>, x<5>, x<6>, x<7>, x<8>>::type, + f, f, f, f, f, f, f, f, x<8>>::type>::type>::type>::type>::type>::type>::type>::type +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/detail/unpack_flatten.cpp b/src/boost/libs/hana/test/detail/unpack_flatten.cpp new file mode 100644 index 000000000..d6002c964 --- /dev/null +++ b/src/boost/libs/hana/test/detail/unpack_flatten.cpp @@ -0,0 +1,114 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + constexpr auto f = hana::test::_injection<0>{}; + + { + auto tuples = hana::make_tuple(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple()); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), hana::make_tuple()); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), + hana::make_tuple(), + hana::make_tuple()); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f() + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), + hana::make_tuple(ct_eq<0>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(), + hana::make_tuple(ct_eq<0>{}, ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + } + + { + auto tuples = hana::make_tuple(hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}, ct_eq<3>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::detail::unpack_flatten(tuples, f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } +} diff --git a/src/boost/libs/hana/test/detail/variadic/at.cpp b/src/boost/libs/hana/test/detail/variadic/at.cpp new file mode 100644 index 000000000..ddb4bddc4 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/at.cpp @@ -0,0 +1,93 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#include +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +struct non_pod { virtual ~non_pod() { } }; + +template struct y { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, ct_eq<1>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}), + ct_eq<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}), + ct_eq<2>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}, y<3>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}, y<3>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}, y<3>{}), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<3>(y<0>{}, y<1>{}, y<2>{}, ct_eq<3>{}), + ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<0>(ct_eq<0>{}, y<1>{}, y<2>{}, y<3>{}, y<4>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<1>(y<0>{}, ct_eq<1>{}, y<2>{}, y<3>{}, y<4>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<2>(y<0>{}, y<1>{}, ct_eq<2>{}, y<3>{}, y<4>{}), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<3>(y<0>{}, y<1>{}, y<2>{}, ct_eq<3>{}, y<4>{}), + ct_eq<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::at<4>(y<0>{}, y<1>{}, y<2>{}, y<3>{}, ct_eq<4>{}), + ct_eq<4>{} + )); + + // make sure we can use non-pods on both side of the fetched object + vd::at<0>(ct_eq<0>{}, non_pod{}); + vd::at<1>(non_pod{}, ct_eq<1>{}); + + // make sure it works with const objects + int const i = 1; + vd::at<0>(i); +} diff --git a/src/boost/libs/hana/test/detail/variadic/drop_into.cpp b/src/boost/libs/hana/test/detail/variadic/drop_into.cpp new file mode 100644 index 000000000..8c4aecb5d --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/drop_into.cpp @@ -0,0 +1,78 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#include +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +struct non_pod { virtual ~non_pod() { } }; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(ct_eq<0>{}), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<0>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<1>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::drop_into<2>(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + f(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + + // make sure we can use non-pods + vd::drop_into<1>(f)(ct_eq<0>{}, non_pod{}); + vd::drop_into<1>(f)(non_pod{}, ct_eq<1>{}); +} diff --git a/src/boost/libs/hana/test/detail/variadic/foldl1.cpp b/src/boost/libs/hana/test/detail/variadic/foldl1.cpp new file mode 100644 index 000000000..e0ded2c88 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/foldl1.cpp @@ -0,0 +1,212 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +struct undefined { }; + +template +using x = hana::test::ct_eq; + +int main() { + using hana::detail::variadic::foldl1; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(undefined{}, x<1>{}), + x<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}), + f(x<1>{}, x<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}), + f(f(x<1>{}, x<2>{}), x<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}), + f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), + f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}), + f(f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}), + f(f(f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, x<8>{}), + f(f(f(f(f(f(f(x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), x<8>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{} + ), + f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}), x<30>{}), x<31>{}), x<32>{}), x<33>{}), x<34>{}), x<35>{}), + x<36>{}), x<37>{}), x<38>{}), x<39>{}), x<40>{}), x<41>{}), x<42>{}), + x<43>{}), x<44>{}), x<45>{}), x<46>{}), x<47>{}), x<48>{}), x<49>{}), + x<50>{}), x<51>{}), x<52>{}), x<53>{}), x<54>{}), x<55>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}), x<30>{}), x<31>{}), x<32>{}), x<33>{}), x<34>{}), x<35>{}), + x<36>{}), x<37>{}), x<38>{}), x<39>{}), x<40>{}), x<41>{}), x<42>{}), + x<43>{}), x<44>{}), x<45>{}), x<46>{}), x<47>{}), x<48>{}), x<49>{}), + x<50>{}), x<51>{}), x<52>{}), x<53>{}), x<54>{}), x<55>{}), x<56>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldl1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}, + x<57>{} + ), + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f( + x<1>{}, x<2>{}), x<3>{}), x<4>{}), x<5>{}), x<6>{}), x<7>{}), + x<8>{}), x<9>{}), x<10>{}), x<11>{}), x<12>{}), x<13>{}), x<14>{}), + x<15>{}), x<16>{}), x<17>{}), x<18>{}), x<19>{}), x<20>{}), x<21>{}), + x<22>{}), x<23>{}), x<24>{}), x<25>{}), x<26>{}), x<27>{}), x<28>{}), + x<29>{}), x<30>{}), x<31>{}), x<32>{}), x<33>{}), x<34>{}), x<35>{}), + x<36>{}), x<37>{}), x<38>{}), x<39>{}), x<40>{}), x<41>{}), x<42>{}), + x<43>{}), x<44>{}), x<45>{}), x<46>{}), x<47>{}), x<48>{}), x<49>{}), + x<50>{}), x<51>{}), x<52>{}), x<53>{}), x<54>{}), x<55>{}), x<56>{}), + x<57>{}) + )); +} diff --git a/src/boost/libs/hana/test/detail/variadic/foldr1.cpp b/src/boost/libs/hana/test/detail/variadic/foldr1.cpp new file mode 100644 index 000000000..1d7d91ed6 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/foldr1.cpp @@ -0,0 +1,207 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct undefined { }; + +template +using x = hana::test::ct_eq; + +// We do not use test::_injection here because comparing the result would +// blow away the template recursion limit. +struct f_t { + template + constexpr auto operator()(X const&, Y const&) { + return x() - hana::value()>{}; + } +}; + +int main() { + using hana::detail::variadic::foldr1; + f_t f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(undefined{}, x<0>{}), + x<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}), + f(x<0>{}, x<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}), + f(x<0>{}, f(x<1>{}, x<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, x<3>{}))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, x<4>{})))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, x<5>{}))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, x<6>{})))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, x<7>{} + ))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<0>{}, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, x<8>{}), + f(x<0>{}, f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, x<8>{} + )))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, x<13>{} + )))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, x<14>{} + ))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, x<15>{} + )))))))))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, x<27>{} + )))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, x<28>{} + ))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + x<29>{} + )))))))))))))))))))))))))))) + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, x<55>{} + )))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, f(x<55>{}, x<56>{} + ))))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + foldr1(f, x<1>{}, x<2>{}, x<3>{}, x<4>{}, x<5>{}, x<6>{}, x<7>{}, + x<8>{}, x<9>{}, x<10>{}, x<11>{}, x<12>{}, x<13>{}, x<14>{}, + x<15>{}, x<16>{}, x<17>{}, x<18>{}, x<19>{}, x<20>{}, x<21>{}, + x<22>{}, x<23>{}, x<24>{}, x<25>{}, x<26>{}, x<27>{}, x<28>{}, + x<29>{}, x<30>{}, x<31>{}, x<32>{}, x<33>{}, x<34>{}, x<35>{}, + x<36>{}, x<37>{}, x<38>{}, x<39>{}, x<40>{}, x<41>{}, x<42>{}, + x<43>{}, x<44>{}, x<45>{}, x<46>{}, x<47>{}, x<48>{}, x<49>{}, + x<50>{}, x<51>{}, x<52>{}, x<53>{}, x<54>{}, x<55>{}, x<56>{}, + x<57>{}), + f(x<1>{}, f(x<2>{}, f(x<3>{}, f(x<4>{}, f(x<5>{}, f(x<6>{}, f(x<7>{}, + f(x<8>{}, f(x<9>{}, f(x<10>{}, f(x<11>{}, f(x<12>{}, f(x<13>{}, f(x<14>{}, + f(x<15>{}, f(x<16>{}, f(x<17>{}, f(x<18>{}, f(x<19>{}, f(x<20>{}, f(x<21>{}, + f(x<22>{}, f(x<23>{}, f(x<24>{}, f(x<25>{}, f(x<26>{}, f(x<27>{}, f(x<28>{}, + f(x<29>{}, f(x<30>{}, f(x<31>{}, f(x<32>{}, f(x<33>{}, f(x<34>{}, f(x<35>{}, + f(x<36>{}, f(x<37>{}, f(x<38>{}, f(x<39>{}, f(x<40>{}, f(x<41>{}, f(x<42>{}, + f(x<43>{}, f(x<44>{}, f(x<45>{}, f(x<46>{}, f(x<47>{}, f(x<48>{}, f(x<49>{}, + f(x<50>{}, f(x<51>{}, f(x<52>{}, f(x<53>{}, f(x<54>{}, f(x<55>{}, f(x<56>{}, + x<57>{} + )))))))))))))))))))))))))))))))))))))))))))))))))))))))) + )); +} diff --git a/src/boost/libs/hana/test/detail/variadic/reverse_apply.cpp b/src/boost/libs/hana/test/detail/variadic/reverse_apply.cpp new file mode 100644 index 000000000..60305f3a7 --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/reverse_apply.cpp @@ -0,0 +1,70 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +auto check = [](auto reverse_apply) { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + f(ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}), + f(ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}), + f(ct_eq<6>{}, ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + f(ct_eq<7>{}, ct_eq<6>{}, ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + reverse_apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + f(ct_eq<8>{}, ct_eq<7>{}, ct_eq<6>{}, ct_eq<5>{}, ct_eq<4>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{}, ct_eq<0>{}) + )); +}; + +int main() { + check(hana::detail::variadic::reverse_apply); + check([](auto f, auto ...x) { + return hana::detail::variadic::reverse_apply_flat(f, x...); + }); + check([](auto f, auto ...x) { + return hana::detail::variadic::reverse_apply_unrolled(f, x...); + }); +} diff --git a/src/boost/libs/hana/test/detail/variadic/split_at.cpp b/src/boost/libs/hana/test/detail/variadic/split_at.cpp new file mode 100644 index 000000000..e33872a5b --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/split_at.cpp @@ -0,0 +1,168 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +auto check = [](auto split, auto xs, auto ys) { + auto result = split([](auto ...xs) { + return [=](auto ...ys) { + return hana::make_pair(hana::make_tuple(xs...), hana::make_tuple(ys...)); + }; + }); + + BOOST_HANA_CONSTANT_CHECK(hana::equal(xs, hana::first(result))); + BOOST_HANA_CONSTANT_CHECK(hana::equal(ys, hana::second(result))); +}; + +int main() { + { + check( + vd::split_at<0>(), + hana::make_tuple(), + hana::make_tuple() + ); + + check( + vd::split_at<0>(ct_eq<1>{}), + hana::make_tuple(), + hana::make_tuple(ct_eq<1>{}) + ); + + check( + vd::split_at<0>(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}) + ); + + check( + vd::split_at<0>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_tuple(), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + ); + } + { + check( + vd::split_at<1>(ct_eq<1>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple() + ); + + check( + vd::split_at<1>(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}) + ); + + check( + vd::split_at<1>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}, ct_eq<3>{}) + ); + + check( + vd::split_at<1>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::make_tuple(ct_eq<1>{}), + hana::make_tuple(ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + ); + } + { + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple() + ); + + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}) + ); + + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}) + ); + + check( + vd::split_at<2>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + ); + } + { + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple() + ); + + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<8>{}) + ); + + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<8>{}, ct_eq<9>{}) + ); + + check( + vd::split_at<7>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}), + hana::make_tuple(ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}) + ); + } + { + check( + vd::split_at<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple() + ); + + check( + vd::split_at<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<9>{}) + ); + + check( + vd::split_at<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}), + hana::make_tuple(ct_eq<9>{}, ct_eq<10>{}) + ); + } + { + check( + vd::split_at<9>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple() + ); + + check( + vd::split_at<9>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<10>{}) + ); + + check( + vd::split_at<9>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}, ct_eq<10>{}, ct_eq<11>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{}), + hana::make_tuple(ct_eq<10>{}, ct_eq<11>{}) + ); + } +} diff --git a/src/boost/libs/hana/test/detail/variadic/take.cpp b/src/boost/libs/hana/test/detail/variadic/take.cpp new file mode 100644 index 000000000..031c6baea --- /dev/null +++ b/src/boost/libs/hana/test/detail/variadic/take.cpp @@ -0,0 +1,62 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#include +namespace hana = boost::hana; +namespace vd = hana::detail::variadic; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<0>()(f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<0>(ct_eq<1>{})(f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<0>(ct_eq<1>{}, ct_eq<2>{})(f), + f() + )); + } + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<1>(ct_eq<1>{})(f), + f(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<1>(ct_eq<1>{}, ct_eq<2>{})(f), + f(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<1>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})(f), + f(ct_eq<1>{}) + )); + } + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{})(f), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + vd::take<8>(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}, ct_eq<9>{})(f), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}, ct_eq<6>{}, ct_eq<7>{}, ct_eq<8>{}) + )); + } +} diff --git a/src/boost/libs/hana/test/euclidean_ring.cpp b/src/boost/libs/hana/test/euclidean_ring.cpp new file mode 100644 index 000000000..2653fe7eb --- /dev/null +++ b/src/boost/libs/hana/test/euclidean_ring.cpp @@ -0,0 +1,28 @@ +// 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 +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::TestEuclideanRing{hana::make_tuple(0,1,2,3,4,5)}; + hana::test::TestEuclideanRing{hana::make_tuple(0l,1l,2l,3l,4l,5l)}; + + // div + { + static_assert(hana::div(6, 4) == 6 / 4, ""); + static_assert(hana::div(7, -3) == 7 / -3, ""); + } + + // mod + { + static_assert(hana::mod(6, 4) == 6 % 4, ""); + static_assert(hana::mod(7, -3) == 7 % -3, ""); + } +} 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 +#include +#include +#include +#include + +#include +#include +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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + +namespace foo { + template struct my_template { }; + template struct my_mf { struct type; }; + struct my_mf_class { template struct apply { struct type; }; }; +} + +int main() { + { + std::ostringstream ss; + ss << hana::experimental::print( + hana::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 + ); + 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 + ); + 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 +#include +#include +#include + +#include +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 +#include +#include +#include + +#include +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 +#include +#include +#include +#include + +#include +#include +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 +#include +#include + +#include +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 +#include +#include + +#include +#include +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 +#include + +#include +namespace hana = boost::hana; + + +template +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) << std::endl; + + std::cout << hana::experimental::print(hana::type_c) << std::endl; + + std::cout << hana::experimental::print(hana::type_c) << std::endl; + + std::cout << hana::experimental::print(hana::type_c) << std::endl; + + std::cout << hana::experimental::print(hana::type_c) << std::endl; + + std::cout << hana::experimental::print(hana::type_c) << std::endl; + + std::cout << hana::experimental::print(hana::type_c>) << 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 +#include +#include +#include + +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct Template { }; + +template +void check_matches(std::string const& re) { + std::string name = hana::to(hana::experimental::type_name()); + 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(), + BOOST_HANA_STRING("void") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::experimental::type_name(), + BOOST_HANA_STRING("int") + )); + + // Make sure we get something reasonable + check_matches("int const|const int"); + check_matches(R"(int\s*&)"); + check_matches(R"(const\s+int\s*&|int\s+const\s*&)"); + check_matches(R"(int\s*\(\s*&\s*\)\s*\[\s*\])"); + check_matches(R"(int\s*\(\s*&\s*\)\s*\[\s*10\s*\])"); + check_matches>(R"(Template<\s*void\s*,\s*(char const|const char)\s*\*\s*>)"); + check_matches(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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template struct x; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types>{}), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types, x<1>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types, x<1>>{}), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types, x<1>, x<2>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types, x<1>, x<2>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(hana::experimental::types, x<1>, x<2>>{}), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types, x<1>, x<2>, x<3>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types, x<1>, x<2>, x<3>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(hana::experimental::types, x<1>, x<2>, x<3>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<3>(hana::experimental::types, x<1>, x<2>, x<3>>{}), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<0>(hana::experimental::types, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<1>(hana::experimental::types, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<2>(hana::experimental::types, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<3>(hana::experimental::types, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_c<4>(hana::experimental::types, x<1>, x<2>, x<3>, x<4>>{}), + hana::type_c> + )); +} 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template 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>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types>{}, + hana::type_c> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types, x<1>>{}, + hana::type_c> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>, x<2>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>, x<2>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>, x<2>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types, x<1>, x<2>>{}, + hana::type_c> + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>, x<2>, x<3>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>, x<2>, x<3>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>, x<2>, x<3>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::experimental::types, x<1>, x<2>, x<3>>{}, + hana::type_c> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::experimental::types, x<1>, x<2>, x<3>>{}, + hana::type_c> + ))); +} 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template 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>{}, 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>{}, hana::size_c<2>), + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>>{}, hana::size_c<0>), + hana::experimental::types, x<1>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>>{}, hana::size_c<1>), + hana::experimental::types>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>>{}, hana::size_c<2>), + hana::experimental::types<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>>{}, hana::size_c<3>), + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>>{}, hana::size_c<0>), + hana::experimental::types, x<1>, x<2>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>>{}, hana::size_c<1>), + hana::experimental::types, x<2>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>>{}, hana::size_c<2>), + hana::experimental::types>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>>{}, hana::size_c<3>), + hana::experimental::types<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>>{}, hana::size_c<4>), + hana::experimental::types<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>, x<3>>{}, hana::size_c<0>), + hana::experimental::types, x<1>, x<2>, x<3>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>, x<3>>{}, hana::size_c<1>), + hana::experimental::types, x<2>, x<3>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>, x<3>>{}, hana::size_c<2>), + hana::experimental::types, x<3>>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, x<1>, x<2>, x<3>>{}, hana::size_c<3>), + hana::experimental::types>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::experimental::types, 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<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 +#include +#include +#include +namespace hana = boost::hana; + + +template 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>{}, + hana::experimental::types>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::experimental::types, x<1>, x<2>>{}, + hana::experimental::types, x<1>, x<2>>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types<>{}, + hana::experimental::types>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types>{}, + hana::experimental::types<>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types>{}, + hana::experimental::types>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types, x<1>, x<2>>{}, + hana::experimental::types, x<1>, x<3>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types, x<1>, x<2>>{}, + hana::experimental::types, x<1>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::experimental::types, x<1>, x<2>>{}, + hana::experimental::types, 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 +#include +#include +#include +namespace hana = boost::hana; + + +template 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>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::experimental::types, x<1>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::experimental::types, x<1>, x<2>>{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::experimental::types, 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct mf { struct type; }; + +template 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>{}, hana::metafunction), + hana::experimental::types>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types, x<1>>{}, hana::metafunction), + hana::experimental::types>::type, mf>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types, x<1>, x<2>>{}, hana::metafunction), + hana::experimental::types>::type, mf>::type, mf>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types, x<1>, x<2>, x<3>>{}, hana::metafunction), + hana::experimental::types>::type, mf>::type, mf>::type, mf>::type>{} + )); + } + + // with a non-Metafunction + { + auto f = [](auto t) { + return hana::metafunction(t); + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types>{}, f), + hana::experimental::types>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types, x<1>>{}, f), + hana::experimental::types>::type, mf>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types, x<1>, x<2>>{}, f), + hana::experimental::types>::type, mf>::type, mf>::type>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::experimental::types, x<1>, x<2>, x<3>>{}, f), + hana::experimental::types>::type, mf>::type, mf>::type, mf>::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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +struct mf { struct type; }; + +template struct x; + +int main() { + // with a Metafunction + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types<>{}, hana::metafunction), + hana::type_c::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types>{}, hana::metafunction), + hana::type_c>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types, x<1>>{}, hana::metafunction), + hana::type_c, x<1>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types, x<1>, x<2>>{}, hana::metafunction), + hana::type_c, x<1>, x<2>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types, x<1>, x<2>, x<3>>{}, hana::metafunction), + hana::type_c, x<1>, x<2>, x<3>>::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types, x<1>, x<2>, x<3>, x<4>>{}, hana::metafunction), + hana::type_c, 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>{}, f), + f(hana::type_c>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types, x<1>>{}, f), + f(hana::type_c>, hana::type_c>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types, x<1>, x<2>>{}, f), + f(hana::type_c>, hana::type_c>, hana::type_c>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::experimental::types, x<1>, x<2>, x<3>>{}, f), + f(hana::type_c>, hana::type_c>, hana::type_c>, hana::type_c>) + )); + } +} 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 +#include +#include +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 +#include +#include +#include +#include +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 +#include +#include +#include + +#include +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 +#include +#include +#include +#include + +#include +#include +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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template 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 +#include +#include +#include + +#include +#include +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 +#include +#include +#include +#include + +#include +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 +#include +#include +#include +namespace hana = boost::hana; + + +template 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template 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 +#include +#include +#include + +#include +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 +#include +#include +#include +#include +#include + +#include +#include +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); + 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); + 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); + 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); + 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); + 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); + 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); + 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto storage = container(); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); + }{ + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); + }{ + auto storage = container(undefined<0>{}, undefined<1>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(sliced)); + } + + { + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(sliced))); + }{ + auto storage = container(undefined<0>{}); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + 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); + 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 +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template struct undefined { }; + +int main() { + auto container = ::seq; + + { + auto storage = container(); + auto sliced = hana::experimental::sliced(storage, hana::tuple_c); + 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); + 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); + 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); + 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); + 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); + 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 +#include +#include +#include +#include + +#include +#include +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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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); + 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 +#include +#include +#include +#include + +#include +#include +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 +#include +#include +#include + +#include +#include +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 +#include +#include +#include +#include + +#include +#include +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 +#include +#include +#include +#include + +#include +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 +#include +#include +#include + +#include +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 + +#include +#include +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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template 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 +#include +#include +#include + +#include +#include +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 +#include +#include +#include + +#include +#include +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 +#include +#include +#include + +#include +#include +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>{}); +} diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/_specs.hpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/_specs.hpp new file mode 100644 index 000000000..6734967af --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/_specs.hpp @@ -0,0 +1,18 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_EXT_BOOST_FUSION_DEQUE_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_EXT_BOOST_FUSION_DEQUE_AUTO_SPECS_HPP + +#include + +#include +#include + + +#define MAKE_TUPLE(...) ::boost::fusion::make_deque(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::fusion::deque<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::ext::boost::fusion::deque_tag + +#endif // !BOOST_HANA_TEST_EXT_BOOST_FUSION_DEQUE_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/all_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/any_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/ap.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/cartesian_product.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/for_each.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/group.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/index_if.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/intersperse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/is_empty.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/length.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/make.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/none_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/partition.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/permutations.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/permutations.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/reverse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/scans.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sequence.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/slice.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sort.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/span.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/transform.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unfolds.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unique.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/zips.cpp b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/deque/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/_specs.hpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/_specs.hpp new file mode 100644 index 000000000..1bc300cf6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/_specs.hpp @@ -0,0 +1,18 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_EXT_BOOST_FUSION_LIST_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_EXT_BOOST_FUSION_LIST_AUTO_SPECS_HPP + +#include + +#include +#include + + +#define MAKE_TUPLE(...) ::boost::fusion::make_list(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::fusion::list<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::ext::boost::fusion::list_tag + +#endif // !BOOST_HANA_TEST_EXT_BOOST_FUSION_LIST_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/all_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/any_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/ap.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/cartesian_product.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/for_each.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/group.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/index_if.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/intersperse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/is_empty.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/length.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/make.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/none_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/partition.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/permutations.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/permutations.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/reverse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/scans.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/sequence.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/slice.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/sort.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/span.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/transform.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/unfolds.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/unique.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/list/auto/zips.cpp b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/list/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/_specs.hpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/_specs.hpp new file mode 100644 index 000000000..5024efc4c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/_specs.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_EXT_BOOST_FUSION_TUPLE_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_EXT_BOOST_FUSION_TUPLE_AUTO_SPECS_HPP + +#define FUSION_MAX_VECTOR_SIZE 50 +#include + +#include + + +#define MAKE_TUPLE(...) ::boost::fusion::make_tuple(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::fusion::tuple<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::ext::boost::fusion::tuple_tag +#define MAKE_TUPLE_NO_CONSTEXPR + +#endif // !BOOST_HANA_TEST_EXT_BOOST_FUSION_TUPLE_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/all_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/any_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/ap.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/cartesian_product.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/for_each.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/group.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/index_if.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/intersperse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/is_empty.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/length.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/make.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/none_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/partition.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/permutations.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/permutations.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/reverse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/scans.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sequence.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/slice.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sort.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/span.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/transform.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unfolds.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unique.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/zips.cpp b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/tuple/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/_specs.hpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/_specs.hpp new file mode 100644 index 000000000..3b87a1d8e --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/_specs.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_EXT_BOOST_FUSION_VECTOR_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_EXT_BOOST_FUSION_VECTOR_AUTO_SPECS_HPP + +#define FUSION_MAX_VECTOR_SIZE 50 +#include + +#include +#include + +#define MAKE_TUPLE(...) ::boost::fusion::make_vector(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::fusion::vector<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::ext::boost::fusion::vector_tag +#define MAKE_TUPLE_NO_CONSTEXPR + +#endif // !BOOST_HANA_TEST_EXT_BOOST_FUSION_VECTOR_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/all_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/any_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/ap.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/cartesian_product.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/for_each.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/group.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/index_if.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/intersperse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/is_empty.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/length.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/make.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/none_of.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/partition.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/permutations.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/permutations.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_at.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_range.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/reverse.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/scans.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sequence.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/slice.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sort.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/span.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_back.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_front.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_while.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/transform.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unfolds.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unique.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/zips.cpp b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/fusion/vector/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/mpl/integral_c/arithmetic.cpp b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/arithmetic.cpp new file mode 100644 index 000000000..0dfef3713 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/arithmetic.cpp @@ -0,0 +1,30 @@ +// 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 + +#include + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +int main() { + auto ints = hana::make_tuple( + mpl::int_<-10>{}, mpl::int_<-2>{}, mpl::integral_c{}, + mpl::integral_c{}, mpl::integral_c{} + ); + + hana::test::TestMonoid>{ints}; + hana::test::TestGroup>{ints}; + hana::test::TestRing>{ints}; + hana::test::TestEuclideanRing>{ints}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/integral_c/comparable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/comparable.cpp new file mode 100644 index 000000000..60a0e5be5 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/comparable.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 + +#include + +#include +#include + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +int main() { + auto ints = hana::make_tuple( + mpl::int_<-10>{}, mpl::int_<-2>{}, mpl::integral_c{}, + mpl::integral_c{}, mpl::integral_c{} + ); + + hana::test::TestComparable>{ints}; + hana::test::TestHashable>{ints}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/integral_c/constant.cpp b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/constant.cpp new file mode 100644 index 000000000..6831d6cf9 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/constant.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#include + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +int main() { + // value + static_assert(hana::value(mpl::integral_c{}) == 0, ""); + static_assert(hana::value(mpl::integral_c{}) == 1, ""); + static_assert(hana::value(mpl::integral_c{}) == 3, ""); + + // laws + hana::test::TestConstant>{ + hana::make_tuple( + mpl::int_<-10>{}, mpl::int_<-2>{}, mpl::integral_c{}, + mpl::integral_c{}, mpl::integral_c{} + ), + hana::tuple_t + }; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/integral_c/interop.cpp b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/interop.cpp new file mode 100644 index 000000000..949e477d7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/interop.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 + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +int main() { + // Interoperation with hana::integral_constant + BOOST_HANA_CONSTANT_CHECK(mpl::integral_c{} == hana::int_c<1>); + BOOST_HANA_CONSTANT_CHECK(mpl::integral_c{} == hana::long_c<1>); + + BOOST_HANA_CONSTANT_CHECK(mpl::integral_c{} != hana::int_c<3>); +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/integral_c/logical.cpp b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/logical.cpp new file mode 100644 index 000000000..10c0e19a1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/logical.cpp @@ -0,0 +1,66 @@ +// 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 + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +int main() { + // eval_if + { + auto t = hana::test::ct_eq<3>{}; + auto e = hana::test::ct_eq<4>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(mpl::true_{}, hana::always(t), hana::always(e)), + t + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(mpl::false_{}, hana::always(t), hana::always(e)), + e + )); + } + + // not_ + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::not_(mpl::true_{}), + mpl::false_{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::not_(mpl::false_{}), + mpl::true_{} + )); + } + + // laws + hana::test::TestLogical>{ + hana::make_tuple( + mpl::int_<-2>{}, mpl::integral_c{}, mpl::integral_c{} + ) + }; + + hana::test::TestLogical>{ + hana::make_tuple( + mpl::true_{}, mpl::false_{}, + mpl::integral_c{}, mpl::integral_c{} + ) + }; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/integral_c/orderable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/orderable.cpp new file mode 100644 index 000000000..24ee5b752 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/orderable.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 + +#include + +#include + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +int main() { + auto ints = hana::make_tuple( + mpl::int_<-10>{}, mpl::int_<-2>{}, mpl::integral_c{}, + mpl::integral_c{}, mpl::integral_c{} + ); + + hana::test::TestOrderable>{ints}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/integral_c/tag.cpp b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/tag.cpp new file mode 100644 index 000000000..55b33a8c0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/integral_c/tag.cpp @@ -0,0 +1,52 @@ +// 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 + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::integral_c_tag +>::value, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::integral_c_tag +>::value, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::integral_c_tag +>::value, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::integral_c_tag +>::value, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::integral_c_tag +>::value, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::integral_c_tag +>::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/mpl/list/comparable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/list/comparable.cpp new file mode 100644 index 000000000..fd13b5309 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/list/comparable.cpp @@ -0,0 +1,28 @@ +// 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 + +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + auto lists = hana::make_tuple( + mpl::list<>{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + ); + + hana::test::TestComparable{lists}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/list/foldable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/list/foldable.cpp new file mode 100644 index 000000000..1c4697771 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/list/foldable.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 + +#include +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + // unpack + { + hana::test::_injection<0> f{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::list<>{}, f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::list{}, f), + f(hana::type_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::list{}, f), + f(hana::type_c, hana::type_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::list{}, f), + f(hana::type_c, hana::type_c, hana::type_c) + )); + } + + // laws + auto lists = hana::make_tuple( + mpl::list<>{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + ); + + hana::test::TestFoldable{lists}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/list/iterable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/list/iterable.cpp new file mode 100644 index 000000000..68a900ee1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/list/iterable.cpp @@ -0,0 +1,95 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + // front + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(mpl::list{}), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(mpl::list{}), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(mpl::list{}), + hana::type_c + )); + } + + // drop_front_exactly + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::list{}), + mpl::list<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::list{}), + mpl::list{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::list{}), + mpl::list{} + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::list{}, hana::size_c<2>), + mpl::list{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::list{}, hana::size_c<2>), + mpl::list{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::list{}, hana::size_c<3>), + mpl::list{} + )); + } + + // is_empty + { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(mpl::list<>{})); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(mpl::list0<>{})); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list{}))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list1{}))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list{}))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::list2{}))); + } + + // laws + auto lists = hana::make_tuple( + mpl::list<>{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + ); + hana::test::TestIterable{lists}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/list/searchable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/list/searchable.cpp new file mode 100644 index 000000000..50b3a15e1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/list/searchable.cpp @@ -0,0 +1,30 @@ +// 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 + +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + auto lists = hana::make_tuple( + mpl::list<>{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + , mpl::list{} + ); + + auto keys = hana::tuple_t; + + hana::test::TestSearchable{lists, keys}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/list/tag.cpp b/src/boost/libs/hana/test/ext/boost/mpl/list/tag.cpp new file mode 100644 index 000000000..3cfc26ae8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/list/tag.cpp @@ -0,0 +1,62 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +using mpl_id = mpl::quote1; + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::list_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t::type>, + hana::ext::boost::mpl::list_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t, mpl_id>::type>, + hana::ext::boost::mpl::list_tag +>{}, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::list_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t::type>, + hana::ext::boost::mpl::list_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t, mpl_id>::type>, + hana::ext::boost::mpl::list_tag +>{}, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::list_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t::type>, + hana::ext::boost::mpl::list_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t, mpl_id>::type>, + hana::ext::boost::mpl::list_tag +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/mpl/list/to.cpp b/src/boost/libs/hana/test/ext/boost/mpl/list/to.cpp new file mode 100644 index 000000000..bd8808af4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/list/to.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 + +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + // Conversion from any `Foldable` containing `type`s + auto foldable = ::seq; + auto to_list = hana::to; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_list(foldable()), + mpl::list<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_list(foldable(hana::type_c)), + mpl::list{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_list(foldable(hana::type_c, hana::type_c)), + mpl::list{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_list(foldable(hana::type_c, hana::type_c, hana::type_c)), + mpl::list{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_list(foldable(hana::type_c, hana::type_c, hana::type_c, hana::type_c)), + mpl::list{} + )); +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/vector/comparable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/vector/comparable.cpp new file mode 100644 index 000000000..55557f31b --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/vector/comparable.cpp @@ -0,0 +1,28 @@ +// 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 + +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + auto vectors = hana::make_tuple( + mpl::vector<>{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + ); + + hana::test::TestComparable{vectors}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/vector/foldable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/vector/foldable.cpp new file mode 100644 index 000000000..4143cd58c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/vector/foldable.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 + +#include +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + // unpack + { + hana::test::_injection<0> f{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::vector<>{}, f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::vector{}, f), + f(hana::type_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::vector{}, f), + f(hana::type_c, hana::type_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(mpl::vector{}, f), + f(hana::type_c, hana::type_c, hana::type_c) + )); + } + + // laws + auto vectors = hana::make_tuple( + mpl::vector<>{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + ); + + hana::test::TestFoldable{vectors}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/vector/iterable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/vector/iterable.cpp new file mode 100644 index 000000000..08090af7b --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/vector/iterable.cpp @@ -0,0 +1,95 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + // front + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(mpl::vector{}), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(mpl::vector{}), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(mpl::vector{}), + hana::type_c + )); + } + + // drop_front_exactly + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::vector{}), + mpl::vector<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::vector{}), + mpl::vector{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::vector{}), + mpl::vector{} + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::vector{}, hana::size_c<2>), + mpl::vector{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::vector{}, hana::size_c<2>), + mpl::vector{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(mpl::vector{}, hana::size_c<3>), + mpl::vector{} + )); + } + + // is_empty + { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(mpl::vector<>{})); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(mpl::vector0<>{})); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::vector{}))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::vector1{}))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::vector{}))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(mpl::vector2{}))); + } + + // laws + auto vectors = hana::make_tuple( + mpl::vector<>{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + ); + hana::test::TestIterable{vectors}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/vector/searchable.cpp b/src/boost/libs/hana/test/ext/boost/mpl/vector/searchable.cpp new file mode 100644 index 000000000..58a0dd068 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/vector/searchable.cpp @@ -0,0 +1,30 @@ +// 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 + +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + auto vectors = hana::make_tuple( + mpl::vector<>{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + , mpl::vector{} + ); + + auto keys = hana::tuple_t; + + hana::test::TestSearchable{vectors, keys}; +} diff --git a/src/boost/libs/hana/test/ext/boost/mpl/vector/tag.cpp b/src/boost/libs/hana/test/ext/boost/mpl/vector/tag.cpp new file mode 100644 index 000000000..892f119b2 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/vector/tag.cpp @@ -0,0 +1,62 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +using mpl_id = mpl::quote1; + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::vector_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t::type>, + hana::ext::boost::mpl::vector_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t, mpl_id>::type>, + hana::ext::boost::mpl::vector_tag +>{}, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::vector_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t::type>, + hana::ext::boost::mpl::vector_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t, mpl_id>::type>, + hana::ext::boost::mpl::vector_tag +>{}, ""); + +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::boost::mpl::vector_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t::type>, + hana::ext::boost::mpl::vector_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t, mpl_id>::type>, + hana::ext::boost::mpl::vector_tag +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/mpl/vector/to.cpp b/src/boost/libs/hana/test/ext/boost/mpl/vector/to.cpp new file mode 100644 index 000000000..0ebb6d47c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/mpl/vector/to.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 + +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; +namespace mpl = boost::mpl; + + +struct t1; struct t2; struct t3; struct t4; + +int main() { + // Conversion from any `Foldable` containing `type`s + auto foldable = ::seq; + auto to_vector = hana::to; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_vector(foldable()), + mpl::vector<>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_vector(foldable(hana::type_c)), + mpl::vector{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_vector(foldable(hana::type_c, hana::type_c)), + mpl::vector{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_vector(foldable(hana::type_c, hana::type_c, hana::type_c)), + mpl::vector{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + to_vector(foldable(hana::type_c, hana::type_c, hana::type_c, hana::type_c)), + mpl::vector{} + )); +} diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/_specs.hpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/_specs.hpp new file mode 100644 index 000000000..3d1ff41ab --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/_specs.hpp @@ -0,0 +1,18 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_EXT_BOOST_TUPLE_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_EXT_BOOST_TUPLE_AUTO_SPECS_HPP + +#include + +#include + + +#define MAKE_TUPLE(...) ::boost::make_tuple(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::tuple<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::ext::boost::tuple_tag +#define MAKE_TUPLE_NO_CONSTEXPR + +#endif // !BOOST_HANA_TEST_EXT_BOOST_TUPLE_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/all_of.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/any_of.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/ap.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/at.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/cartesian_product.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_back.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_front.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_while.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/for_each.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/group.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/index_if.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/insert.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/insert_range.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/intersperse.broken.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/intersperse.broken.cpp new file mode 100644 index 000000000..88d5d356e --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/intersperse.broken.cpp @@ -0,0 +1,10 @@ +// 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) + +#if 0 +#include "_specs.hpp" +#include +#endif + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/is_empty.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/length.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/make.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/none_of.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/partition.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/permutations.broken.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/permutations.broken.cpp new file mode 100644 index 000000000..0b505bf33 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/permutations.broken.cpp @@ -0,0 +1,10 @@ +// 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) + +#if 0 +#include "_specs.hpp" +#include +#endif + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/remove_at.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/remove_range.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/reverse.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/scans.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/sequence.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/slice.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/sort.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/span.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/take_back.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/take_front.broken.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/take_front.broken.cpp new file mode 100644 index 000000000..f155b3865 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/take_front.broken.cpp @@ -0,0 +1,10 @@ +// 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) + +#if 0 +#include "_specs.hpp" +#include +#endif + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/take_while.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/transform.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/unfolds.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/unique.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/auto/zips.cpp b/src/boost/libs/hana/test/ext/boost/tuple/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/boost/tuple/iterable.cpp b/src/boost/libs/hana/test/ext/boost/tuple/iterable.cpp new file mode 100644 index 000000000..d74a355dd --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/iterable.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 + +#include + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +using eq = hana::test::ct_eq; + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Setup for the laws below + ////////////////////////////////////////////////////////////////////////// + auto eq_tuples = hana::make_tuple( + ::boost::make_tuple() + , ::boost::make_tuple(eq<0>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}, eq<2>{}) + ); + + ////////////////////////////////////////////////////////////////////////// + // Foldable, Iterable + ////////////////////////////////////////////////////////////////////////// + hana::test::TestFoldable{eq_tuples}; + hana::test::TestIterable{eq_tuples}; +} diff --git a/src/boost/libs/hana/test/ext/boost/tuple/monad.cpp b/src/boost/libs/hana/test/ext/boost/tuple/monad.cpp new file mode 100644 index 000000000..b7af39136 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/monad.cpp @@ -0,0 +1,52 @@ +// 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 + +#include + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +using eq = hana::test::ct_eq; + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Setup for the laws below + ////////////////////////////////////////////////////////////////////////// + auto eq_tuples = hana::make_tuple( + ::boost::make_tuple() + , ::boost::make_tuple(eq<0>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}) + ); + + auto eq_values = hana::make_tuple(eq<0>{}, eq<2>{}); + + auto eq_tuples_tuples = hana::make_tuple( + ::boost::make_tuple() + , ::boost::make_tuple( + ::boost::make_tuple(eq<0>{})) + , ::boost::make_tuple( + ::boost::make_tuple(eq<0>{}), + ::boost::make_tuple(eq<1>{}, eq<2>{})) + , ::boost::make_tuple( + ::boost::make_tuple(eq<0>{}), + ::boost::make_tuple(eq<1>{}, eq<2>{}), + ::boost::make_tuple(eq<3>{}, eq<4>{})) + ); + + ////////////////////////////////////////////////////////////////////////// + // Functor up to Monad + ////////////////////////////////////////////////////////////////////////// + hana::test::TestFunctor{eq_tuples, eq_values}; + hana::test::TestApplicative{eq_tuples}; + hana::test::TestMonad{eq_tuples, eq_tuples_tuples}; +} diff --git a/src/boost/libs/hana/test/ext/boost/tuple/monad_plus.cpp b/src/boost/libs/hana/test/ext/boost/tuple/monad_plus.cpp new file mode 100644 index 000000000..ca6b51589 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/monad_plus.cpp @@ -0,0 +1,42 @@ +// 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 + +#include +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +template +using eq = hana::test::ct_eq; + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Setup for the laws below + ////////////////////////////////////////////////////////////////////////// + auto eq_tuples = hana::make_tuple( + ::boost::make_tuple(eq<0>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}, eq<2>{}) + ); + + auto eq_values = hana::make_tuple(eq<0>{}, eq<1>{}, eq<2>{}); + auto predicates = hana::make_tuple( + hana::equal.to(eq<0>{}), hana::equal.to(eq<1>{}), hana::equal.to(eq<2>{}), + hana::always(hana::false_c), hana::always(hana::true_c) + ); + + ////////////////////////////////////////////////////////////////////////// + // MonadPlus + ////////////////////////////////////////////////////////////////////////// + hana::test::TestMonadPlus{eq_tuples, predicates, eq_values}; +} diff --git a/src/boost/libs/hana/test/ext/boost/tuple/orderable.cpp b/src/boost/libs/hana/test/ext/boost/tuple/orderable.cpp new file mode 100644 index 000000000..661fad13b --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/orderable.cpp @@ -0,0 +1,47 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +template +using eq = hana::test::ct_eq; + +template +using ord = hana::test::ct_ord; + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Setup for the laws below + ////////////////////////////////////////////////////////////////////////// + auto eq_tuples = hana::make_tuple( + ::boost::make_tuple() + , ::boost::make_tuple(eq<0>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}, eq<2>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}, eq<2>{}, eq<3>{}, eq<4>{}) + ); + + auto ord_tuples = hana::make_tuple( + ::boost::make_tuple() + , ::boost::make_tuple(ord<0>{}) + , ::boost::make_tuple(ord<0>{}, ord<1>{}) + , ::boost::make_tuple(ord<0>{}, ord<1>{}, ord<2>{}) + , ::boost::make_tuple(ord<0>{}, ord<1>{}, ord<2>{}, ord<3>{}, ord<4>{}) + ); + + ////////////////////////////////////////////////////////////////////////// + // Comparable and Orderable + ////////////////////////////////////////////////////////////////////////// + hana::test::TestComparable{eq_tuples}; + hana::test::TestOrderable{ord_tuples}; +} diff --git a/src/boost/libs/hana/test/ext/boost/tuple/searchable.cpp b/src/boost/libs/hana/test/ext/boost/tuple/searchable.cpp new file mode 100644 index 000000000..08b4b78d1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/searchable.cpp @@ -0,0 +1,54 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +template +using eq = hana::test::ct_eq; + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Setup for the laws below + ////////////////////////////////////////////////////////////////////////// + auto eq_tuples = hana::make_tuple( + ::boost::make_tuple() + , ::boost::make_tuple(eq<0>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}) + , ::boost::make_tuple(eq<0>{}, eq<1>{}, eq<2>{}) + ); + + auto eq_tuple_keys = hana::make_tuple( + eq<3>{}, eq<5>{}, eq<7>{} + ); + + ////////////////////////////////////////////////////////////////////////// + // Searchable + ////////////////////////////////////////////////////////////////////////// + { + hana::test::TestSearchable{eq_tuples, eq_tuple_keys}; + + auto bools = hana::make_tuple( + ::boost::make_tuple(hana::true_c) + , ::boost::make_tuple(hana::false_c) + , ::boost::make_tuple(hana::true_c, hana::true_c) + , ::boost::make_tuple(hana::true_c, hana::false_c) + , ::boost::make_tuple(hana::false_c, hana::true_c) + , ::boost::make_tuple(hana::false_c, hana::false_c) + ); + hana::test::TestSearchable{ + bools, + hana::make_tuple(hana::true_c, hana::false_c) + }; + } +} diff --git a/src/boost/libs/hana/test/ext/boost/tuple/tag_of.cpp b/src/boost/libs/hana/test/ext/boost/tuple/tag_of.cpp new file mode 100644 index 000000000..831bb8a7c --- /dev/null +++ b/src/boost/libs/hana/test/ext/boost/tuple/tag_of.cpp @@ -0,0 +1,63 @@ +// 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 +#include + +#include + +#include +namespace hana = boost::hana; + + +int main() { + ////////////////////////////////////////////////////////////////////////// + // make sure the tag is correct + ////////////////////////////////////////////////////////////////////////// + { + auto make_cons = [](auto x, auto xs) { + return boost::tuples::cons{x, xs}; + }; + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + + static_assert(std::is_same< + hana::tag_of_t, + hana::ext::boost::tuple_tag + >::value, ""); + } +} diff --git a/src/boost/libs/hana/test/ext/std/array/at.cpp b/src/boost/libs/hana/test/ext/std/array/at.cpp new file mode 100644 index 000000000..90ed1f5b7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/at.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 + +#include +#include + +#include // for move_only + +#include +namespace hana = boost::hana; + + +int main() { + // Check non-const lvalue reference + { + std::array arr = {{999, 888}}; + int& i = hana::at_c<0>(arr); + BOOST_HANA_RUNTIME_CHECK(i == 999); + arr[0] = 333; + BOOST_HANA_RUNTIME_CHECK(i == 333); + i = 444; + BOOST_HANA_RUNTIME_CHECK(arr[0] == 444); + } + + // Check const lvalue reference + { + std::array arr = {{999, 888}}; + int const& i = hana::at_c<0>(static_cast const&>(arr)); + BOOST_HANA_RUNTIME_CHECK(i == 999); + arr[0] = 333; + BOOST_HANA_RUNTIME_CHECK(i == 333); + } + + // Check move-only types + { + std::array arr{}; + hana::test::move_only m = hana::at_c<0>(std::move(arr)); + (void)m; + } +} diff --git a/src/boost/libs/hana/test/ext/std/array/comparable.cpp b/src/boost/libs/hana/test/ext/std/array/comparable.cpp new file mode 100644 index 000000000..d0596fa6c --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/comparable.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 + +#include + +#include + +#include +namespace hana = boost::hana; + + +template +constexpr auto array() { return std::array{{i...}}; } + +int main() { + auto int_arrays = hana::make_tuple( + array<>() + , array<0>() + , array<0, 1>() + , array<0, 1, 2>() + , array<0, 1, 2, 3>() + , array<0, 1, 2, 3, 4>() + ); + + hana::test::TestComparable{int_arrays}; +} diff --git a/src/boost/libs/hana/test/ext/std/array/foldable.cpp b/src/boost/libs/hana/test/ext/std/array/foldable.cpp new file mode 100644 index 000000000..b36e9521f --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/foldable.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 + +#include + +#include + +#include +namespace hana = boost::hana; + + +template +constexpr auto array() { return std::array{{i...}}; } + +int main() { + auto int_arrays = hana::make_tuple( + array<>() + , array<0>() + , array<0, 1>() + , array<0, 1, 2>() + , array<0, 1, 2, 3>() + , array<0, 1, 2, 3, 4>() + ); + + hana::test::TestFoldable{int_arrays}; +} diff --git a/src/boost/libs/hana/test/ext/std/array/issue_304.cpp b/src/boost/libs/hana/test/ext/std/array/issue_304.cpp new file mode 100644 index 000000000..321f18f27 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/issue_304.cpp @@ -0,0 +1,21 @@ +// 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) +// modified from https://github.com/boostorg/hana/issues/304 + +#include +#include + +namespace hana = boost::hana; + +struct Foo +{ + Foo() = default; + Foo(Foo const&) = delete; + Foo(Foo &&) = default; +}; + +using bar = decltype(hana::to_tuple(std::array())); + +int main() +{ } diff --git a/src/boost/libs/hana/test/ext/std/array/iterable.cpp b/src/boost/libs/hana/test/ext/std/array/iterable.cpp new file mode 100644 index 000000000..38bd7731d --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/iterable.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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +template +constexpr auto array() { return std::array{{i...}}; } + +int main() { + // is_empty + { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(array<>())); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(array<0>()))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(array<0, 1>()))); + } + + // front + { + BOOST_HANA_CONSTEXPR_CHECK(hana::front(array<0>()) == 0); + BOOST_HANA_CONSTEXPR_CHECK(hana::front(array<0, 1>()) == 0); + BOOST_HANA_CONSTEXPR_CHECK(hana::front(array<0, 1, 2>()) == 0); + } + + // drop_front_exactly + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(array<0>()), + array<>() + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::drop_front_exactly(array<0, 1>()), + array<1>() + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::drop_front_exactly(array<0, 1, 2>()), + array<1, 2>() + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::drop_front_exactly(array<0, 1, 2, 3>()), + array<1, 2, 3>() + )); + + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::drop_front_exactly(array<0, 1, 2, 3>(), hana::size_c<2>), + array<2, 3>() + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::drop_front_exactly(array<0, 1, 2, 3>(), hana::size_c<3>), + array<3>() + )); + } + + // laws + auto int_arrays = hana::make_tuple( + array<>() + , array<0>() + , array<0, 1>() + , array<0, 1, 2>() + , array<0, 1, 2, 3>() + , array<0, 1, 2, 3, 4>() + ); + + hana::test::TestIterable{int_arrays}; +} diff --git a/src/boost/libs/hana/test/ext/std/array/orderable.cpp b/src/boost/libs/hana/test/ext/std/array/orderable.cpp new file mode 100644 index 000000000..ced9ab6b4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/orderable.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 + +#include + +#include + +#include +namespace hana = boost::hana; + + +template +constexpr auto array() { return std::array{{i...}}; } + +int main() { + auto int_arrays = hana::make_tuple( + array<>() + , array<0>() + , array<0, 1>() + , array<0, 1, 2>() + , array<0, 1, 2, 3>() + , array<0, 1, 2, 3, 4>() + ); + + hana::test::TestOrderable{int_arrays}; +} diff --git a/src/boost/libs/hana/test/ext/std/array/searchable.cpp b/src/boost/libs/hana/test/ext/std/array/searchable.cpp new file mode 100644 index 000000000..1ba584fde --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/array/searchable.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 + +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +template +constexpr auto array() { return std::array{{i...}}; } + +int main() { + auto eq_arrays = hana::make_tuple( + std::array, 0>{} + , std::array, 1>{} + , std::array, 2>{} + , std::array, 3>{} + , std::array, 4>{} + ); + + auto eq_keys = hana::make_tuple(hana::test::ct_eq<0>{}); + + hana::test::TestSearchable{eq_arrays, eq_keys}; +} diff --git a/src/boost/libs/hana/test/ext/std/bugs/libcxx_19616.cpp b/src/boost/libs/hana/test/ext/std/bugs/libcxx_19616.cpp new file mode 100644 index 000000000..2b91f88ad --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/bugs/libcxx_19616.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // Make sure we workaround the bug at: + // http://llvm.org/bugs/show_bug.cgi?id=19616 + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::lift(std::make_tuple(1)), + std::make_tuple(std::make_tuple(1)) + )); +} diff --git a/src/boost/libs/hana/test/ext/std/bugs/libcxx_22806.cpp b/src/boost/libs/hana/test/ext/std/bugs/libcxx_22806.cpp new file mode 100644 index 000000000..281481086 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/bugs/libcxx_22806.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 +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +int main() { + using M = hana::ext::std::tuple_tag; + auto m = std::make_tuple(hana::test::ct_eq<0>{}); + auto f = hana::compose(hana::lift, hana::test::_injection<0>{}); + hana::chain(m, hana::compose(hana::lift, f)); +} diff --git a/src/boost/libs/hana/test/ext/std/integer_sequence/drop_front_exactly.cpp b/src/boost/libs/hana/test/ext/std/integer_sequence/drop_front_exactly.cpp new file mode 100644 index 000000000..a9556ccb7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integer_sequence/drop_front_exactly.cpp @@ -0,0 +1,44 @@ +// 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(std::index_sequence<0>{}), + std::index_sequence<>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(std::index_sequence<0, 1>{}), + std::index_sequence<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(std::index_sequence<0, 1, 2>{}), + std::index_sequence<1, 2>{} + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(std::index_sequence<0, 1, 2>{}, hana::size_c<2>), + std::index_sequence<2>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(std::index_sequence<0, 1, 2, 3>{}, hana::size_c<2>), + std::index_sequence<2, 3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(std::index_sequence<0, 1, 2, 3>{}, hana::size_c<3>), + std::index_sequence<3>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/integer_sequence/equal.cpp b/src/boost/libs/hana/test/ext/std/integer_sequence/equal.cpp new file mode 100644 index 000000000..7249d234d --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integer_sequence/equal.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +using T = int; +using U = long long; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + std::integer_sequence{}, + std::integer_sequence{} + ))); +} diff --git a/src/boost/libs/hana/test/ext/std/integer_sequence/find_if.cpp b/src/boost/libs/hana/test/ext/std/integer_sequence/find_if.cpp new file mode 100644 index 000000000..4c904ed65 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integer_sequence/find_if.cpp @@ -0,0 +1,101 @@ +// 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 +#include +#include +#include +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +struct undefined { }; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<>{}, + hana::equal.to(undefined{})), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0>{}, + hana::equal.to(std::integral_constant{})), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1>{}, + hana::equal.to(std::integral_constant{})), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2>{}, + hana::equal.to(std::integral_constant{})), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2, 3>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2, 3>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2, 3>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2, 3>{}, + hana::equal.to(std::integral_constant{})), + hana::just(std::integral_constant{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(std::index_sequence<0, 1, 2, 3>{}, + hana::equal.to(std::integral_constant{})), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/ext/std/integer_sequence/front.cpp b/src/boost/libs/hana/test/ext/std/integer_sequence/front.cpp new file mode 100644 index 000000000..69372c99b --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integer_sequence/front.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 +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(std::index_sequence<0>{}), + std::integral_constant{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(std::index_sequence<0, 1>{}), + std::integral_constant{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(std::integer_sequence{}), + std::integral_constant{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/integer_sequence/is_empty.cpp b/src/boost/libs/hana/test/ext/std/integer_sequence/is_empty.cpp new file mode 100644 index 000000000..b6c79c755 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integer_sequence/is_empty.cpp @@ -0,0 +1,18 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(std::index_sequence<>{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(std::index_sequence<0>{}))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(std::index_sequence<1>{}))); +} diff --git a/src/boost/libs/hana/test/ext/std/integer_sequence/laws.cpp b/src/boost/libs/hana/test/ext/std/integer_sequence/laws.cpp new file mode 100644 index 000000000..8cc7fcc43 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integer_sequence/laws.cpp @@ -0,0 +1,37 @@ +// 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 +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +auto sequences = hana::make_tuple( + std::integer_sequence{}, + std::integer_sequence{}, + std::integer_sequence{}, + std::integer_sequence{}, + std::integer_sequence{} +); + +auto keys = hana::make_tuple( + std::integral_constant{}, std::integral_constant{} +); + +int main() { + hana::test::TestComparable{sequences}; + hana::test::TestFoldable{sequences}; + hana::test::TestIterable{sequences}; + hana::test::TestSearchable{sequences, keys}; +} diff --git a/src/boost/libs/hana/test/ext/std/integer_sequence/unpack.cpp b/src/boost/libs/hana/test/ext/std/integer_sequence/unpack.cpp new file mode 100644 index 000000000..5ef9320c8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integer_sequence/unpack.cpp @@ -0,0 +1,47 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include + +#include +#include +namespace hana = boost::hana; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(std::integer_sequence{}, f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(std::integer_sequence{}, f), + f(std::integral_constant{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(std::integer_sequence{}, f), + f(std::integral_constant{}, std::integral_constant{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(std::integer_sequence{}, f), + f(std::integral_constant{}, std::integral_constant{}, + std::integral_constant{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(std::integer_sequence{}, f), + f(std::integral_constant{}, std::integral_constant{}, + std::integral_constant{}, std::integral_constant{}) + )); +} diff --git a/src/boost/libs/hana/test/ext/std/integral_constant/arithmetic.cpp b/src/boost/libs/hana/test/ext/std/integral_constant/arithmetic.cpp new file mode 100644 index 000000000..25372ddd5 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integral_constant/arithmetic.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 + +#include + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto ints = hana::make_tuple( + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{} + ); + + hana::test::TestMonoid>{ints}; + hana::test::TestGroup>{ints}; + hana::test::TestRing>{ints}; + hana::test::TestEuclideanRing>{ints}; +} diff --git a/src/boost/libs/hana/test/ext/std/integral_constant/comparable.cpp b/src/boost/libs/hana/test/ext/std/integral_constant/comparable.cpp new file mode 100644 index 000000000..d17b6d810 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integral_constant/comparable.cpp @@ -0,0 +1,27 @@ +// 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 + +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto ints = hana::make_tuple( + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{} + ); + + hana::test::TestComparable>{ints}; + hana::test::TestHashable>{ints}; +} diff --git a/src/boost/libs/hana/test/ext/std/integral_constant/constant.cpp b/src/boost/libs/hana/test/ext/std/integral_constant/constant.cpp new file mode 100644 index 000000000..f15fb8e80 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integral_constant/constant.cpp @@ -0,0 +1,33 @@ +// 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 + +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +int main() { + // value + static_assert(hana::value(std::integral_constant{}) == 0, ""); + static_assert(hana::value(std::integral_constant{}) == 1, ""); + static_assert(hana::value(std::integral_constant{}) == 3, ""); + + // laws + hana::test::TestConstant>{ + hana::make_tuple( + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{} + ), + hana::tuple_t + }; +} diff --git a/src/boost/libs/hana/test/ext/std/integral_constant/interop.cpp b/src/boost/libs/hana/test/ext/std/integral_constant/interop.cpp new file mode 100644 index 000000000..9b445f01b --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integral_constant/interop.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 + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // Interoperation with hana::integral_constant + BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} == hana::int_c<1>); + BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} == hana::long_c<1>); + + BOOST_HANA_CONSTANT_CHECK(std::integral_constant{} != hana::int_c<3>); +} diff --git a/src/boost/libs/hana/test/ext/std/integral_constant/logical.cpp b/src/boost/libs/hana/test/ext/std/integral_constant/logical.cpp new file mode 100644 index 000000000..38d8091c2 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integral_constant/logical.cpp @@ -0,0 +1,63 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // eval_if + { + auto t = hana::test::ct_eq<3>{}; + auto e = hana::test::ct_eq<4>{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(std::true_type{}, hana::always(t), hana::always(e)), + t + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(std::false_type{}, hana::always(t), hana::always(e)), + e + )); + } + + // not_ + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::not_(std::true_type{}), + std::false_type{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::not_(std::false_type{}), + std::true_type{} + )); + } + + auto ints = hana::make_tuple( + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{} + ); + + auto bools = hana::make_tuple(std::true_type{}, std::false_type{}); + + // laws + hana::test::TestLogical>{ints}; + hana::test::TestLogical>{bools}; +} diff --git a/src/boost/libs/hana/test/ext/std/integral_constant/orderable.cpp b/src/boost/libs/hana/test/ext/std/integral_constant/orderable.cpp new file mode 100644 index 000000000..6a14ad147 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integral_constant/orderable.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 + +#include + +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto ints = hana::make_tuple( + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{}, + std::integral_constant{} + ); + + hana::test::TestOrderable>{ints}; +} diff --git a/src/boost/libs/hana/test/ext/std/integral_constant/tag.cpp b/src/boost/libs/hana/test/ext/std/integral_constant/tag.cpp new file mode 100644 index 000000000..8a747e441 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/integral_constant/tag.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 + +#include + +#include +namespace hana = boost::hana; + + +struct inherit_simple : std::integral_constant { }; +struct inherit_no_default : std::integral_constant { + inherit_no_default() = delete; +}; + +struct incomplete; +struct empty_type { }; +struct non_pod { virtual ~non_pod() { } }; + + +static_assert(std::is_same< + hana::tag_of_t, + hana::ext::std::integral_constant_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t, + hana::ext::std::integral_constant_tag +>{}, ""); +static_assert(std::is_same< + hana::tag_of_t>, + hana::ext::std::integral_constant_tag +>{}, ""); + +static_assert(!std::is_same< + hana::tag_of_t, + hana::ext::std::integral_constant_tag +>{}, ""); +static_assert(!std::is_same< + hana::tag_of_t, + hana::ext::std::integral_constant_tag +>{}, ""); +static_assert(!std::is_same< + hana::tag_of_t, + hana::ext::std::integral_constant_tag +>{}, ""); +static_assert(!std::is_same< + hana::tag_of_t, + hana::ext::std::integral_constant_tag +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/pair/first_second.cpp b/src/boost/libs/hana/test/ext/std/pair/first_second.cpp new file mode 100644 index 000000000..a44ed1cc3 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/pair/first_second.cpp @@ -0,0 +1,30 @@ +// 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 +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + // first + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::first(std::make_pair(ct_eq<0>{}, ct_eq<1>{})), + ct_eq<0>{} + )); + + // second + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::second(std::make_pair(ct_eq<0>{}, ct_eq<1>{})), + ct_eq<1>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/pair/issue_90.cpp b/src/boost/libs/hana/test/ext/std/pair/issue_90.cpp new file mode 100644 index 000000000..d8f70c56e --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/pair/issue_90.cpp @@ -0,0 +1,44 @@ +// 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 +#include +#include + +#include +namespace hana = boost::hana; + + +template +T const& cref(T& t) { return t; } + +// a non-movable, non-copyable type +template +struct RefOnly { + RefOnly() = default; + RefOnly(RefOnly const&) = delete; + RefOnly(RefOnly&&) = delete; +}; + +int main() { + // This test makes sure that we return the proper reference types from + // `first` and `second`. + std::pair, RefOnly<1>> p; + + { + RefOnly<0>&& r1 = hana::first(std::move(p)); + RefOnly<0>& r2 = hana::first(p); + RefOnly<0> const& r3 = hana::first(cref(p)); + + (void)r1; (void)r2; (void)r3; + } + + { + RefOnly<1>&& r1 = hana::second(std::move(p)); + RefOnly<1>& r2 = hana::second(p); + RefOnly<1> const& r3 = hana::second(cref(p)); + + (void)r1; (void)r2; (void)r3; + } +} diff --git a/src/boost/libs/hana/test/ext/std/pair/laws.cpp b/src/boost/libs/hana/test/ext/std/pair/laws.cpp new file mode 100644 index 000000000..869001ab6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/pair/laws.cpp @@ -0,0 +1,41 @@ +// 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 +#include + +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; +using hana::test::ct_ord; + + +int main() { + auto eq_elems = hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}); + + auto eqs = hana::make_tuple( + std::make_pair(ct_eq<3>{}, ct_eq<3>{}) + , std::make_pair(ct_eq<3>{}, ct_eq<4>{}) + , std::make_pair(ct_eq<4>{}, ct_eq<3>{}) + , std::make_pair(ct_eq<4>{}, ct_eq<4>{}) + ); + + auto ords = hana::make_tuple( + std::make_pair(ct_ord<3>{}, ct_ord<3>{}) + , std::make_pair(ct_ord<3>{}, ct_ord<4>{}) + , std::make_pair(ct_ord<4>{}, ct_ord<3>{}) + , std::make_pair(ct_ord<4>{}, ct_ord<4>{}) + ); + + hana::test::TestComparable{eqs}; + hana::test::TestOrderable{ords}; + hana::test::TestFoldable{eqs}; + hana::test::TestProduct{eq_elems}; +} diff --git a/src/boost/libs/hana/test/ext/std/pair/make.cpp b/src/boost/libs/hana/test/ext/std/pair/make.cpp new file mode 100644 index 000000000..f0cb9d297 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/pair/make.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 +#include +#include + +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(ct_eq<0>{}, ct_eq<1>{}), + std::make_pair(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(ct_eq<3>{}, ct_eq<4>{}), + std::make_pair(ct_eq<3>{}, ct_eq<4>{}) + )); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/div.cpp b/src/boost/libs/hana/test/ext/std/ratio/div.cpp new file mode 100644 index 000000000..327717fcb --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/div.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::div(std::ratio<6>{}, std::ratio<4>{}), + std::ratio<6, 4>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::div(std::ratio<3, 4>{}, std::ratio<5, 10>{}), + std::ratio<3*10, 4*5>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/equal.cpp b/src/boost/libs/hana/test/ext/std/ratio/equal.cpp new file mode 100644 index 000000000..f72ec8980 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/equal.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + std::ratio<0>{}, + std::ratio<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + std::ratio<3>{}, + std::ratio<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + std::ratio<3, 5>{}, + std::ratio<6, 10>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + std::ratio<4, 5>{}, + std::ratio<6, 10>{} + ))); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/laws.cpp b/src/boost/libs/hana/test/ext/std/ratio/laws.cpp new file mode 100644 index 000000000..460fe3c81 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/laws.cpp @@ -0,0 +1,37 @@ +// 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 +#include + +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto ratios = hana::make_tuple( + std::ratio<0>{} + , std::ratio<1, 3>{} + , std::ratio<1, 2>{} + , std::ratio<2, 6>{} + , std::ratio<3, 1>{} + , std::ratio<7, 8>{} + , std::ratio<3, 5>{} + , std::ratio<2, 1>{} + ); + + hana::test::TestComparable{ratios}; + hana::test::TestOrderable{ratios}; + hana::test::TestMonoid{ratios}; + hana::test::TestGroup{ratios}; + hana::test::TestRing{ratios}; + hana::test::TestEuclideanRing{ratios}; +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/less.cpp b/src/boost/libs/hana/test/ext/std/ratio/less.cpp new file mode 100644 index 000000000..79e8dbc42 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/less.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::less( + std::ratio<1>{}, + std::ratio<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + std::ratio<4, 10>{}, + std::ratio<3, 5>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + std::ratio<3, 5>{}, + std::ratio<4, 10>{} + ))); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/minus.cpp b/src/boost/libs/hana/test/ext/std/ratio/minus.cpp new file mode 100644 index 000000000..9a6bc4199 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/minus.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minus(std::ratio<3, 4>{}, std::ratio<5, 10>{}), + std::ratio<3*10 - 5*4, 4*10>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/mod.cpp b/src/boost/libs/hana/test/ext/std/ratio/mod.cpp new file mode 100644 index 000000000..24c748eb3 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/mod.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::mod(std::ratio<6>{}, std::ratio<4>{}), + std::ratio<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::mod(std::ratio<3, 4>{}, std::ratio<5, 10>{}), + std::ratio<0>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/mult.cpp b/src/boost/libs/hana/test/ext/std/ratio/mult.cpp new file mode 100644 index 000000000..5f345bf2f --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/mult.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::mult(std::ratio<3, 4>{}, std::ratio<5, 10>{}), + std::ratio<3*5, 4*10>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/one.cpp b/src/boost/libs/hana/test/ext/std/ratio/one.cpp new file mode 100644 index 000000000..a05ac1be1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/one.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::one(), + std::ratio<1, 1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::one(), + std::ratio<2, 2>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/plus.cpp b/src/boost/libs/hana/test/ext/std/ratio/plus.cpp new file mode 100644 index 000000000..33a47bd9d --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/plus.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::plus(std::ratio<3, 4>{}, std::ratio<5, 10>{}), + std::ratio<3*10 + 5*4, 4*10>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/to.cpp b/src/boost/libs/hana/test/ext/std/ratio/to.cpp new file mode 100644 index 000000000..2795c990a --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/to.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 +#include +#include +#include + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +int main() { + // Conversion from a Constant to a std::ratio + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(cnumeric), + std::ratio<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(cnumeric), + std::ratio<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(cnumeric), + std::ratio<3>{} + )); + } +} diff --git a/src/boost/libs/hana/test/ext/std/ratio/zero.cpp b/src/boost/libs/hana/test/ext/std/ratio/zero.cpp new file mode 100644 index 000000000..af0fa1711 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/ratio/zero.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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zero(), + std::ratio<0, 1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zero(), + std::ratio<0, 2>{} + )); +} diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/_specs.hpp b/src/boost/libs/hana/test/ext/std/tuple/auto/_specs.hpp new file mode 100644 index 000000000..c165d4214 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/_specs.hpp @@ -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) + +#ifndef BOOST_HANA_TEST_EXT_STD_TUPLE_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_EXT_STD_TUPLE_AUTO_SPECS_HPP + +#include + +#include + + +#define MAKE_TUPLE(...) ::std::make_tuple(__VA_ARGS__) +#define TUPLE_TYPE(...) ::std::tuple<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::ext::std::tuple_tag + +#endif // !BOOST_HANA_TEST_EXT_STD_TUPLE_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/all_of.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/any_of.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/ap.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/at.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/cartesian_product.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/drop_back.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/drop_front.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/drop_while.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/for_each.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/group.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/index_if.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/insert.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/insert_range.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/intersperse.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/is_empty.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/length.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/make.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/none_of.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/partition.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/permutations.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/permutations.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/remove_at.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/remove_range.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/reverse.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/scans.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/sequence.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/slice.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/sort.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/span.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/take_back.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/take_front.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/take_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/take_while.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/transform.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/unfolds.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/unique.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/auto/zips.cpp b/src/boost/libs/hana/test/ext/std/tuple/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/ext/std/tuple/issue_90.cpp b/src/boost/libs/hana/test/ext/std/tuple/issue_90.cpp new file mode 100644 index 000000000..dfbb4a7fc --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/issue_90.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 +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +T const& cref(T& t) { return t; } + +// a non-movable, non-copyable type +struct RefOnly { + RefOnly() = default; + RefOnly(RefOnly const&) = delete; + RefOnly(RefOnly&&) = delete; +}; + +template +struct RefOnly_i : hana::int_ { + RefOnly_i() = default; + RefOnly_i(RefOnly_i const&) = delete; + RefOnly_i(RefOnly_i&&) = delete; +}; + +int main() { + std::tuple t; + + // Make sure that we return the proper reference types from `at`. + { + RefOnly&& r1 = hana::at_c<0>(std::move(t)); + RefOnly& r2 = hana::at_c<0>(t); + RefOnly const& r3 = hana::at_c<0>(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `front`. + { + RefOnly&& r1 = hana::front(std::move(t)); + RefOnly& r2 = hana::front(t); + RefOnly const& r3 = hana::front(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `back`. + { + RefOnly&& r1 = hana::back(std::move(t)); + RefOnly& r2 = hana::back(t); + RefOnly const& r3 = hana::back(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `at_key`. + { + std::tuple> t{}; + RefOnly_i<3>& r1 = hana::at_key(t, RefOnly_i<3>{}); + RefOnly_i<3> const& r2 = hana::at_key(cref(t), RefOnly_i<3>{}); + RefOnly_i<3>&& r3 = hana::at_key(std::move(t), RefOnly_i<3>{}); + + (void)r1; (void)r2; (void)r3; + } +} diff --git a/src/boost/libs/hana/test/ext/std/tuple/laws.cpp b/src/boost/libs/hana/test/ext/std/tuple/laws.cpp new file mode 100644 index 000000000..4c56bc8ee --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/laws.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 +#include + +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; +using hana::test::ct_ord; + + +int main() { + auto eq_tuples = hana::make_tuple( + std::make_tuple() + , std::make_tuple(ct_eq<0>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + ); + + auto ord_tuples = hana::make_tuple( + std::make_tuple() + , std::make_tuple(ct_ord<0>{}) + , std::make_tuple(ct_ord<0>{}, ct_ord<1>{}) + , std::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) + , std::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}, ct_ord<4>{}) + ); + + hana::test::TestComparable{eq_tuples}; + hana::test::TestOrderable{ord_tuples}; + hana::test::TestFoldable{eq_tuples}; + hana::test::TestIterable{eq_tuples}; + hana::test::TestSequence{}; +} diff --git a/src/boost/libs/hana/test/ext/std/tuple/laws.functor.cpp b/src/boost/libs/hana/test/ext/std/tuple/laws.functor.cpp new file mode 100644 index 000000000..874d01f9b --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/laws.functor.cpp @@ -0,0 +1,55 @@ +// 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto tuples = hana::make_tuple( + std::make_tuple() + , std::make_tuple(ct_eq<0>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + ); + + auto values = hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + + auto nested_tuples = hana::make_tuple( + std::make_tuple() + , std::make_tuple( + std::make_tuple(ct_eq<0>{})) + , std::make_tuple( + std::make_tuple(ct_eq<0>{}), + std::make_tuple(ct_eq<1>{}, ct_eq<2>{})) + , std::make_tuple( + std::make_tuple(ct_eq<0>{}), + std::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + std::make_tuple(ct_eq<3>{}, ct_eq<4>{})) + ); + + auto predicates = hana::make_tuple( + hana::equal.to(ct_eq<0>{}), hana::equal.to(ct_eq<1>{}), hana::equal.to(ct_eq<2>{}), + hana::always(hana::false_c), hana::always(hana::true_c) + ); + + hana::test::TestFunctor{tuples, values}; + hana::test::TestApplicative{tuples}; + hana::test::TestMonad{tuples, nested_tuples}; + hana::test::TestMonadPlus{tuples, predicates, values}; +} diff --git a/src/boost/libs/hana/test/ext/std/tuple/laws.searchable.cpp b/src/boost/libs/hana/test/ext/std/tuple/laws.searchable.cpp new file mode 100644 index 000000000..7eb6b42b9 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/tuple/laws.searchable.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 +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto tuples = hana::make_tuple( + std::make_tuple() + , std::make_tuple(ct_eq<0>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , std::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + ); + auto keys = hana::make_tuple(ct_eq<3>{}, ct_eq<5>{}, ct_eq<7>{}); + + auto bool_tuples = hana::make_tuple( + std::make_tuple(hana::true_c) + , std::make_tuple(hana::false_c) + , std::make_tuple(hana::true_c, hana::true_c) + , std::make_tuple(hana::true_c, hana::false_c) + , std::make_tuple(hana::false_c, hana::true_c) + , std::make_tuple(hana::false_c, hana::false_c) + ); + auto bool_keys = hana::make_tuple(hana::true_c, hana::false_c); + + hana::test::TestSearchable{tuples, keys}; + hana::test::TestSearchable{bool_tuples, bool_keys}; +} diff --git a/src/boost/libs/hana/test/ext/std/vector.cpp b/src/boost/libs/hana/test/ext/std/vector.cpp new file mode 100644 index 000000000..1e9e7cde1 --- /dev/null +++ b/src/boost/libs/hana/test/ext/std/vector.cpp @@ -0,0 +1,44 @@ +// 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 + +#include +#include + +#include +#include +// #include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto eqs = hana::make_tuple( + std::vector>{0} + , std::vector>{1} + , std::vector>{2} + , std::vector>{3} + , std::vector>{4} + ); + + // auto eq_values = hana::make_tuple(hana::test::eq<0>{}, hana::test::eq<2>{}); + + auto ords = hana::make_tuple( + std::vector>{0} + , std::vector>{1} + , std::vector>{2} + , std::vector>{3} + , std::vector>{4} + ); + + ////////////////////////////////////////////////////////////////////////// + // Comparable, Orderable, Functor + ////////////////////////////////////////////////////////////////////////// + hana::test::TestComparable{eqs}; + hana::test::TestOrderable{ords}; + // hana::test::TestFunctor{eqs, eq_values}; +} diff --git a/src/boost/libs/hana/test/fold_left/ref.cpp b/src/boost/libs/hana/test/fold_left/ref.cpp new file mode 100644 index 000000000..a2b34ad6d --- /dev/null +++ b/src/boost/libs/hana/test/fold_left/ref.cpp @@ -0,0 +1,40 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + +// +// Make sure that we can fold_left and take arguments by reference. +// + +int main() { + // with state + { + auto xs = hana::make_tuple(1, 2, 3); + int state = 99; + + int& three = hana::fold_left(xs, state, [](int&, int& i) -> int& { + return i; + }); + BOOST_HANA_RUNTIME_CHECK(three == 3); + three = 10; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(xs) == 10); + } + + // without state + { + auto xs = hana::make_tuple(1, 2, 3); + + int& three = hana::fold_left(xs, [](int&, int& i) -> int& { + return i; + }); + BOOST_HANA_RUNTIME_CHECK(three == 3); + three = 10; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(xs) == 10); + } +} diff --git a/src/boost/libs/hana/test/fold_right/ref.cpp b/src/boost/libs/hana/test/fold_right/ref.cpp new file mode 100644 index 000000000..e23cd5211 --- /dev/null +++ b/src/boost/libs/hana/test/fold_right/ref.cpp @@ -0,0 +1,39 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + +// +// Make sure that we can fold_right and take arguments by reference. +// + +int main() { + // with state + { + auto xs = hana::make_tuple(1, 2, 3); + int state = 99; + + int& one = hana::fold_right(xs, state, [](int& i, int&) -> int& { + return i; + }); + BOOST_HANA_RUNTIME_CHECK(one == 1); + one = 10; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(xs) == 10); + } + + // without state + { + auto xs = hana::make_tuple(1, 2, 3); + int& one = hana::fold_right(xs, [](int& i, int&) -> int& { + return i; + }); + BOOST_HANA_RUNTIME_CHECK(one == 1); + one = 10; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(xs) == 10); + } +} diff --git a/src/boost/libs/hana/test/foldable/fold_left_mcd/iterable.cpp b/src/boost/libs/hana/test/foldable/fold_left_mcd/iterable.cpp new file mode 100644 index 000000000..683d895f8 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/fold_left_mcd/iterable.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) + +#define BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD +#define BOOST_HANA_TEST_ITERABLE +#include diff --git a/src/boost/libs/hana/test/foldable/fold_left_mcd/monad.cpp b/src/boost/libs/hana/test/foldable/fold_left_mcd/monad.cpp new file mode 100644 index 000000000..fb3a0b5ec --- /dev/null +++ b/src/boost/libs/hana/test/foldable/fold_left_mcd/monad.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) + +#define BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD +#define BOOST_HANA_TEST_MONAD +#include diff --git a/src/boost/libs/hana/test/foldable/fold_left_mcd/monad_plus.cpp b/src/boost/libs/hana/test/foldable/fold_left_mcd/monad_plus.cpp new file mode 100644 index 000000000..3d2a963d7 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/fold_left_mcd/monad_plus.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) + +#define BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD +#define BOOST_HANA_TEST_MONAD_PLUS +#include diff --git a/src/boost/libs/hana/test/foldable/fold_left_mcd/orderable.cpp b/src/boost/libs/hana/test/foldable/fold_left_mcd/orderable.cpp new file mode 100644 index 000000000..ee4594657 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/fold_left_mcd/orderable.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) + +#define BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD +#define BOOST_HANA_TEST_ORDERABLE +#include diff --git a/src/boost/libs/hana/test/foldable/fold_left_mcd/searchable.cpp b/src/boost/libs/hana/test/foldable/fold_left_mcd/searchable.cpp new file mode 100644 index 000000000..2569ab05e --- /dev/null +++ b/src/boost/libs/hana/test/foldable/fold_left_mcd/searchable.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) + +#define BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD +#define BOOST_HANA_TEST_SEARCHABLE +#include diff --git a/src/boost/libs/hana/test/foldable/fold_left_mcd/sequence.cpp b/src/boost/libs/hana/test/foldable/fold_left_mcd/sequence.cpp new file mode 100644 index 000000000..c8eeddd6f --- /dev/null +++ b/src/boost/libs/hana/test/foldable/fold_left_mcd/sequence.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) + +#define BOOST_HANA_TEST_FOLDABLE_FOLD_LEFT_MCD +#define BOOST_HANA_TEST_SEQUENCE +#include diff --git a/src/boost/libs/hana/test/foldable/iterable_mcd/iterable.cpp b/src/boost/libs/hana/test/foldable/iterable_mcd/iterable.cpp new file mode 100644 index 000000000..ecb051124 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/iterable_mcd/iterable.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) + +#define BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD +#define BOOST_HANA_TEST_ITERABLE +#include diff --git a/src/boost/libs/hana/test/foldable/iterable_mcd/monad.cpp b/src/boost/libs/hana/test/foldable/iterable_mcd/monad.cpp new file mode 100644 index 000000000..6197c3696 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/iterable_mcd/monad.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) + +#define BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD +#define BOOST_HANA_TEST_MONAD +#include diff --git a/src/boost/libs/hana/test/foldable/iterable_mcd/monad_plus.cpp b/src/boost/libs/hana/test/foldable/iterable_mcd/monad_plus.cpp new file mode 100644 index 000000000..2aac153d1 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/iterable_mcd/monad_plus.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) + +#define BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD +#define BOOST_HANA_TEST_MONAD_PLUS +#include diff --git a/src/boost/libs/hana/test/foldable/iterable_mcd/orderable.cpp b/src/boost/libs/hana/test/foldable/iterable_mcd/orderable.cpp new file mode 100644 index 000000000..50632df36 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/iterable_mcd/orderable.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) + +#define BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD +#define BOOST_HANA_TEST_ORDERABLE +#include diff --git a/src/boost/libs/hana/test/foldable/iterable_mcd/searchable.cpp b/src/boost/libs/hana/test/foldable/iterable_mcd/searchable.cpp new file mode 100644 index 000000000..d2d1fa1ff --- /dev/null +++ b/src/boost/libs/hana/test/foldable/iterable_mcd/searchable.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) + +#define BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD +#define BOOST_HANA_TEST_SEARCHABLE +#include diff --git a/src/boost/libs/hana/test/foldable/iterable_mcd/sequence.cpp b/src/boost/libs/hana/test/foldable/iterable_mcd/sequence.cpp new file mode 100644 index 000000000..bf3d5a9d5 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/iterable_mcd/sequence.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) + +#define BOOST_HANA_TEST_FOLDABLE_ITERABLE_MCD +#define BOOST_HANA_TEST_SEQUENCE +#include diff --git a/src/boost/libs/hana/test/foldable/unpack_mcd/iterable.cpp b/src/boost/libs/hana/test/foldable/unpack_mcd/iterable.cpp new file mode 100644 index 000000000..d0d4f50a3 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/unpack_mcd/iterable.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) + +#define BOOST_HANA_TEST_FOLDABLE_UNPACK_MCD +#define BOOST_HANA_TEST_ITERABLE +#include diff --git a/src/boost/libs/hana/test/foldable/unpack_mcd/monad.cpp b/src/boost/libs/hana/test/foldable/unpack_mcd/monad.cpp new file mode 100644 index 000000000..e7450de39 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/unpack_mcd/monad.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) + +#define BOOST_HANA_TEST_FOLDABLE_UNPACK_MCD +#define BOOST_HANA_TEST_MONAD +#include diff --git a/src/boost/libs/hana/test/foldable/unpack_mcd/monad_plus.cpp b/src/boost/libs/hana/test/foldable/unpack_mcd/monad_plus.cpp new file mode 100644 index 000000000..e41ca2571 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/unpack_mcd/monad_plus.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) + +#define BOOST_HANA_TEST_FOLDABLE_UNPACK_MCD +#define BOOST_HANA_TEST_MONAD_PLUS +#include diff --git a/src/boost/libs/hana/test/foldable/unpack_mcd/orderable.cpp b/src/boost/libs/hana/test/foldable/unpack_mcd/orderable.cpp new file mode 100644 index 000000000..70ef8e9a5 --- /dev/null +++ b/src/boost/libs/hana/test/foldable/unpack_mcd/orderable.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) + +#define BOOST_HANA_TEST_FOLDABLE_UNPACK_MCD +#define BOOST_HANA_TEST_ORDERABLE +#include diff --git a/src/boost/libs/hana/test/foldable/unpack_mcd/searchable.cpp b/src/boost/libs/hana/test/foldable/unpack_mcd/searchable.cpp new file mode 100644 index 000000000..900cc878e --- /dev/null +++ b/src/boost/libs/hana/test/foldable/unpack_mcd/searchable.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) + +#define BOOST_HANA_TEST_FOLDABLE_UNPACK_MCD +#define BOOST_HANA_TEST_SEARCHABLE +#include diff --git a/src/boost/libs/hana/test/foldable/unpack_mcd/sequence.cpp b/src/boost/libs/hana/test/foldable/unpack_mcd/sequence.cpp new file mode 100644 index 000000000..5af417aed --- /dev/null +++ b/src/boost/libs/hana/test/foldable/unpack_mcd/sequence.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) + +#define BOOST_HANA_TEST_FOLDABLE_UNPACK_MCD +#define BOOST_HANA_TEST_SEQUENCE +#include diff --git a/src/boost/libs/hana/test/functional.cpp b/src/boost/libs/hana/test/functional.cpp new file mode 100644 index 000000000..beb5381b8 --- /dev/null +++ b/src/boost/libs/hana/test/functional.cpp @@ -0,0 +1,503 @@ +// 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 +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +template +struct nonpod : Tracked { + nonpod() : Tracked{i} { } +}; + +template +struct undefined { }; + +struct move_only { + move_only() = default; + move_only(move_only&&) = default; + move_only(move_only const&) = delete; +}; + + +int main() { + hana::test::_injection<0> f{}; + hana::test::_injection<1> g{}; + hana::test::_injection<2> h{}; + using hana::test::ct_eq; + + // always + { + auto z = ct_eq<0>{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::always(z)(), z + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::always(z)(undefined<1>{}), z + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::always(z)(undefined<1>{}, undefined<2>{}), z + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::always(z)(undefined<1>{}, undefined<2>{}, undefined<3>{}), z + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::always(z)(undefined<1>{}, undefined<2>{}, undefined<3>{}, undefined<4>{}), z + )); + + hana::always(z)(nonpod<>{}); + auto m = hana::always(move_only{})(undefined<1>{}); (void)m; + } + + // apply (tested separately) + { + + } + + // arg + { + // moveonly friendliness: + move_only z = hana::arg<1>(move_only{}); (void)z; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<1>(ct_eq<1>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<1>(ct_eq<1>{}, undefined<2>{}), + ct_eq<1>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<1>(ct_eq<1>{}, undefined<2>{}, undefined<3>{}), + ct_eq<1>{} + )); + hana::arg<1>(nonpod<1>{}); + hana::arg<1>(nonpod<1>{}, nonpod<2>{}); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<2>(undefined<1>{}, ct_eq<2>{}), + ct_eq<2>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<2>(undefined<1>{}, ct_eq<2>{}, undefined<3>{}), + ct_eq<2>{} + )); + hana::arg<2>(nonpod<1>{}, nonpod<2>{}); + hana::arg<2>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<3>(undefined<1>{}, undefined<2>{}, ct_eq<3>{}), + ct_eq<3>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<3>(undefined<1>{}, undefined<2>{}, ct_eq<3>{}, undefined<4>{}), + ct_eq<3>{} + )); + hana::arg<3>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}); + hana::arg<3>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}, nonpod<4>{}); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<4>(undefined<1>{}, undefined<2>{}, undefined<3>{}, ct_eq<4>{}), + ct_eq<4>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<4>(undefined<1>{}, undefined<2>{}, undefined<3>{}, ct_eq<4>{}, undefined<5>{}), + ct_eq<4>{} + )); + hana::arg<4>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}, nonpod<4>{}); + hana::arg<4>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}, nonpod<4>{}, nonpod<5>{}); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<5>(undefined<1>{}, undefined<2>{}, undefined<3>{}, undefined<4>{}, ct_eq<5>{}), + ct_eq<5>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<5>(undefined<1>{}, undefined<2>{}, undefined<3>{}, undefined<4>{}, ct_eq<5>{}, undefined<6>{}), + ct_eq<5>{} + )); + hana::arg<5>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}, nonpod<4>{}, nonpod<5>{}); + hana::arg<5>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}, nonpod<4>{}, nonpod<5>{}, nonpod<6>{}); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<6>(undefined<1>{}, undefined<2>{}, undefined<3>{}, undefined<4>{}, undefined<5>{}, ct_eq<6>{}), + ct_eq<6>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::arg<6>(undefined<1>{}, undefined<2>{}, undefined<3>{}, undefined<4>{}, undefined<5>{}, ct_eq<6>{}, undefined<7>{}), + ct_eq<6>{} + )); + hana::arg<6>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}, nonpod<4>{}, nonpod<5>{}, nonpod<6>{}); + hana::arg<6>(nonpod<1>{}, nonpod<2>{}, nonpod<3>{}, nonpod<4>{}, nonpod<5>{}, nonpod<6>{}, nonpod<7>{}); + } + + // compose + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::compose(f, g)(ct_eq<0>{}), + f(g(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::compose(f, g)(ct_eq<0>{}, ct_eq<1>{}), + f(g(ct_eq<0>{}), ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::compose(f, g)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(g(ct_eq<0>{}), ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::compose(f, g, h)(ct_eq<0>{}), + f(g(h(ct_eq<0>{}))) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::compose(f, g, h)(ct_eq<0>{}, ct_eq<1>{}), + f(g(h(ct_eq<0>{})), ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::compose(f, g, h)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(g(h(ct_eq<0>{})), ct_eq<1>{}, ct_eq<2>{}) + )); + + auto h = [capture = move_only{}](int) { (void)capture; return 1; }; + auto i = [](int) { return 1; }; + hana::compose(std::move(h), i)(1); + + { + // Compose move-only functions. + auto f = [capture = move_only{}](int) { (void)capture; return 1; }; + auto g = [capture = move_only{}](int) { (void)capture; return 1; }; + auto c = hana::compose(std::move(f), std::move(g)); (void)c; + } + } + + // curry + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<0>(f)(), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<1>(f)(ct_eq<1>{}), + f(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<2>(f)(ct_eq<1>{})(ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<2>(f)(ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(f)(ct_eq<1>{})(ct_eq<2>{})(ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(f)(ct_eq<1>{})(ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(f)(ct_eq<1>{}, ct_eq<2>{})(ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(f)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + + // Make sure curry is idempotent; this is important because it allows + // currying a function in generic contexts where it is unknown whether + // the function is already curried. + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<0>(hana::curry<0>(f))(), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<1>(hana::curry<1>(f))(ct_eq<1>{}), + f(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<2>(hana::curry<2>(f))(ct_eq<1>{})(ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<2>(hana::curry<2>(f))(ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(hana::curry<3>(f))(ct_eq<1>{})(ct_eq<2>{})(ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(hana::curry<3>(f))(ct_eq<1>{})(ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(hana::curry<3>(f))(ct_eq<1>{}, ct_eq<2>{})(ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::curry<3>(hana::curry<3>(f))(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } + + // demux (tested separately) + { + + } + + // fix (tested separately) + { + + } + + // flip + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flip(f)(ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<2>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flip(f)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<2>{}, ct_eq<1>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flip(f)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}), + f(ct_eq<2>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flip(f)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}), + f(ct_eq<2>{}, ct_eq<1>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + )); + } + + // id + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::id(ct_eq<0>{}), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::id(ct_eq<1>{}), + ct_eq<1>{} + )); + + (void)hana::id(move_only{}); + + // make sure we don't return a dangling reference + auto f = []() -> decltype(auto) { return hana::id(Tracked{1}); }; + auto z = f(); (void)z; + } + + // lockstep (tested separately) + { + + } + + // infix + { + auto g = hana::infix(f); + + // disregard associativity + BOOST_HANA_CONSTANT_CHECK(hana::equal( + ct_eq<0>{} ^g^ ct_eq<1>{}, + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (ct_eq<0>{} ^g)^ ct_eq<1>{}, + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + ct_eq<0>{} ^(g^ ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + + // left partial application + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (ct_eq<0>{}^g)(ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (ct_eq<0>{}^g)(ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (ct_eq<0>{}^g)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + // right partial application + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (g^ct_eq<1>{})(ct_eq<0>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (g^ct_eq<2>{})(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (g^ct_eq<3>{})(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + // equivalence with the base function + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } + + // on + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::on(f, g)(), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::on(f, g)(ct_eq<0>{}), + f(g(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::on(f, g)(ct_eq<0>{}, ct_eq<1>{}), + f(g(ct_eq<0>{}), g(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::on(f, g)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(g(ct_eq<0>{}), g(ct_eq<1>{}), g(ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::on(f, g)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(g(ct_eq<0>{}), g(ct_eq<1>{}), g(ct_eq<2>{}), g(ct_eq<3>{})) + )); + + // check the infix version + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (f ^hana::on^ g)(), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (f ^hana::on^ g)(ct_eq<0>{}), + f(g(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (f ^hana::on^ g)(ct_eq<0>{}, ct_eq<1>{}), + f(g(ct_eq<0>{}), g(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (f ^hana::on^ g)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(g(ct_eq<0>{}), g(ct_eq<1>{}), g(ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + (f ^hana::on^ g)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(g(ct_eq<0>{}), g(ct_eq<1>{}), g(ct_eq<2>{}), g(ct_eq<3>{})) + )); + } + + // overload + { + // 1 function + { + auto f = hana::overload([](int) { return ct_eq<1>{}; }); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(int{}), ct_eq<1>{})); + } + + // 2 functions + { + auto f = hana::overload( + [](int) { return ct_eq<1>{}; }, + [](float) { return ct_eq<2>{}; } + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(int{}), ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(float{}), ct_eq<2>{})); + } + + // 3 functions + { + auto f = hana::overload( + [](int) { return ct_eq<1>{}; }, + [](float) { return ct_eq<2>{}; }, + static_cast(*)(char)>([](char) { return ct_eq<3>{}; }) + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(int{}), ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(float{}), ct_eq<2>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(char{}), ct_eq<3>{})); + } + + // 4 functions + { + auto f = hana::overload( + [](int) { return ct_eq<1>{}; }, + [](float) { return ct_eq<2>{}; }, + static_cast(*)(char)>([](char) { return ct_eq<3>{}; }), + [](auto) { return ct_eq<4>{}; } + ); + + struct otherwise { }; + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(int{}), ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(float{}), ct_eq<2>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(char{}), ct_eq<3>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal(f(otherwise{}), ct_eq<4>{})); + } + + // check move-only friendliness for bare functions + { + void (*g)(move_only) = [](move_only) { }; + hana::overload(g)(move_only{}); + } + + // check non-strict matches which require a conversion + { + struct convertible_to_int { operator int() const { return 1; } }; + auto f = [](int) { return ct_eq<0>{}; }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::overload(f)(convertible_to_int{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::overload(static_cast(*)(int)>(f))(convertible_to_int{}), + ct_eq<0>{} + )); + } + } + + // partial (tested separately) + { + + } + + // placeholder (tested separately) + { + + } +} diff --git a/src/boost/libs/hana/test/functional/apply.cpp b/src/boost/libs/hana/test/functional/apply.cpp new file mode 100644 index 000000000..ff1c81cf9 --- /dev/null +++ b/src/boost/libs/hana/test/functional/apply.cpp @@ -0,0 +1,262 @@ +// 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 +#include +#include + +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +struct nonpod : Tracked { + nonpod() : Tracked{i} { } +}; + +struct NonCopyable { + NonCopyable() = default; + NonCopyable(NonCopyable const&) = delete; + NonCopyable& operator=(NonCopyable const&) = delete; +}; + +struct TestClass { + explicit TestClass(int x) : data(x) { } + TestClass(TestClass const&) = delete; + TestClass& operator=(TestClass const&) = delete; + + int& operator()(NonCopyable&&) & { return data; } + int const& operator()(NonCopyable&&) const & { return data; } + int volatile& operator()(NonCopyable&&) volatile & { return data; } + int const volatile& operator()(NonCopyable&&) const volatile & { return data; } + + int&& operator()(NonCopyable&&) && { return std::move(data); } + int const&& operator()(NonCopyable&&) const && { return std::move(data); } + int volatile&& operator()(NonCopyable&&) volatile && { return std::move(data); } + int const volatile&& operator()(NonCopyable&&) const volatile && { return std::move(data); } + + int data; +}; + +struct DerivedFromTestClass : TestClass { + explicit DerivedFromTestClass(int x) : TestClass(x) { } +}; + + +template +void test_b12(Functor&& f) { + // Create the callable object. + using ClassFunc = Signature TestClass::*; + ClassFunc func_ptr = &TestClass::operator(); + + // Create the dummy arg. + NonCopyable arg; + + // Check that the deduced return type of invoke is what is expected. + using DeducedReturnType = decltype( + hana::apply(func_ptr, std::forward(f), std::move(arg)) + ); + static_assert(std::is_same::value, ""); + + // Check that result_of_t matches Expect. + using ResultOfReturnType = typename std::result_of::type; + static_assert(std::is_same::value, ""); + + // Run invoke and check the return value. + DeducedReturnType ret = hana::apply(func_ptr, std::forward(f), std::move(arg)); + BOOST_HANA_RUNTIME_CHECK(ret == 42); +} + +template +void test_b34(Functor&& f) { + // Create the callable object. + using ClassFunc = int TestClass::*; + ClassFunc func_ptr = &TestClass::data; + + // Check that the deduced return type of invoke is what is expected. + using DeducedReturnType = decltype( + hana::apply(func_ptr, std::forward(f)) + ); + static_assert(std::is_same::value, ""); + + // Check that result_of_t matches Expect. + using ResultOfReturnType = typename std::result_of::type; + static_assert(std::is_same::value, ""); + + // Run invoke and check the return value. + DeducedReturnType ret = hana::apply(func_ptr, std::forward(f)); + BOOST_HANA_RUNTIME_CHECK(ret == 42); +} + +template +void test_b5(Functor&& f) { + NonCopyable arg; + + // Check that the deduced return type of invoke is what is expected. + using DeducedReturnType = decltype( + hana::apply(std::forward(f), std::move(arg)) + ); + static_assert(std::is_same::value, ""); + + // Check that result_of_t matches Expect. + using ResultOfReturnType = typename std::result_of::type; + static_assert(std::is_same::value, ""); + + // Run invoke and check the return value. + DeducedReturnType ret = hana::apply(std::forward(f), std::move(arg)); + BOOST_HANA_RUNTIME_CHECK(ret == 42); +} + +int& foo(NonCopyable&&) { + static int data = 42; + return data; +} + +int main() { + // Test normal usage with a function object + { + hana::test::_injection<0> f{}; + using hana::test::ct_eq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::apply(f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::apply(f, ct_eq<0>{}), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::apply(f, ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::apply(f, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + // Make sure we can use apply with non-PODs + hana::apply(f, nonpod<>{}); + } + + // Bullets 1 & 2 in the standard + { + TestClass cl(42); + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + } + { + DerivedFromTestClass cl(42); + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + test_b12(std::move(cl)); + } + { + TestClass cl_obj(42); + TestClass *cl = &cl_obj; + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + } + { + DerivedFromTestClass cl_obj(42); + DerivedFromTestClass *cl = &cl_obj; + test_b12(cl); + test_b12(cl); + test_b12(cl); + test_b12(cl); + } + + // Bullets 3 & 4 in the standard + { + using Fn = TestClass; + Fn cl(42); + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } + { + using Fn = DerivedFromTestClass; + Fn cl(42); + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } + { + using Fn = TestClass; + Fn cl_obj(42); + Fn* cl = &cl_obj; + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } + { + using Fn = DerivedFromTestClass; + Fn cl_obj(42); + Fn* cl = &cl_obj; + test_b34(cl); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + test_b34(static_cast(cl)); + } + + // Bullet 5 in the standard + using FooType = int&(NonCopyable&&); + { + FooType& fn = foo; + test_b5(fn); + } + { + FooType* fn = foo; + test_b5(fn); + } + { + using Fn = TestClass; + Fn cl(42); + test_b5(cl); + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + test_b5(static_cast(cl)); + } +} diff --git a/src/boost/libs/hana/test/functional/capture.cpp b/src/boost/libs/hana/test/functional/capture.cpp new file mode 100644 index 000000000..f64a65c0f --- /dev/null +++ b/src/boost/libs/hana/test/functional/capture.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 +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + // 0-arg capture + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture()(f)(), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture()(f)(ct_eq<0>{}), + f(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture()(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture()(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + // 1-arg capture + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{})(f)(), + f(ct_eq<77>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{})(f)(ct_eq<0>{}), + f(ct_eq<77>{}, ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{})(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<77>{}, ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{})(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<77>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + // 2-args capture + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(), + f(ct_eq<77>{}, ct_eq<88>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(ct_eq<0>{}), + f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{})(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + // 3-args capture + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(), + f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(ct_eq<0>{}), + f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{}, ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(ct_eq<0>{}, ct_eq<1>{}), + f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{}, ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::capture(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{})(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<77>{}, ct_eq<88>{}, ct_eq<99>{}, ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); +} diff --git a/src/boost/libs/hana/test/functional/demux.cpp b/src/boost/libs/hana/test/functional/demux.cpp new file mode 100644 index 000000000..07285bce5 --- /dev/null +++ b/src/boost/libs/hana/test/functional/demux.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct MoveOnly { + MoveOnly() = default; + MoveOnly(MoveOnly const&) = delete; + MoveOnly(MoveOnly&&) = default; +}; + +int main() { + hana::test::_injection<0> f{}; + hana::test::_injection<1> g{}; + hana::test::_injection<2> h{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::demux(f)()(), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::demux(f)(g)(ct_eq<1>{}), + f(g(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::demux(f)(g)(ct_eq<1>{}, ct_eq<2>{}), + f(g(ct_eq<1>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::demux(f)(g)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(g(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::demux(f)(g, h)(ct_eq<1>{}), + f(g(ct_eq<1>{}), h(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::demux(f)(g, h)(ct_eq<1>{}, ct_eq<2>{}), + f(g(ct_eq<1>{}, ct_eq<2>{}), h(ct_eq<1>{}, ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::demux(f)(g, h)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(g(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), h(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})) + )); + + // Make sure we can pass move-only types when a single function + // is demux'ed. In other words, make sure the arguments are + // perfect-forwarded when a single function is demux'ed. + { + hana::demux(f)(g)(MoveOnly{}); + hana::demux(f)(g)(MoveOnly{}, MoveOnly{}); + hana::demux(f)(g)(MoveOnly{}, MoveOnly{}, MoveOnly{}); + } +} diff --git a/src/boost/libs/hana/test/functional/fix.cpp b/src/boost/libs/hana/test/functional/fix.cpp new file mode 100644 index 000000000..79041b4a9 --- /dev/null +++ b/src/boost/libs/hana/test/functional/fix.cpp @@ -0,0 +1,41 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +BOOST_HANA_CONSTEXPR_LAMBDA auto fact = hana::fix([](auto fact, auto n) { + return hana::eval_if(hana::equal(n, hana::ullong_c<0>), + hana::always(hana::ullong_c<1>), + [=](auto _) { return hana::mult(n, fact(_(n) - hana::ullong_c<1>)); } + ); +}); + +constexpr unsigned long long reference(unsigned long long n) +{ return n == 0 ? 1 : n * reference(n - 1); } + +template +void test() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + fact(hana::ullong_c), + hana::ullong_c + )); + test(); +} + +template <> void test<-1>() { } + +int main() { + test<15>(); +} diff --git a/src/boost/libs/hana/test/functional/iterate.cpp b/src/boost/libs/hana/test/functional/iterate.cpp new file mode 100644 index 000000000..f40805760 --- /dev/null +++ b/src/boost/libs/hana/test/functional/iterate.cpp @@ -0,0 +1,151 @@ +// 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 + +#include +#include + +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct undefined { }; + +constexpr int incr(int i) { return i + 1; } + +int main() { + hana::test::_injection<0> f{}; + + // "real usage" tests + static_assert(hana::iterate<3>(incr, 0) == 3, ""); + { + std::vector vec; + hana::iterate<10>([&](int i) { vec.push_back(i); return i + 1; }, 0); + BOOST_HANA_RUNTIME_CHECK( + vec == std::vector{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} + ); + } + + // equivalence between iterate(f, x) and iterate(f)(x) + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<0>(undefined{})(ct_eq<0>{}), + hana::iterate<0>(undefined{}, ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<4>(f)(ct_eq<0>{}), + hana::iterate<4>(f, ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<10>(f)(ct_eq<0>{}), + hana::iterate<10>(f, ct_eq<0>{}) + )); + + // systematic tests + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<0>(undefined{}, ct_eq<0>{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<1>(f, ct_eq<0>{}), + f(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<2>(f, ct_eq<0>{}), + f(f(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<3>(f, ct_eq<0>{}), + f(f(f(ct_eq<0>{}))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<4>(f, ct_eq<0>{}), + f(f(f(f(ct_eq<0>{})))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<5>(f, ct_eq<0>{}), + f(f(f(f(f(ct_eq<0>{}))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<6>(f, ct_eq<0>{}), + f(f(f(f(f(f(ct_eq<0>{})))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<7>(f, ct_eq<0>{}), + f(f(f(f(f(f(f(ct_eq<0>{}))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<11>(f, ct_eq<0>{}), + f(f(f(f(f(f(f(f(f(f(f(ct_eq<0>{}))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<12>(f, ct_eq<0>{}), + f(f(f(f(f(f(f(f(f(f(f(f(ct_eq<0>{})))))))))))) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::iterate<13>(f, ct_eq<0>{}), + f(f(f(f(f(f(f(f(f(f(f(f(f(ct_eq<0>{}))))))))))))) + )); + + // We can't nest too many calls to f, because that uses a hana::tuple + // internally and some implementation (libstdc++) have trouble with + // deeply-nested calls to `std::is_constructible`, which is required by + // hana::tuple. Hence, we use an homogeneous function for the remaining + // tests. + static_assert(hana::iterate<23>(incr, 0) == 23, ""); + static_assert(hana::iterate<24>(incr, 0) == 24, ""); + static_assert(hana::iterate<25>(incr, 0) == 25, ""); + static_assert(hana::iterate<26>(incr, 0) == 26, ""); + static_assert(hana::iterate<27>(incr, 0) == 27, ""); + static_assert(hana::iterate<28>(incr, 0) == 28, ""); + static_assert(hana::iterate<29>(incr, 0) == 29, ""); + + static_assert(hana::iterate<30>(incr, 0) == 30, ""); + static_assert(hana::iterate<31>(incr, 0) == 31, ""); + static_assert(hana::iterate<32>(incr, 0) == 32, ""); + static_assert(hana::iterate<33>(incr, 0) == 33, ""); + static_assert(hana::iterate<34>(incr, 0) == 34, ""); + static_assert(hana::iterate<35>(incr, 0) == 35, ""); + static_assert(hana::iterate<36>(incr, 0) == 36, ""); + static_assert(hana::iterate<37>(incr, 0) == 37, ""); + static_assert(hana::iterate<38>(incr, 0) == 38, ""); + static_assert(hana::iterate<39>(incr, 0) == 39, ""); + + static_assert(hana::iterate<40>(incr, 0) == 40, ""); + static_assert(hana::iterate<41>(incr, 0) == 41, ""); + static_assert(hana::iterate<42>(incr, 0) == 42, ""); + static_assert(hana::iterate<43>(incr, 0) == 43, ""); + static_assert(hana::iterate<44>(incr, 0) == 44, ""); + static_assert(hana::iterate<45>(incr, 0) == 45, ""); + static_assert(hana::iterate<46>(incr, 0) == 46, ""); + static_assert(hana::iterate<47>(incr, 0) == 47, ""); + static_assert(hana::iterate<48>(incr, 0) == 48, ""); + static_assert(hana::iterate<49>(incr, 0) == 49, ""); + + static_assert(hana::iterate<50>(incr, 0) == 50, ""); + static_assert(hana::iterate<51>(incr, 0) == 51, ""); + static_assert(hana::iterate<52>(incr, 0) == 52, ""); + static_assert(hana::iterate<53>(incr, 0) == 53, ""); + static_assert(hana::iterate<54>(incr, 0) == 54, ""); + static_assert(hana::iterate<55>(incr, 0) == 55, ""); + static_assert(hana::iterate<56>(incr, 0) == 56, ""); + static_assert(hana::iterate<57>(incr, 0) == 57, ""); + static_assert(hana::iterate<58>(incr, 0) == 58, ""); + static_assert(hana::iterate<59>(incr, 0) == 59, ""); +} diff --git a/src/boost/libs/hana/test/functional/lockstep.cpp b/src/boost/libs/hana/test/functional/lockstep.cpp new file mode 100644 index 000000000..086d02cad --- /dev/null +++ b/src/boost/libs/hana/test/functional/lockstep.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 +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + hana::test::_injection<1> g{}; + hana::test::_injection<2> h{}; + hana::test::_injection<3> i{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lockstep(f)()(), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lockstep(f)(g)(ct_eq<1>{}), + f(g(ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lockstep(f)(g, h)(ct_eq<1>{}, ct_eq<2>{}), + f(g(ct_eq<1>{}), h(ct_eq<2>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lockstep(f)(g, h, i)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(g(ct_eq<1>{}), h(ct_eq<2>{}), i(ct_eq<3>{})) + )); +} diff --git a/src/boost/libs/hana/test/functional/overload_linearly.cpp b/src/boost/libs/hana/test/functional/overload_linearly.cpp new file mode 100644 index 000000000..6f537f589 --- /dev/null +++ b/src/boost/libs/hana/test/functional/overload_linearly.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 + +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct A { }; +struct AA : A { }; +struct B { }; +struct C { }; + +int main() { + // 2 functions without overlap + { + auto f = hana::overload_linearly( + [](A) { return ct_eq<0>{}; }, + [](B) { return ct_eq<1>{}; } + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(A{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(AA{}), + f(A{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(B{}), + ct_eq<1>{} + )); + } + + // 2 functions with overlap + { + auto f = hana::overload_linearly( + [](A) { return ct_eq<0>{}; }, + [](A) { return ct_eq<1>{}; } + ); + + auto g = hana::overload_linearly( + [](A) { return ct_eq<0>{}; }, + [](AA) { return ct_eq<1>{}; } + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(A{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(AA{}), + f(A{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(A{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + g(AA{}), + g(A{}) + )); + } + + // 3 functions + { + auto f = hana::overload_linearly( + [](A) { return ct_eq<0>{}; }, + [](B) { return ct_eq<1>{}; }, + [](C) { return ct_eq<2>{}; } + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(A{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(AA{}), + f(A{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(B{}), + ct_eq<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(C{}), + ct_eq<2>{} + )); + } + + // 1 function (github issue #280) + { + auto f = hana::overload_linearly( + [](A) { return ct_eq<0>{}; } + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(A{}), + ct_eq<0>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + f(AA{}), + f(A{}) + )); + } +} diff --git a/src/boost/libs/hana/test/functional/partial.cpp b/src/boost/libs/hana/test/functional/partial.cpp new file mode 100644 index 000000000..e6f56243c --- /dev/null +++ b/src/boost/libs/hana/test/functional/partial.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f)(), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f)(ct_eq<1>{}), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f)(ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f, ct_eq<1>{})(), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f, ct_eq<1>{})(ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f, ct_eq<1>{})(ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f, ct_eq<1>{}, ct_eq<2>{})(), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f, ct_eq<1>{}, ct_eq<2>{})(ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f, ct_eq<1>{}, ct_eq<2>{})(ct_eq<3>{}, ct_eq<4>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::partial(f, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})(), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); +} diff --git a/src/boost/libs/hana/test/functional/placeholder.cpp b/src/boost/libs/hana/test/functional/placeholder.cpp new file mode 100644 index 000000000..be6c9e610 --- /dev/null +++ b/src/boost/libs/hana/test/functional/placeholder.cpp @@ -0,0 +1,119 @@ +// 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 +#include + +#include +namespace hana = boost::hana; +using hana::_; + + +struct extra_t { virtual ~extra_t() { } }; +extra_t extra{}; + +constexpr struct { } invalid{}; + +template using bool_t = bool; +constexpr bool valid_call(...) { return false; } +template +constexpr auto valid_call(F&& f, Args&& ...args) + -> bool_t(f)(std::forward(args)...))> +{ return true; } + +#define BOOST_HANA_TEST_BINARY_OP(op, x, y) \ + static_assert((_ op _)(x, y) == (x op y), ""); \ + BOOST_HANA_RUNTIME_CHECK((_ op _)(x, y, extra) == (x op y)); \ + BOOST_HANA_RUNTIME_CHECK((_ op _)(x, y, extra, extra) == (x op y)); \ + static_assert(!valid_call(_ op _), ""); \ + static_assert(!valid_call(_ op _, invalid), ""); \ + static_assert(!valid_call(_ op _, invalid, invalid), ""); \ + \ + static_assert((_ op y)(x) == (x op y), ""); \ + BOOST_HANA_RUNTIME_CHECK((_ op y)(x, extra) == (x op y)); \ + BOOST_HANA_RUNTIME_CHECK((_ op y)(x, extra, extra) == (x op y)); \ + static_assert(!valid_call(_ op y), ""); \ + static_assert(!valid_call(_ op y, invalid), ""); \ + \ + static_assert((x op _)(y) == (x op y), ""); \ + BOOST_HANA_RUNTIME_CHECK((x op _)(y, extra) == (x op y)); \ + BOOST_HANA_RUNTIME_CHECK((x op _)(y, extra, extra) == (x op y)); \ + static_assert(!valid_call(x op _), ""); \ + static_assert(!valid_call(x op _, invalid), ""); \ + static_assert(!valid_call(x op _, invalid), ""); \ +/**/ + +#define BOOST_HANA_TEST_UNARY_OP(op, x) \ + static_assert((op _)(x) == (op x), ""); \ + BOOST_HANA_RUNTIME_CHECK((op _)(x, extra) == (op x)); \ + BOOST_HANA_RUNTIME_CHECK((op _)(x, extra, extra) == (op x)); \ + static_assert(!valid_call(op _), ""); \ + static_assert(!valid_call(op _, invalid), ""); \ +/**/ + +struct incr_t { + template + constexpr auto operator()(X x) const -> decltype(x + 1) + { return x + 1; } +}; +constexpr incr_t incr{}; + +int main() { + // Arithmetic + BOOST_HANA_TEST_UNARY_OP(+, 1) + BOOST_HANA_TEST_UNARY_OP(-, 1) + BOOST_HANA_TEST_BINARY_OP(+, 6, 3) + BOOST_HANA_TEST_BINARY_OP(-, 6, 3) + BOOST_HANA_TEST_BINARY_OP(*, 6, 3) + BOOST_HANA_TEST_BINARY_OP(/, 6, 3) + BOOST_HANA_TEST_BINARY_OP(%, 6, 3) + + // Bitwise + BOOST_HANA_TEST_UNARY_OP(~, 5) + BOOST_HANA_TEST_BINARY_OP(&, 6, 3) + BOOST_HANA_TEST_BINARY_OP(|, 6, 3) + BOOST_HANA_TEST_BINARY_OP(^, 6, 3) + BOOST_HANA_TEST_BINARY_OP(<<, 6, 3) + BOOST_HANA_TEST_BINARY_OP(>>, 6, 3) + + // Comparison + BOOST_HANA_TEST_BINARY_OP(==, 6, 3) + BOOST_HANA_TEST_BINARY_OP(!=, 6, 3) + BOOST_HANA_TEST_BINARY_OP(<, 6, 3) + BOOST_HANA_TEST_BINARY_OP(<=, 6, 3) + BOOST_HANA_TEST_BINARY_OP(>, 6, 3) + BOOST_HANA_TEST_BINARY_OP(>=, 6, 3) + + // Logical + BOOST_HANA_TEST_BINARY_OP(||, true, false) + BOOST_HANA_TEST_BINARY_OP(&&, true, true) + BOOST_HANA_TEST_UNARY_OP(!, true) + + // Member access + constexpr int i = 4; + constexpr int array[] = {0, 1, 2}; + BOOST_HANA_TEST_UNARY_OP(*, &i) + + static_assert(_[0](array) == array[0], ""); + BOOST_HANA_RUNTIME_CHECK(_[0](array, extra) == array[0]); + BOOST_HANA_RUNTIME_CHECK(_[0](array, extra, extra) == array[0]); + static_assert(_[1](array) == array[1], ""); + static_assert(_[1](array) == array[1], ""); + static_assert(_[2](array) == array[2], ""); + static_assert(!valid_call(_[invalid]), ""); + static_assert(!valid_call(_[invalid], array), ""); + static_assert(!valid_call(_[invalid], invalid), ""); + static_assert(!valid_call(_[0], invalid), ""); + + // Call operator + static_assert(_(1)(incr) == incr(1), ""); + BOOST_HANA_RUNTIME_CHECK(_(1)(incr, extra) == incr(1)); + BOOST_HANA_RUNTIME_CHECK(_(1)(incr, extra, extra) == incr(1)); + static_assert(_(2)(incr) == incr(2), ""); + static_assert(_(3)(incr) == incr(3), ""); + static_assert(!valid_call(_(invalid)), ""); + static_assert(!valid_call(_(invalid), incr), ""); + static_assert(!valid_call(_(invalid), invalid), ""); + static_assert(!valid_call(_(1), invalid), ""); +} diff --git a/src/boost/libs/hana/test/functional/reverse_partial.cpp b/src/boost/libs/hana/test/functional/reverse_partial.cpp new file mode 100644 index 000000000..b5a131a11 --- /dev/null +++ b/src/boost/libs/hana/test/functional/reverse_partial.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + constexpr auto rp = hana::reverse_partial; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f)(), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f)(ct_eq<1>{}), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f)(ct_eq<1>{}, ct_eq<2>{}), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f)(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f, ct_eq<1>{})(), + f(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f, ct_eq<1>{})(ct_eq<2>{}), + f(ct_eq<2>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f, ct_eq<1>{})(ct_eq<2>{}, ct_eq<3>{}), + f(ct_eq<2>{}, ct_eq<3>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f, ct_eq<1>{}, ct_eq<2>{})(), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f, ct_eq<1>{}, ct_eq<2>{})(ct_eq<3>{}), + f(ct_eq<3>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f, ct_eq<1>{}, ct_eq<2>{})(ct_eq<3>{}, ct_eq<4>{}), + f(ct_eq<3>{}, ct_eq<4>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + rp(f, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})(), + f(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); +} diff --git a/src/boost/libs/hana/test/group.cpp b/src/boost/libs/hana/test/group.cpp new file mode 100644 index 000000000..1c069b4c9 --- /dev/null +++ b/src/boost/libs/hana/test/group.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::TestGroup{hana::make_tuple(0,1,2,3,4,5)}; + hana::test::TestGroup{hana::make_tuple(0l,1l,2l,3l,4l,5l)}; + + // minus + static_assert(hana::minus(6, 4) == 6 - 4, ""); + + // negate + static_assert(hana::negate(6) == -6, ""); +} diff --git a/src/boost/libs/hana/test/identity/applicative.full_mcd.cpp b/src/boost/libs/hana/test/identity/applicative.full_mcd.cpp new file mode 100644 index 000000000..ceb00326b --- /dev/null +++ b/src/boost/libs/hana/test/identity/applicative.full_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_APPLICATIVE_FULL_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/identity/applicative.monad_mcd.cpp b/src/boost/libs/hana/test/identity/applicative.monad_mcd.cpp new file mode 100644 index 000000000..7c255253e --- /dev/null +++ b/src/boost/libs/hana/test/identity/applicative.monad_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_APPLICATIVE_MONAD_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/identity/functor.adjust_mcd.cpp b/src/boost/libs/hana/test/identity/functor.adjust_mcd.cpp new file mode 100644 index 000000000..972d12e6f --- /dev/null +++ b/src/boost/libs/hana/test/identity/functor.adjust_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_FUNCTOR_ADJUST_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/identity/functor.transform_mcd.cpp b/src/boost/libs/hana/test/identity/functor.transform_mcd.cpp new file mode 100644 index 000000000..e9bbba146 --- /dev/null +++ b/src/boost/libs/hana/test/identity/functor.transform_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_FUNCTOR_TRANSFORM_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/identity/main.hpp b/src/boost/libs/hana/test/identity/main.hpp new file mode 100644 index 000000000..012aeb54d --- /dev/null +++ b/src/boost/libs/hana/test/identity/main.hpp @@ -0,0 +1,150 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + // Functor + { + auto functor = ::identity; + // adjust_if + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::adjust_if(functor(ct_eq<0>{}), hana::always(cnumeric), f), + functor(f(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::adjust_if(functor(ct_eq<0>{}), hana::always(cnumeric), f), + functor(ct_eq<0>{}) + )); + } + + // fill + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(functor(ct_eq<0>{}), ct_eq<1>{}), + functor(ct_eq<1>{}) + )); + } + + // transform + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(functor(ct_eq<0>{}), f), + functor(f(ct_eq<0>{})) + )); + } + + // replace_if + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(functor(ct_eq<0>{}), hana::always(cnumeric), ct_eq<1>{}), + functor(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::replace_if(functor(ct_eq<0>{}), hana::always(cnumeric), ct_eq<1>{}), + functor(ct_eq<0>{}) + )); + } + } + + // Applicative + { + auto a = ::identity; + using A = ::Identity; + + // ap + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(a(f), a(ct_eq<0>{})), + a(f(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(a(f), a(ct_eq<0>{}), a(ct_eq<1>{})), + a(f(ct_eq<0>{}, ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(a(f), a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<2>{})), + a(f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(a(f), a(ct_eq<0>{}), a(ct_eq<1>{}), a(ct_eq<2>{}), a(ct_eq<3>{})), + a(f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})) + )); + } + + // lift + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lift(ct_eq<0>{}), + a(ct_eq<0>{}) + )); + } + } + + // Monad + { + auto monad = ::identity; + using M = ::Identity; + auto f = hana::compose(monad, hana::test::_injection<0>{}); + + // chain + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(monad(ct_eq<1>{}), f), + f(ct_eq<1>{}) + )); + } + + // tap + { + bool executed = false; + auto exec = [&](auto) { executed = true; }; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(monad(ct_eq<0>{}), hana::tap(exec)), + monad(ct_eq<0>{}) + )); + BOOST_HANA_RUNTIME_CHECK(executed); + } + + // then + { + struct invalid { }; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::then(monad(invalid{}), monad(ct_eq<0>{})), + monad(ct_eq<0>{}) + )); + } + } +} diff --git a/src/boost/libs/hana/test/identity/monad.chain_mcd.cpp b/src/boost/libs/hana/test/identity/monad.chain_mcd.cpp new file mode 100644 index 000000000..bad96d728 --- /dev/null +++ b/src/boost/libs/hana/test/identity/monad.chain_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_MONAD_CHAIN_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/identity/monad.flatten_mcd.cpp b/src/boost/libs/hana/test/identity/monad.flatten_mcd.cpp new file mode 100644 index 000000000..3ff28218e --- /dev/null +++ b/src/boost/libs/hana/test/identity/monad.flatten_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_MONAD_FLATTEN_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/if_/non_copyable.cpp b/src/boost/libs/hana/test/if_/non_copyable.cpp new file mode 100644 index 000000000..0de09ee42 --- /dev/null +++ b/src/boost/libs/hana/test/if_/non_copyable.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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +// This test makes sure that if_ can be used with non-copyable branches. + +template +struct Boolean { }; + +namespace boost { namespace hana { + template + struct while_impl> { + // Not implemented + }; + + template + struct not_impl> { + // Not implemented + }; + + template + struct eval_if_impl> { + template + static constexpr decltype(auto) apply(Cond const&, Then&& t, Else&& e) { + return hana::eval_if(hana::bool_c, static_cast(t), + static_cast(e)); + } + }; +}} + +template +struct NonCopyable { + static constexpr int value = v; + NonCopyable() = default; + NonCopyable(NonCopyable const&) = delete; + NonCopyable(NonCopyable&&) = default; + + NonCopyable& operator=(NonCopyable const&) = delete; + NonCopyable& operator=(NonCopyable&&) = default; +}; + +static_assert(hana::if_(Boolean{}, NonCopyable<3>{}, NonCopyable<4>{}).value == 3, ""); +static_assert(hana::if_(Boolean{}, NonCopyable<3>{}, NonCopyable<4>{}).value == 4, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/index_if.cpp b/src/boost/libs/hana/test/index_if.cpp new file mode 100644 index 000000000..b899f0ca1 --- /dev/null +++ b/src/boost/libs/hana/test/index_if.cpp @@ -0,0 +1,31 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 +#include + +#include +#include + +namespace hana = boost::hana; + + +int main() { + // Tests hana::index_if on an infinite iterable + constexpr Counter<> c{}; + auto pred = [](auto i) { + return [=](auto x) { + return hana::bool_c; + }; + }; + + static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<0>)).value()){}) == 0, ""); + static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<1>)).value()){}) == 1, ""); + static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<2>)).value()){}) == 2, ""); + static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<3>)).value()){}) == 3, ""); + static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<4>)).value()){}) == 4, ""); + static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<5>)).value()){}) == 5, ""); + static_assert(hana::value(decltype(hana::index_if(c, pred(hana::size_c<6>)).value()){}) == 6, ""); +} diff --git a/src/boost/libs/hana/test/integral_constant/arithmetic.cpp b/src/boost/libs/hana/test/integral_constant/arithmetic.cpp new file mode 100644 index 000000000..5968ebe31 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/arithmetic.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 +#include + +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + hana::int_c<-10>, + hana::int_c<-2>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<3>, + hana::int_c<4> + ); + + hana::test::TestMonoid>{ints}; + hana::test::TestGroup>{ints}; + hana::test::TestRing>{ints}; + hana::test::TestEuclideanRing>{ints}; +} diff --git a/src/boost/libs/hana/test/integral_constant/comparable.cpp b/src/boost/libs/hana/test/integral_constant/comparable.cpp new file mode 100644 index 000000000..a9677341e --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/comparable.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 +#include + +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + hana::int_c<-10>, + hana::int_c<-2>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<3>, + hana::int_c<4> + ); + + hana::test::TestComparable>{ints}; +} diff --git a/src/boost/libs/hana/test/integral_constant/constant.cpp b/src/boost/libs/hana/test/integral_constant/constant.cpp new file mode 100644 index 000000000..5ef1248ca --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/constant.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 +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // value + static_assert(hana::value(hana::integral_c) == 0, ""); + static_assert(hana::value(hana::integral_c) == 1, ""); + + + // laws + hana::test::TestConstant>{ + hana::make_tuple( + hana::int_c<-10>, + hana::int_c<-2>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<3>, + hana::int_c<4> + ), + hana::tuple_t + }; + + hana::test::TestConstant>{ + hana::make_tuple( + hana::true_c, hana::false_c + ), + hana::tuple_t + }; +} diff --git a/src/boost/libs/hana/test/integral_constant/constexpr_init.cpp b/src/boost/libs/hana/test/integral_constant/constexpr_init.cpp new file mode 100644 index 000000000..0656eb6d0 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/constexpr_init.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 +#include +namespace hana = boost::hana; + + +/* +When we use `int_<...>` in a template, Clang 3.5 says: + +-------------------------------- +include/boost/hana/integral_constant.hpp:80:20: error: constexpr variable 'int_<1>' must be initialized by a constant expression + constexpr auto int_ = integral; + ^ ~~~~~~~~~~~~~~~~ +test/integral/constexpr_bug.cpp:41:37: note: in instantiation of variable template specialization 'boost::hana::int_' requested here +constexpr auto check_int() { return int_<1>; } + ^ +include/boost/hana/integral_constant.hpp:80:27: note: subexpression not valid in a constant expression + constexpr auto int_ = integral; + ^ +include/boost/hana/integral_constant.hpp:80:27: note: in call to 'integral_type(integral)' +-------------------------------- + +if we define int_ & friends like + + template + constexpr auto int_ = integral; + +Instead, we do + + template + constexpr decltype(integral) int_{}; + +which is equivalent but uglier. Note that everything works just fine when +we're not in a template. +*/ + +template +constexpr auto check_int() { return hana::int_c<1>; } + +template +constexpr auto check_true() { return hana::true_c; } + +template +constexpr auto check_size_t() { return hana::size_c<0>; } + + +int main() { } diff --git a/src/boost/libs/hana/test/integral_constant/github_354.cpp b/src/boost/libs/hana/test/integral_constant/github_354.cpp new file mode 100644 index 000000000..33ce2f37b --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/github_354.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 +#include +#include +namespace hana = boost::hana; + + +static_assert(hana::is_convertible, bool>::value, ""); +static_assert(hana::to(hana::bool_c) == true, ""); + +static_assert(hana::is_convertible, int>::value, ""); +static_assert(hana::to(hana::integral_c) == 1, ""); + +static_assert(hana::is_convertible, long>::value, ""); +static_assert(hana::to(hana::integral_c) == 1l, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/integral_constant/hash.cpp b/src/boost/libs/hana/test/integral_constant/hash.cpp new file mode 100644 index 000000000..59cf07057 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/hash.cpp @@ -0,0 +1,110 @@ +// 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 +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // Unsigned integral constants should hash to `unsigned long long` + { + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + } + + // Signed integral constants should hash to `signed long long` + { + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + } + + // `char` should hash to either `signed long long` or `unsigned long long`, + // depending on its signedness + { + using T = std::conditional_t< + std::is_signed::value, + signed long long, + unsigned long long + >; + + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::integral_c), + hana::type_c> + )); + } + + // Pointers to members should hash to themselves. + // This test is disabled in pre-C++17, because pointers to non-static + // data members can't be used as non-type template arguments before that. + // See http://stackoverflow.com/q/35398848/627587. + { +#if __cplusplus > 201402L + + struct Foo { int bar; }; + constexpr auto x = hana::integral_constant{}; + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(x), + hana::type_c> + )); + +#endif + } + + // Booleans should hash to themselves + { + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::true_c), + hana::type_c + )); + + BOOST_HANA_CONSTANT_ASSERT(hana::equal( + hana::hash(hana::false_c), + hana::type_c + )); + } +} diff --git a/src/boost/libs/hana/test/integral_constant/hashable.cpp b/src/boost/libs/hana/test/integral_constant/hashable.cpp new file mode 100644 index 000000000..5c31355d0 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/hashable.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 +#include + +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + hana::integral_constant{} + , hana::integral_constant{} + , hana::integral_constant{} + , hana::integral_constant{} + , hana::integral_constant{} + , hana::integral_constant{} + , hana::integral_constant{} + , hana::integral_constant{} + , hana::integral_constant{} + ); + + hana::test::TestHashable>{ints}; +} diff --git a/src/boost/libs/hana/test/integral_constant/logical.cpp b/src/boost/libs/hana/test/integral_constant/logical.cpp new file mode 100644 index 000000000..70641d370 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/logical.cpp @@ -0,0 +1,55 @@ +// 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 +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +int main() { + // eval_if + { + auto t = [](auto) { return hana::test::ct_eq<3>{}; }; + auto e = [](auto) { return hana::test::ct_eq<4>{}; }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(hana::true_c, t, e), + hana::test::ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval_if(hana::false_c, t, e), + hana::test::ct_eq<4>{} + )); + } + + // not_ + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::not_(hana::true_c), + hana::false_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::not_(hana::false_c), + hana::true_c + )); + } + + // laws + hana::test::TestLogical>{hana::make_tuple( + hana::int_c<-2>, hana::int_c<0>, hana::int_c<1>, hana::int_c<3> + )}; + + hana::test::TestLogical>{hana::make_tuple( + hana::false_c, hana::true_c + )}; +} diff --git a/src/boost/libs/hana/test/integral_constant/operators.cpp b/src/boost/libs/hana/test/integral_constant/operators.cpp new file mode 100644 index 000000000..339198580 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/operators.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 +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +// Arithmetic operators +BOOST_HANA_CONSTANT_CHECK(+hana::int_c<1> == hana::int_c<1>); +BOOST_HANA_CONSTANT_CHECK(-hana::int_c<1> == hana::int_c<-1>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<1> + hana::int_c<2> == hana::int_c<3>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<1> - hana::int_c<2> == hana::int_c<-1>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<3> * hana::int_c<2> == hana::int_c<6>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<6> / hana::int_c<3> == hana::int_c<2>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<6> % hana::int_c<4> == hana::int_c<2>); +BOOST_HANA_CONSTANT_CHECK(~hana::int_c<6> == hana::int_c<~6>); +BOOST_HANA_CONSTANT_CHECK((hana::int_c<6> & hana::int_c<3>) == hana::int_c<6 & 3>); +BOOST_HANA_CONSTANT_CHECK((hana::int_c<4> | hana::int_c<2>) == hana::int_c<4 | 2>); +BOOST_HANA_CONSTANT_CHECK((hana::int_c<6> ^ hana::int_c<3>) == hana::int_c<6 ^ 3>); +BOOST_HANA_CONSTANT_CHECK((hana::int_c<6> << hana::int_c<3>) == hana::int_c<(6 << 3)>); +BOOST_HANA_CONSTANT_CHECK((hana::int_c<6> >> hana::int_c<3>) == hana::int_c<(6 >> 3)>); + +// Comparison operators +BOOST_HANA_CONSTANT_CHECK(hana::int_c<0> == hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<1> != hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<0> < hana::int_c<1>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<0> <= hana::int_c<1>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<0> <= hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<1> > hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<1> >= hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<0> >= hana::int_c<0>); + +// Logical operators +BOOST_HANA_CONSTANT_CHECK(hana::int_c<3> || hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(hana::int_c<3> && hana::int_c<1>); +BOOST_HANA_CONSTANT_CHECK(!hana::int_c<0>); +BOOST_HANA_CONSTANT_CHECK(!!hana::int_c<3>); + +int main() { } diff --git a/src/boost/libs/hana/test/integral_constant/orderable.cpp b/src/boost/libs/hana/test/integral_constant/orderable.cpp new file mode 100644 index 000000000..b32b33c53 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/orderable.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 +#include + +#include +namespace hana = boost::hana; + + +int main() { + constexpr auto ints = hana::make_tuple( + hana::int_c<-10>, + hana::int_c<-2>, + hana::int_c<0>, + hana::int_c<1>, + hana::int_c<3>, + hana::int_c<4> + ); + + hana::test::TestOrderable>{ints}; +} diff --git a/src/boost/libs/hana/test/integral_constant/std_api.cpp b/src/boost/libs/hana/test/integral_constant/std_api.cpp new file mode 100644 index 000000000..95e9d5fe3 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/std_api.cpp @@ -0,0 +1,44 @@ +// 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 + +#include +#include +namespace hana = boost::hana; + + +// operator() +static_assert(hana::size_c<0>() == 0, ""); +static_assert(hana::size_c<1>() == 1, ""); +static_assert(hana::int_c<-3>() == -3, ""); + +// decltype(operator()) +static_assert(std::is_same()), std::size_t>{}, ""); +static_assert(std::is_same()), int>{}, ""); + +// conversions +constexpr std::size_t a = hana::size_c<0>, b = hana::size_c<1>; +static_assert(a == 0 && b == 1, ""); + +constexpr int c = hana::int_c<0>, d = hana::int_c<-3>; +static_assert(c == 0 && d == -3, ""); + +// nested ::value +static_assert(decltype(hana::int_c<1>)::value == 1, ""); + +// nested ::type +static_assert(std::is_same< + decltype(hana::int_c<1>)::type, + std::remove_cv_t)> +>{}, ""); + +// nested ::value_type +static_assert(std::is_same)::value_type, int>{}, ""); + +// inherits from std::integral_constant +static_assert(std::is_base_of, + hana::integral_constant>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/integral_constant/tag.cpp b/src/boost/libs/hana/test/integral_constant/tag.cpp new file mode 100644 index 000000000..35b420201 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/tag.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 +#include +#include + +#include +namespace hana = boost::hana; + + +// Make sure we have the right tag, even when including ext/std/integral_constant.hpp +static_assert(std::is_same< + hana::tag_of_t>, + hana::integral_constant_tag +>{}, ""); + +struct derived : hana::integral_constant { }; +static_assert(std::is_same< + hana::tag_of_t, + hana::integral_constant_tag +>{}, ""); + + +int main() { } diff --git a/src/boost/libs/hana/test/integral_constant/times.cpp b/src/boost/libs/hana/test/integral_constant/times.cpp new file mode 100644 index 000000000..51f354fd7 --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/times.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 +#include +#include +#include +namespace hana = boost::hana; + + +void function() { } +void function_index(...) { } + +int main() { + // times member function + { + int counter = 0; + hana::int_c<3>.times([&] { ++counter; }); + BOOST_HANA_RUNTIME_CHECK(counter == 3); + + // Call .times with a normal function used to fail. + hana::int_c<3>.times(function); + + // make sure times can be accessed as a static member function too + decltype(hana::int_c<5>)::times([]{ }); + + // make sure xxx.times can be used as a function object + auto z = hana::int_c<5>.times; + (void)z; + } + + // times.with_index + { + int index = 0; + hana::int_c<3>.times.with_index([&](auto i) { + static_assert(hana::is_an>(i), ""); + BOOST_HANA_RUNTIME_CHECK(hana::value(i) == index); + ++index; + }); + + // Calling .times.with_index with a normal function used to fail. + hana::int_c<3>.times.with_index(function_index); + + // make sure times.with_index can be accessed as a static member + // function too + auto times = hana::int_c<5>.times; + decltype(times)::with_index([](auto) { }); + + // make sure xxx.times.with_index can be used as a function object + auto z = hana::int_c<5>.times.with_index; + (void)z; + + // make sure we're calling the function in the right order + int current = 0; + hana::int_c<5>.times.with_index([&](auto i) { + BOOST_HANA_RUNTIME_CHECK(hana::value(i) == current); + ++current; + }); + } +} diff --git a/src/boost/libs/hana/test/integral_constant/udl.cpp b/src/boost/libs/hana/test/integral_constant/udl.cpp new file mode 100644 index 000000000..05b0186fc --- /dev/null +++ b/src/boost/libs/hana/test/integral_constant/udl.cpp @@ -0,0 +1,75 @@ +// 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using namespace hana::literals; + + +BOOST_HANA_CONSTANT_CHECK(0_c == hana::llong_c<0>); +BOOST_HANA_CONSTANT_CHECK(1_c == hana::llong_c<1>); +BOOST_HANA_CONSTANT_CHECK(12_c == hana::llong_c<12>); +BOOST_HANA_CONSTANT_CHECK(123_c == hana::llong_c<123>); +BOOST_HANA_CONSTANT_CHECK(1234567_c == hana::llong_c<1234567>); +BOOST_HANA_CONSTANT_CHECK(-34_c == hana::llong_c<-34>); + + +static_assert(std::is_same< + decltype(-1234_c)::value_type, + long long +>{}, ""); +static_assert(-1234_c == -1234ll, ""); +BOOST_HANA_CONSTANT_CHECK(-12_c < 0_c); + + +constexpr auto deadbeef = hana::llong_c<0xDEADBEEF>; + +//hexadecimal +BOOST_HANA_CONSTANT_CHECK(deadbeef == 0xDEADBEEF_c); +BOOST_HANA_CONSTANT_CHECK(deadbeef == 0xDeAdBeEf_c); +BOOST_HANA_CONSTANT_CHECK(deadbeef == 0xdeadbeef_c); + +//decimal +BOOST_HANA_CONSTANT_CHECK(deadbeef == hana::llong_c<3735928559>); // test the test +BOOST_HANA_CONSTANT_CHECK(deadbeef == 3735928559_c); + +//binary +BOOST_HANA_CONSTANT_CHECK(deadbeef == hana::llong_c<0b11011110101011011011111011101111>); // test the test +BOOST_HANA_CONSTANT_CHECK(deadbeef == 0b11011110101011011011111011101111_c); + +//octal +BOOST_HANA_CONSTANT_CHECK(deadbeef == hana::llong_c<033653337357>); // test the test +BOOST_HANA_CONSTANT_CHECK(deadbeef == 033653337357_c); + +BOOST_HANA_CONSTANT_CHECK(0x0_c == hana::llong_c<0>); +BOOST_HANA_CONSTANT_CHECK(0b0_c == hana::llong_c<0>); +BOOST_HANA_CONSTANT_CHECK(00_c == hana::llong_c<0>); + +BOOST_HANA_CONSTANT_CHECK(0x1_c == hana::llong_c<1>); +BOOST_HANA_CONSTANT_CHECK(0b1_c == hana::llong_c<1>); +BOOST_HANA_CONSTANT_CHECK(01_c == hana::llong_c<1>); + +BOOST_HANA_CONSTANT_CHECK(-0x1_c == hana::llong_c<-1>); +BOOST_HANA_CONSTANT_CHECK(-0b1_c == hana::llong_c<-1>); +BOOST_HANA_CONSTANT_CHECK(-01_c == hana::llong_c<-1>); + +BOOST_HANA_CONSTANT_CHECK(0x10_c == hana::llong_c<16>); +BOOST_HANA_CONSTANT_CHECK(0b10_c == hana::llong_c<2>); +BOOST_HANA_CONSTANT_CHECK(010_c == hana::llong_c<8>); + +BOOST_HANA_CONSTANT_CHECK(-0x10_c == hana::llong_c<-16>); +BOOST_HANA_CONSTANT_CHECK(-0b10_c == hana::llong_c<-2>); +BOOST_HANA_CONSTANT_CHECK(-010_c == hana::llong_c<-8>); + +// digit separators +static_assert(123'456 == 123456, ""); // test the test +BOOST_HANA_CONSTANT_CHECK(123'456_c == hana::llong_c<123456>); + +int main() { } 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 +namespace hana = boost::hana; + + +template struct F { struct type; }; +struct M { template struct apply { struct type; }; }; +struct T; + +int main() { + // See http://llvm.org/bugs/show_bug.cgi?id=20046 + [](auto) { return hana::trait; }(1); + [](auto) { return hana::type_c; }(1); + [](auto) { return hana::template_; }(1); + [](auto) { return hana::metafunction; }(1); + [](auto) { return hana::metafunction_class; }(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 +#include +#include +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(); +constexpr auto employee_members = hana::accessors(); + +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 +#include +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 +#include +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 + +#include + +#include +namespace hana = boost::hana; + + +template +decltype(auto) call_always(T&& x) { + return hana::always(std::forward(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 + +#include +namespace hana = boost::hana; + + +constexpr int f() { + // copy-assign + { + hana::tuple xs{1}; + hana::tuple ys{1}; + xs = xs; + ys = xs; + } + + // move-assign + { + hana::tuple xs{1}, xxs{1}; + hana::tuple 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 +#include +#include + +#include +namespace hana = boost::hana; + + +using Vector = std::vector; + +static_assert( + sizeof(hana::tuple< + hana::pair, Vector>, + hana::pair, Vector>, + hana::pair, Vector>, + hana::pair, Vector> + >) + == + sizeof(hana::tuple) +, ""); + +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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +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, 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, 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, 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, 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, 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, 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, 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, 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, + hana::tuple_c + ) + ) + ); + } + { + // test with lvalue + constexpr auto x = hana::group(hana::tuple_c, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_tuple( + hana::tuple_c, + hana::tuple_c + ) + ) + ); + } + + // 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, + hana::tuple_c, + 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, 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, 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, hana::id)); + BOOST_HANA_CONSTANT_CHECK(!hana::none_of(hana::tuple_c, hana::id)); + BOOST_HANA_CONSTANT_CHECK(!hana::none_of(hana::tuple_c, 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, + hana::tuple_c + ) + ) + ); + } + { + // test with lvalue + constexpr auto x = hana::partition(hana::tuple_c, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, + hana::make_pair( + hana::tuple_c, + hana::tuple_c + ) + ) + ); + } + + // 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, 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, + 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)); + } + { + // test with lvalue + constexpr auto x = hana::sort(hana::tuple_c, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c)); + } + // 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, + hana::tuple_c + ) + ) + ); + } + { + // test with an lvalue + constexpr auto x = hana::span(hana::tuple_c, hana::id); + BOOST_HANA_CONSTANT_CHECK( + hana::equal(x, + hana::make_pair( + hana::tuple_c, + hana::tuple_c + ) + ) + ); + } + + // 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)); + } + { + // test with lvalue + constexpr auto x = hana::take_while(hana::tuple_c, hana::id); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c)); + } + + // 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)); + } + { + // test with lvalue + constexpr auto x = hana::unique(hana::tuple_c, hana::plus); + BOOST_HANA_CONSTANT_CHECK(hana::equal(x, hana::tuple_c)); + } + + // 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + { + auto set = hana::make_set(hana::int_c<1>, hana::integral_c); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(set, hana::int_c<1>)); + BOOST_HANA_CONSTANT_CHECK(hana::contains(set, hana::integral_c)); + } + + { + auto map = hana::make_map( + hana::make_pair(hana::int_c<1>, 1), + hana::make_pair(hana::integral_c, 'x') + ); + + BOOST_HANA_CONSTANT_CHECK(hana::contains(map, hana::int_c<1>)); + BOOST_HANA_CONSTANT_CHECK(hana::contains(map, hana::integral_c)); + } +} 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 +#include +#include +#include +#include +#include +#include +#include +#include + +namespace hana = boost::hana; + +int main() { + constexpr auto type = hana::type_c; + + BOOST_HANA_CONSTANT_CHECK( + hana::is_an>( + hana::traits::extent(type, hana::uint_c<1>) + ) + ); + + // Check that we can multiple extents in size_t's ring + hana::product>( + 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 +#include +#include +#include + +#include +#include +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::value, ""); + static_assert(std::is_default_constructible::value, ""); + static_assert(std::is_default_constructible::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 +#include +#include +#include +namespace hana = boost::hana; + + +struct predicate { hana::true_ operator()(...) const; }; + +int main() { + auto types = hana::experimental::types{}; + hana::replace_if(types, predicate{}, hana::type{}); +} 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 +#include +namespace hana = boost::hana; + + +using T = int; + +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); +BOOST_HANA_CONSTANT_CHECK(hana::IntegralConstant>{}); + +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 +#include +#include + +#include +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 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +// A simple infinite Iterable. +template +struct counter { }; + +namespace boost { namespace hana { + template + struct at_impl> { + template + static constexpr auto apply(counter, N const&) { + return hana::int_c; + } + }; + + template + struct drop_front_impl> { + template + static constexpr auto apply(counter, N) { return counter{}; } + }; + + template + struct is_empty_impl> { + static constexpr auto apply(counter) { 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 +#include +#include +#include +#include +#include +#include + +#include +#include +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_<2>>; + using Pair = hana::pair, Nested>; + Pair pair{}; + + auto a = hana::first(pair); + static_assert(std::is_same>{}, ""); + + auto b = hana::second(pair); + static_assert(std::is_same{}, ""); + } + + { + using Nested = hana::basic_tuple, hana::int_<2>>; + using Tuple = hana::basic_tuple, Nested>; + Tuple tuple{}; + + auto a = hana::at_c<0>(tuple); + static_assert(std::is_same>{}, ""); + + auto b = hana::at_c<1>(tuple); + static_assert(std::is_same{}, ""); + } + + // Original test case submitted by Vittorio Romeo + { + hana::pair, hana::bool_> 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 +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 +#include +#include +#include +#include +#include + +#include +#include +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 +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(); + auto get_array = hana::second(hana::at_c<0>(accessors)); + static_assert(std::is_same{}, ""); + 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(); + auto get_array = hana::second(hana::at_c<0>(accessors)); + static_assert(std::is_same{}, ""); + 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 + +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 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 +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +using T = decltype(hana::int_c<1>); + +static_assert(hana::Comparable::value, ""); +static_assert(hana::Orderable::value, ""); +static_assert(hana::Monoid::value, ""); +static_assert(hana::Group::value, ""); +static_assert(hana::Ring::value, ""); +static_assert(hana::EuclideanRing::value, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/lazy.cpp b/src/boost/libs/hana/test/lazy.cpp new file mode 100644 index 000000000..87d9f2e77 --- /dev/null +++ b/src/boost/libs/hana/test/lazy.cpp @@ -0,0 +1,342 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +namespace boost { namespace hana { + // We provide this instance for unit tests only because it is _so_ much + // more convenient, but this instance is too dangerous for general usage. + // See the documentation of `hana::lazy` for more info. + template <> + struct equal_impl { + template + static constexpr auto apply(X x, Y y) + { return hana::equal(hana::eval(x), hana::eval(y)); } + }; +}} + +auto invalid = [](auto x) +{ return x.this_function_must_not_be_instantiated; }; + + +int main() { + hana::test::_injection<0> f{}; + + auto eqs = hana::make_tuple( + hana::make_lazy(ct_eq<0>{}), + hana::make_lazy(ct_eq<1>{}), + hana::make_lazy(ct_eq<2>{}) + ); + auto eq_elems = hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<1>{}); + auto nested = hana::make_tuple( + hana::make_lazy(hana::make_lazy(ct_eq<0>{})), + hana::make_lazy(hana::make_lazy(ct_eq<1>{})), + hana::make_lazy(hana::make_lazy(ct_eq<2>{})) + ); + + ////////////////////////////////////////////////////////////////////////// + // Lazy methods + ////////////////////////////////////////////////////////////////////////// + { + // lazy + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_lazy(f)(), + hana::make_lazy(f()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_lazy(f)(ct_eq<0>{}), + hana::make_lazy(f(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_lazy(f)(ct_eq<0>{}, ct_eq<1>{}), + hana::make_lazy(f(ct_eq<0>{}, ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_lazy(f)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_lazy(f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + + // The function is not applied. + hana::make_lazy(invalid)(); + hana::make_lazy(invalid)(ct_eq<0>{}); + hana::make_lazy(invalid)(ct_eq<0>{}, ct_eq<1>{}); + hana::make_lazy(invalid)(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + } + + // eval + { + // With lazy expressions + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval(hana::make_lazy(ct_eq<0>{})), + ct_eq<0>{} + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval(hana::make_lazy(ct_eq<1>{})), + ct_eq<1>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval(hana::make_lazy(f)()), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval(hana::make_lazy(f)(ct_eq<3>{})), + f(ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval(hana::make_lazy(f)(ct_eq<3>{}, ct_eq<4>{})), + f(ct_eq<3>{}, ct_eq<4>{}) + )); + + // Should call a nullary function + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval([]{ return ct_eq<3>{}; }), + ct_eq<3>{} + )); + + // Should call a unary function with hana::id. + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval([](auto _) { return _(ct_eq<3>{}); }), + ct_eq<3>{} + )); + + // For overloaded function objects that are both nullary and unary, + // the nullary overload should be preferred. + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::eval(f), + f() + )); + } + + // Make sure this does not move from a destroyed object, as that + // used to be the case. + { + auto x = hana::flatten(hana::make_lazy(hana::make_lazy(Tracked{1}))); + auto z = hana::eval(x); (void)z; + } + + // In some cases where a type has a constructor that is way too + // general, copying a lazy value holding an object of that type + // could trigger the instantiation of that constructor. If that + // constructor was ill-formed, the compilation would fail. We + // make sure this does not happen. + { + { + auto expr = hana::make_lazy(hana::test::trap_construct{}); + auto implicit_copy = expr; (void)implicit_copy; + decltype(expr) explicit_copy(expr); (void)explicit_copy; + } + + { + auto expr = hana::make_lazy(hana::test::trap_construct{})(); + auto implicit_copy = expr; (void)implicit_copy; + decltype(expr) explicit_copy(expr); (void)explicit_copy; + } + } + } + + ////////////////////////////////////////////////////////////////////////// + // Functor + ////////////////////////////////////////////////////////////////////////// + { + // transform + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::make_lazy(ct_eq<0>{}), f), + hana::make_lazy(f(ct_eq<0>{})) + )); + } + + // laws + hana::test::TestFunctor{eqs, eq_elems}; + } + + ////////////////////////////////////////////////////////////////////////// + // Applicative + ////////////////////////////////////////////////////////////////////////// + { + // ap + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::make_lazy(f), hana::make_lazy(ct_eq<0>{})), + hana::make_lazy(f(ct_eq<0>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::make_lazy(f), hana::make_lazy(ct_eq<0>{}), hana::make_lazy(ct_eq<1>{})), + hana::make_lazy(f(ct_eq<0>{}, ct_eq<1>{})) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::make_lazy(f), hana::make_lazy(ct_eq<0>{}), hana::make_lazy(ct_eq<1>{}), hana::make_lazy(ct_eq<2>{})), + hana::make_lazy(f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{})) + )); + + // The function is not applied. + hana::ap(hana::make_lazy(invalid), hana::make_lazy(ct_eq<0>{})); + hana::ap(hana::make_lazy(invalid), hana::make_lazy(ct_eq<0>{}), hana::make_lazy(ct_eq<1>{})); + hana::ap(hana::make_lazy(invalid), hana::make_lazy(ct_eq<0>{}), hana::make_lazy(ct_eq<1>{}), hana::make_lazy(ct_eq<2>{})); + } + + // lift + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lift(ct_eq<0>{}), + hana::make_lazy(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lift(ct_eq<1>{}), + hana::make_lazy(ct_eq<1>{}) + )); + } + + // laws + hana::test::TestApplicative{eqs}; + } + + ////////////////////////////////////////////////////////////////////////// + // Monad + ////////////////////////////////////////////////////////////////////////// + { + auto f_ = hana::compose(hana::make_lazy, f); + + // chain + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(hana::make_lazy(ct_eq<0>{}), f_), + f_(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(hana::make_lazy(ct_eq<1>{}), f_), + f_(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_lazy(ct_eq<1>{}) | f_, + f_(ct_eq<1>{}) + )); + } + + // flatten + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(hana::make_lazy(hana::make_lazy(ct_eq<0>{}))), + hana::make_lazy(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(hana::make_lazy(hana::make_lazy(ct_eq<1>{}))), + hana::make_lazy(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(hana::make_lazy(hana::make_lazy(hana::make_lazy(ct_eq<1>{})))), + hana::make_lazy(hana::make_lazy(ct_eq<1>{})) + )); + } + + // laws + hana::test::TestMonad{eqs, nested}; + } + + ////////////////////////////////////////////////////////////////////////// + // Comonad + ////////////////////////////////////////////////////////////////////////// + { + // extract + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::extract(hana::make_lazy(ct_eq<4>{})), + ct_eq<4>{} + )); + } + + // duplicate + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::duplicate(hana::make_lazy(ct_eq<4>{})), + hana::make_lazy(hana::make_lazy(ct_eq<4>{})) + )); + } + + // extend + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::extend(hana::make_lazy(ct_eq<4>{}), f), + hana::make_lazy(f(hana::make_lazy(ct_eq<4>{}))) + )); + } + + // laws + hana::test::TestComonad{eqs}; + } + + ////////////////////////////////////////////////////////////////////////// + // Make sure the monadic chain is evaluated in the right order. + ////////////////////////////////////////////////////////////////////////// + { + std::array executed = {{false, false, false}}; + int dummy = 0; + + std::cout << "creating the monadic chain...\n"; + auto chain = hana::make_lazy(dummy) + | [&](int dummy) { + std::cout << "executing the first computation...\n"; + executed[0] = true; + BOOST_HANA_RUNTIME_CHECK( + executed == std::array{{true, false, false}} + ); + return hana::make_lazy(dummy); + } + | [&](int dummy) { + std::cout << "executing the second computation...\n"; + executed[1] = true; + BOOST_HANA_RUNTIME_CHECK( + executed == std::array{{true, true, false}} + ); + return hana::make_lazy(dummy); + } + | [&](int dummy) { + std::cout << "executing the third computation...\n"; + executed[2] = true; + BOOST_HANA_RUNTIME_CHECK( + executed == std::array{{true, true, true}} + ); + return hana::make_lazy(dummy); + }; + + BOOST_HANA_RUNTIME_CHECK( + executed == std::array{{false, false, false}} + ); + + std::cout << "evaluating the chain...\n"; + hana::eval(chain); + } +} diff --git a/src/boost/libs/hana/test/logical.cpp b/src/boost/libs/hana/test/logical.cpp new file mode 100644 index 000000000..b4148e482 --- /dev/null +++ b/src/boost/libs/hana/test/logical.cpp @@ -0,0 +1,84 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::TestLogical{hana::make_tuple(true, false)}; + + // eval_if + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::eval_if(true, hana::always(1), hana::always(2)), + 1 + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::eval_if(false, hana::always(1), hana::always(2)), + 2 + )); + } + + // not_ + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::not_(true), false)); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::not_(false), true)); + } + + // while_ + { + auto less_than = [](auto n) { + return [n](auto v) { return v.size() < n; }; + }; + auto f = [](auto v) { + v.push_back(v.size()); + return v; + }; + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(0u), std::vector{}, f), + std::vector{} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(1u), std::vector{}, f), + std::vector{0} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(2u), std::vector{}, f), + std::vector{0, 1} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(3u), std::vector{}, f), + std::vector{0, 1, 2} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(4u), std::vector{}, f), + std::vector{0, 1, 2, 3} + )); + + // Make sure it can be called with an lvalue state: + std::vector v{}; + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(4u), v, f), + std::vector{0, 1, 2, 3} + )); + } +} diff --git a/src/boost/libs/hana/test/map/any_of.cpp b/src/boost/libs/hana/test/map/any_of.cpp new file mode 100644 index 000000000..8d352c56d --- /dev/null +++ b/src/boost/libs/hana/test/map/any_of.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + hana::make_map(), + hana::equal.to(key<1>() + )))); + + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + hana::make_map(p<1, 1>()), + hana::equal.to(key<1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + hana::make_map(p<1, 1>()), + hana::equal.to(key<2>()) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::equal.to(key<1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::equal.to(key<2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::equal.to(key<3>()) + ))); +} diff --git a/src/boost/libs/hana/test/map/assign.copy.cpp b/src/boost/libs/hana/test/map/assign.copy.cpp new file mode 100644 index 000000000..d5d098392 --- /dev/null +++ b/src/boost/libs/hana/test/map/assign.copy.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 +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; +namespace test = hana::test; + + +int main() { + { + using Map = hana::map<>; + Map map0; + Map map; + map0 = map; + } + { + using Map = hana::map, int>>; + Map map0 = hana::make_map(hana::make_pair(test::ct_eq<0>{}, 999)); + Map map = hana::make_map(hana::make_pair(test::ct_eq<0>{}, 4)); + map0 = map; + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<0>{}) == 4); + } + { + using Map = hana::map, int>, + hana::pair, char>>; + Map map0 = hana::make_map(hana::make_pair(test::ct_eq<0>{}, 999), + hana::make_pair(test::ct_eq<1>{}, 'z')); + Map map = hana::make_map(hana::make_pair(test::ct_eq<0>{}, 4), + hana::make_pair(test::ct_eq<1>{}, 'a')); + map0 = map; + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<0>{}) == 4); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<1>{}) == 'a'); + } + { + using Map = hana::map, int>, + hana::pair, char>, + hana::pair, std::string>>; + Map map0 = hana::make_map(hana::make_pair(test::ct_eq<0>{}, 999), + hana::make_pair(test::ct_eq<1>{}, 'z'), + hana::make_pair(test::ct_eq<2>{}, std::string{"zzzzzzzz"})); + Map map = hana::make_map(hana::make_pair(test::ct_eq<0>{}, 4), + hana::make_pair(test::ct_eq<1>{}, 'a'), + hana::make_pair(test::ct_eq<2>{}, std::string{"abc"})); + map0 = map; + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<0>{}) == 4); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<1>{}) == 'a'); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<2>{}) == "abc"); + } +} diff --git a/src/boost/libs/hana/test/map/assign.move.cpp b/src/boost/libs/hana/test/map/assign.move.cpp new file mode 100644 index 000000000..a04f55e4a --- /dev/null +++ b/src/boost/libs/hana/test/map/assign.move.cpp @@ -0,0 +1,92 @@ +// 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 +#include +#include +#include + +#include + +#include +#include +namespace hana = boost::hana; +namespace test = hana::test; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + int get() const {return data_;} + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } + bool operator< (const MoveOnly& x) const { return data_ < x.data_; } +}; + +int main() { + { + using Map = hana::map<>; + Map map0; + Map map; + map0 = std::move(map); + } + { + using Map = hana::map, MoveOnly>>; + Map map0 = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{999})); + Map map = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{4})); + map0 = std::move(map); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<0>{}) == MoveOnly{4}); + } + { + using Map = hana::map, MoveOnly>, + hana::pair, MoveOnly>>; + Map map0 = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{999}), + hana::make_pair(test::ct_eq<1>{}, MoveOnly{888})); + Map map = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{4}), + hana::make_pair(test::ct_eq<1>{}, MoveOnly{5})); + map0 = std::move(map); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<0>{}) == MoveOnly{4}); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<1>{}) == MoveOnly{5}); + } + { + using Map = hana::map, MoveOnly>, + hana::pair, MoveOnly>, + hana::pair, MoveOnly>>; + Map map0 = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{999}), + hana::make_pair(test::ct_eq<1>{}, MoveOnly{888}), + hana::make_pair(test::ct_eq<2>{}, MoveOnly{777})); + Map map = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{4}), + hana::make_pair(test::ct_eq<1>{}, MoveOnly{5}), + hana::make_pair(test::ct_eq<2>{}, MoveOnly{6})); + map0 = std::move(map); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<0>{}) == MoveOnly{4}); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<1>{}) == MoveOnly{5}); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<2>{}) == MoveOnly{6}); + } + { + using Map = hana::map, MoveOnly>, + hana::pair, MoveOnly>, + hana::pair, MoveOnly>, + hana::pair, std::string>>; + Map map0 = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{999}), + hana::make_pair(test::ct_eq<1>{}, MoveOnly{888}), + hana::make_pair(test::ct_eq<2>{}, MoveOnly{777}), + hana::make_pair(test::ct_eq<3>{}, std::string{"zzzzz"})); + Map map = hana::make_map(hana::make_pair(test::ct_eq<0>{}, MoveOnly{4}), + hana::make_pair(test::ct_eq<1>{}, MoveOnly{5}), + hana::make_pair(test::ct_eq<2>{}, MoveOnly{6}), + hana::make_pair(test::ct_eq<3>{}, std::string{"abc"})); + map0 = std::move(map); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<0>{}) == MoveOnly{4}); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<1>{}) == MoveOnly{5}); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<2>{}) == MoveOnly{6}); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(map0, test::ct_eq<3>{}) == std::string{"abc"}); + } +} diff --git a/src/boost/libs/hana/test/map/at_key.collisions.cpp b/src/boost/libs/hana/test/map/at_key.collisions.cpp new file mode 100644 index 000000000..3df10c4a0 --- /dev/null +++ b/src/boost/libs/hana/test/map/at_key.collisions.cpp @@ -0,0 +1,149 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct A { }; +struct B { }; + +struct the_hash; + +namespace boost { namespace hana { + template <> + struct hash_impl { + static constexpr auto apply(A const&) { + return hana::type_c; + } + }; + + template <> + struct hash_impl { + static constexpr auto apply(B const&) { + return hana::type_c; + } + }; + + template <> + struct equal_impl { + static constexpr auto apply(A const&, A const&) { + return hana::true_c; + } + }; + + template <> + struct equal_impl { + static constexpr auto apply(B const&, B const&) { + return hana::true_c; + } + }; +}} + +int main() { + constexpr auto key1 = A{}; + constexpr auto key2 = B{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal(key1, key1)); + BOOST_HANA_CONSTANT_CHECK(hana::equal(key2, key2)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(key1, key2))); + + // ensure the hashes actually collide + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::hash(key1), hana::hash(key2))); + + { + auto map = hana::to_map(hana::make_tuple( + hana::make_pair(key1, key1), + hana::make_pair(key2, key2) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key1), + key1 + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key2), + key2 + )); + } + + { + auto map = hana::to_map(hana::make_tuple( + hana::make_pair(key2, key2), + hana::make_pair(key1, key1) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key1), + key1 + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key2), + key2 + )); + } + + { + auto map = hana::to_map(hana::make_tuple( + hana::make_pair(key1, key1), + hana::make_pair(hana::int_c<56>, hana::int_c<56>), + hana::make_pair(key2, key2) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key1), + key1 + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, hana::int_c<56>), + hana::int_c<56> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key2), + key2 + )); + } + + { + auto map = hana::to_map(hana::make_tuple( + hana::make_pair(key1, key1), + hana::make_pair(hana::int_c<56>, hana::int_c<56>), + hana::make_pair(key2, key2), + hana::make_pair(hana::int_c<42>, hana::int_c<42>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key1), + key1 + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, hana::int_c<56>), + hana::int_c<56> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, key2), + key2 + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(map, hana::int_c<42>), + hana::int_c<42> + )); + } +} diff --git a/src/boost/libs/hana/test/map/at_key.cpp b/src/boost/libs/hana/test/map/at_key.cpp new file mode 100644 index 000000000..c948216cb --- /dev/null +++ b/src/boost/libs/hana/test/map/at_key.cpp @@ -0,0 +1,60 @@ +// 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 +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(hana::make_map(p<0, 0>()), key<0>()), + val<0>() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(hana::make_map(p<0, 0>(), p<1,1>()), key<0>()), + val<0>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(hana::make_map(p<0, 0>(), p<1,1>()), key<1>()), + val<1>() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<0>()), + val<0>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<1>()), + val<1>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at_key(hana::make_map(p<0, 0>(), p<1,1>(), p<2,2>()), key<2>()), + val<2>() + )); + + // check operators + auto m = hana::make_map(p<2, 2>(), p<1, 1>()); + auto const const_m = hana::make_map(p<2, 2>(), p<1, 1>()); + BOOST_HANA_CONSTANT_CHECK(hana::equal(m[key<1>()], val<1>())); + BOOST_HANA_CONSTANT_CHECK(hana::equal(const_m[key<1>()], val<1>())); + BOOST_HANA_CONSTANT_CHECK(hana::equal(std::move(m)[key<1>()], val<1>())); +} diff --git a/src/boost/libs/hana/test/map/at_key.ref.cpp b/src/boost/libs/hana/test/map/at_key.ref.cpp new file mode 100644 index 000000000..c845bc134 --- /dev/null +++ b/src/boost/libs/hana/test/map/at_key.ref.cpp @@ -0,0 +1,84 @@ +// 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +T const& cref(T& t) { return t; } + +int main() { + // using at_key + { + auto xs = hana::make_map( + hana::make_pair(hana::int_c<0>, 0), + hana::make_pair(hana::int_c<1>, '1'), + hana::make_pair(hana::int_c<2>, 2.2) + ); + + // Make sure we return lvalue-references + BOOST_HANA_RUNTIME_CHECK(hana::at_key(xs, hana::int_c<0>) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(xs, hana::int_c<1>) == '1'); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(xs, hana::int_c<2>) == 2.2); + + int& a = hana::at_key(xs, hana::int_c<0>); + char& b = hana::at_key(xs, hana::int_c<1>); + double& c = hana::at_key(xs, hana::int_c<2>); + a = 9; + b = '9'; + c = 9.9; + + // Make sure we return lvalue-references to const on a const map + int const& ca = hana::at_key(cref(xs), hana::int_c<0>); + char const& cb = hana::at_key(cref(xs), hana::int_c<1>); + double const& cc = hana::at_key(cref(xs), hana::int_c<2>); + + BOOST_HANA_RUNTIME_CHECK(ca == 9); + BOOST_HANA_RUNTIME_CHECK(cb == '9'); + BOOST_HANA_RUNTIME_CHECK(cc == 9.9); + } + + // using operator[] + { + auto xs = hana::make_map( + hana::make_pair(hana::int_c<0>, 0), + hana::make_pair(hana::int_c<1>, '1'), + hana::make_pair(hana::int_c<2>, 2.2) + ); + + BOOST_HANA_RUNTIME_CHECK(xs[hana::int_c<0>] == 0); + BOOST_HANA_RUNTIME_CHECK(xs[hana::int_c<1>] == '1'); + BOOST_HANA_RUNTIME_CHECK(xs[hana::int_c<2>] == 2.2); + + xs[hana::int_c<0>] = 9; + xs[hana::int_c<1>] = '9'; + xs[hana::int_c<2>] = 9.9; + + BOOST_HANA_RUNTIME_CHECK(xs[hana::int_c<0>] == 9); + BOOST_HANA_RUNTIME_CHECK(xs[hana::int_c<1>] == '9'); + BOOST_HANA_RUNTIME_CHECK(xs[hana::int_c<2>] == 9.9); + } + + // Make sure we return a rvalue-reference from a temporary map + // (https://github.com/boostorg/hana/issues/90) + { + auto xs = hana::make_map( + hana::make_pair(hana::int_c<0>, 0), + hana::make_pair(hana::int_c<1>, '1'), + hana::make_pair(hana::int_c<2>, 2.2) + ); + + char&& c = hana::at_key(std::move(xs), hana::int_c<1>); + BOOST_HANA_RUNTIME_CHECK(hana::at_key(xs, hana::int_c<1>) == '1'); + c = '9'; + BOOST_HANA_RUNTIME_CHECK(hana::at_key(xs, hana::int_c<1>) == '9'); + } +} diff --git a/src/boost/libs/hana/test/map/at_key.stackoverflow.cpp b/src/boost/libs/hana/test/map/at_key.stackoverflow.cpp new file mode 100644 index 000000000..7f71799a3 --- /dev/null +++ b/src/boost/libs/hana/test/map/at_key.stackoverflow.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 +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +// +// Make sure that http://stackoverflow.com/q/32702383/627587 works. +// + +auto at = [](auto& map, auto key) -> auto& { + return map[key]; +}; + +template +auto& traverse(Map& map, Keys const& keys){ + return hana::fold_left(keys, map, at); +} + +int main() { + auto xs = hana::make_map(hana::make_pair(hana::int_c<0>, + hana::make_map(hana::make_pair(hana::int_c<1>, + hana::make_map(hana::make_pair(hana::int_c<2>, + hana::make_map(hana::make_pair(hana::int_c<3>, 10)))))))); + + int& i = traverse(xs, hana::range_c); + BOOST_HANA_RUNTIME_CHECK(i == 10); + i = 99; + BOOST_HANA_RUNTIME_CHECK(traverse(xs, hana::range_c) == 99); +} diff --git a/src/boost/libs/hana/test/map/cnstr.copy.cpp b/src/boost/libs/hana/test/map/cnstr.copy.cpp new file mode 100644 index 000000000..881de02bb --- /dev/null +++ b/src/boost/libs/hana/test/map/cnstr.copy.cpp @@ -0,0 +1,114 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct NoCopy { + NoCopy() = default; + NoCopy(NoCopy const&) = delete; + friend auto operator==(NoCopy const&, NoCopy const&) { return hana::true_c; } + friend auto operator!=(NoCopy const&, NoCopy const&) { return hana::false_c; } +}; + +// Note: It is also useful to check with a non-empty class, because that +// triggers different instantiations due to EBO. +struct NoCopy_nonempty { + NoCopy_nonempty() = default; + NoCopy_nonempty(NoCopy_nonempty const&) = delete; + int i; + friend auto operator==(NoCopy_nonempty const&, NoCopy_nonempty const&) { return hana::true_c; } + friend auto operator!=(NoCopy_nonempty const&, NoCopy_nonempty const&) { return hana::false_c; } +}; + +namespace boost { namespace hana { + template <> + struct hash_impl { + static constexpr auto apply(NoCopy const&) + { return hana::type_c; }; + }; + + template <> + struct hash_impl { + static constexpr auto apply(NoCopy_nonempty const&) + { return hana::type_c; }; + }; +}} + + +int main() { + { + auto t0 = hana::make_map(); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_explicit; + (void)t_implicit; + } + { + auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, hana::int_c<20>)); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, hana::int_c<20>), + hana::make_pair(hana::int_c<3>, hana::int_c<30>)); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, hana::int_c<20>), + hana::make_pair(hana::int_c<3>, hana::int_c<30>), + hana::make_pair(hana::type_c, hana::type_c)); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } + { + constexpr auto t0 = hana::make_map( + hana::make_pair(hana::int_c<2>, hana::int_c<20>), + hana::make_pair(hana::int_c<3>, hana::int_c<30>), + hana::make_pair(hana::type_c, hana::type_c)); + constexpr auto t_implicit = t0; + constexpr auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, std::string{"abcdef"})); + auto copy = t0; + BOOST_HANA_RUNTIME_CHECK( + copy == hana::make_map(hana::make_pair(hana::int_c<2>, std::string{"abcdef"})) + ); + } + + { + using Map1 = hana::map>; + Map1 map1; (void)map1; + static_assert(!std::is_copy_constructible::value, ""); + + using Map2 = hana::map>; + Map2 map2; (void)map2; + static_assert(!std::is_copy_constructible::value, ""); + } +} diff --git a/src/boost/libs/hana/test/map/cnstr.default.cpp b/src/boost/libs/hana/test/map/cnstr.default.cpp new file mode 100644 index 000000000..cd1320c8f --- /dev/null +++ b/src/boost/libs/hana/test/map/cnstr.default.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct NoDefault { + NoDefault() = delete; + NoDefault(NoDefault const&) = default; + constexpr explicit NoDefault(int) { } +}; + +auto operator==(NoDefault const&, NoDefault const&) { return hana::true_c; } +auto operator!=(NoDefault const&, NoDefault const&) { return hana::false_c; } + +// Note: It is also useful to check with a non-empty class, because that +// triggers different instantiations due to EBO. +struct NoDefault_nonempty { + NoDefault_nonempty() = delete; + NoDefault_nonempty(NoDefault_nonempty const&) = default; + constexpr explicit NoDefault_nonempty(int k) : i(k) { } + int i; +}; + +auto operator==(NoDefault_nonempty const&, NoDefault_nonempty const&) { return hana::true_c; } +auto operator!=(NoDefault_nonempty const&, NoDefault_nonempty const&) { return hana::false_c; } + +struct Default { + Default() = default; + Default(Default const&) = default; + constexpr explicit Default(int) { } +}; + +auto operator==(Default const&, Default const&) { return hana::true_c; } +auto operator!=(Default const&, Default const&) { return hana::false_c; } + +namespace boost { namespace hana { + template <> + struct hash_impl { + static constexpr auto apply(NoDefault const&) + { return hana::type_c; }; + }; + + template <> + struct hash_impl { + static constexpr auto apply(NoDefault_nonempty const&) + { return hana::type_c; }; + }; + + template <> + struct hash_impl { + static constexpr auto apply(Default const&) + { return hana::type_c; }; + }; +}} + +int main() { + auto map1 = hana::make_map(hana::make_pair(Default(1), Default(1))); + static_assert(std::is_default_constructible::value, ""); + + auto map2 = hana::make_map(hana::make_pair(NoDefault(1), NoDefault(1))); + static_assert(!std::is_default_constructible::value, ""); + + auto map3 = hana::make_map(hana::make_pair(NoDefault_nonempty(1), NoDefault_nonempty(1))); + static_assert(!std::is_default_constructible::value, ""); +} diff --git a/src/boost/libs/hana/test/map/cnstr.move.cpp b/src/boost/libs/hana/test/map/cnstr.move.cpp new file mode 100644 index 000000000..c6f9dca55 --- /dev/null +++ b/src/boost/libs/hana/test/map/cnstr.move.cpp @@ -0,0 +1,123 @@ +// 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 +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +constexpr bool in_constexpr_context() { + auto t0 = hana::make_map( + hana::make_pair(ConstexprMoveOnly<2>{}, ConstexprMoveOnly<20>{}), + hana::make_pair(ConstexprMoveOnly<3>{}, ConstexprMoveOnly<30>{})); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + return true; +} + +static_assert(in_constexpr_context(), ""); + + +struct NoMove { + NoMove() = default; + NoMove(NoMove const&) = delete; + NoMove(NoMove&&) = delete; + friend auto operator==(NoMove const&, NoMove const&) { return hana::true_c; } + friend auto operator!=(NoMove const&, NoMove const&) { return hana::false_c; } +}; + +// Note: It is also useful to check with a non-empty class, because that +// triggers different instantiations due to EBO. +struct NoMove_nonempty { + NoMove_nonempty() = default; + NoMove_nonempty(NoMove_nonempty const&) = delete; + NoMove_nonempty(NoMove_nonempty&&) = delete; + int i; + friend auto operator==(NoMove_nonempty const&, NoMove_nonempty const&) { return hana::true_c; } + friend auto operator!=(NoMove_nonempty const&, NoMove_nonempty const&) { return hana::false_c; } +}; + +namespace boost { namespace hana { + template <> + struct hash_impl { + static constexpr auto apply(NoMove const&) + { return hana::type_c; }; + }; + + template <> + struct hash_impl { + static constexpr auto apply(NoMove_nonempty const&) + { return hana::type_c; }; + }; +}} + +int main() { + { + auto t0 = hana::make_map(); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_explicit; + (void)t_implicit; + } + { + auto t0 = hana::make_map(hana::make_pair(TrackedMoveOnly<1>{}, TrackedMoveOnly<10>{})); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_map(hana::make_pair(TrackedMoveOnly<1>{}, TrackedMoveOnly<10>{}), + hana::make_pair(TrackedMoveOnly<2>{}, TrackedMoveOnly<20>{})); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_map(hana::make_pair(TrackedMoveOnly<1>{}, TrackedMoveOnly<10>{}), + hana::make_pair(TrackedMoveOnly<2>{}, TrackedMoveOnly<20>{}), + hana::make_pair(TrackedMoveOnly<3>{}, TrackedMoveOnly<30>{})); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_map(hana::make_pair(hana::int_c<2>, std::string{"abcdef"})); + auto moved = std::move(t0); + BOOST_HANA_RUNTIME_CHECK( + moved == hana::make_map(hana::make_pair(hana::int_c<2>, std::string{"abcdef"})) + ); + } + + { + using Map1 = hana::map>; + Map1 map1; (void)map1; + static_assert(!std::is_move_constructible::value, ""); + + using Map2 = hana::map>; + Map2 map2; (void)map2; + static_assert(!std::is_move_constructible::value, ""); + } +} diff --git a/src/boost/libs/hana/test/map/cnstr.trap.cpp b/src/boost/libs/hana/test/map/cnstr.trap.cpp new file mode 100644 index 000000000..b9ce84e62 --- /dev/null +++ b/src/boost/libs/hana/test/map/cnstr.trap.cpp @@ -0,0 +1,72 @@ +// 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 +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +// This test makes sure that we do not instantiate rogue constructors when +// doing copies and moves + +template +struct Trap { + Trap() = default; + Trap(Trap const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap(Trap&) = default; +#endif + Trap(Trap&&) = default; + + template + Trap(X&&) { + static_assert(hana::detail::wrong{}, + "this constructor must not be instantiated"); + } +}; + +template +constexpr auto operator==(Trap const&, Trap const&) +{ return hana::bool_c; } + +template +constexpr auto operator!=(Trap const&, Trap const&) +{ return hana::bool_c; } + +namespace boost { namespace hana { + template + struct hash_impl> { + static constexpr auto apply(Trap const&) + { return hana::type_c>; }; + }; +}} + +int main() { + { + auto expr = hana::make_map( + hana::make_pair(Trap<0>{}, Trap<0>{}) + ); + auto implicit_copy = expr; + decltype(expr) explicit_copy(expr); + + (void)implicit_copy; + (void)explicit_copy; + } + { + auto expr = hana::make_map( + hana::make_pair(Trap<0>{}, Trap<0>{}) + ); + auto implicit_move = std::move(expr); + decltype(expr) explicit_move(std::move(implicit_move)); + + (void)implicit_move; + (void)explicit_move; + } +} diff --git a/src/boost/libs/hana/test/map/cnstr.variadic.cpp b/src/boost/libs/hana/test/map/cnstr.variadic.cpp new file mode 100644 index 000000000..8143d2cfb --- /dev/null +++ b/src/boost/libs/hana/test/map/cnstr.variadic.cpp @@ -0,0 +1,186 @@ +// 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 +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +using pair = ::product_t, hana::test::ct_eq<-i>>; + +// Check with move-only literal types. +constexpr bool in_constexpr_context() { + hana::map, ConstexprMoveOnly<20>>, + hana::pair, ConstexprMoveOnly<30>>> map{ + hana::make_pair(ConstexprMoveOnly<2>{}, ConstexprMoveOnly<20>{}), + hana::make_pair(ConstexprMoveOnly<3>{}, ConstexprMoveOnly<30>{}) + }; + (void)map; + return true; +} + +static_assert(in_constexpr_context(), ""); + +int main() { + // Basic check with non trivial runtime state + { + std::vector v{"Hello", "world", "!"}; + + hana::map< + hana::pair, std::string>, + hana::pair, std::vector> + > map{ + hana::make_pair(hana::test::ct_eq<1>{}, std::string{"Hello world!"}), + hana::make_pair(hana::test::ct_eq<2>{}, v) + }; + + BOOST_HANA_RUNTIME_CHECK( + hana::at_key(map, hana::test::ct_eq<1>{}) == std::string{"Hello world!"} + ); + + BOOST_HANA_RUNTIME_CHECK( + hana::at_key(map, hana::test::ct_eq<2>{}) == v + ); + } + + { + hana::map<> map{}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map() + )); + } + + { + hana::map> map{pair<0>{}}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}) + )); + } + + { + hana::map, pair<1>> map{pair<0>{}, pair<1>{}}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}) + )); + } + + { + hana::map, pair<1>, pair<2>> map{pair<0>{}, pair<1>{}, pair<2>{}}; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}, pair<2>{}) + )); + } + + { + hana::map, pair<1>, pair<2>, pair<3>> map{ + pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{} + }; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{}) + )); + } + + { + hana::map, pair<1>, pair<2>, pair<3>, pair<4>> map{ + pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{}, pair<4>{} + }; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{}, pair<4>{}) + )); + } + + { + hana::map, pair<1>, pair<2>, pair<3>, pair<4>, pair<5>> map{ + pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{}, pair<4>{}, pair<5>{} + }; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{}, pair<4>{}, pair<5>{}) + )); + } + + // Use parenthesis syntax instead of braces + { + hana::map<> map = hana::map<>(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map() + )); + } + + { + hana::map> map( + pair<0>{} + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}) + )); + } + + { + hana::map, pair<1>> map( + pair<0>{}, pair<1>{} + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}) + )); + } + + { + hana::map, pair<1>, pair<2>> map( + pair<0>{}, pair<1>{}, pair<2>{} + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}, pair<2>{}) + )); + } + + { + hana::map, pair<1>, pair<2>, pair<3>> map( + pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{} + ); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + map, + hana::make_map(pair<0>{}, pair<1>{}, pair<2>{}, pair<3>{}) + )); + } + + // Check with move-only types + { + hana::map, TrackedMoveOnly<10>>, + hana::pair, TrackedMoveOnly<20>>> map{ + hana::make_pair(TrackedMoveOnly<1>{}, TrackedMoveOnly<10>{}), + hana::make_pair(TrackedMoveOnly<2>{}, TrackedMoveOnly<20>{}) + }; + } + + // The following used to fail when we did not constrain the + // constructor properly: + { + hana::map> map{}; + hana::test::_injection<0> f{}; + auto x = f(map); + } +} diff --git a/src/boost/libs/hana/test/map/contains.cpp b/src/boost/libs/hana/test/map/contains.cpp new file mode 100644 index 000000000..901d0a666 --- /dev/null +++ b/src/boost/libs/hana/test/map/contains.cpp @@ -0,0 +1,117 @@ +// 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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(), + key<0>() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(), + key<1>() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>()), + key<0>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>()), + key<1>() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>()), + key<2>() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>()), + key<0>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>()), + key<1>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>(), p<1,1>()), + key<2>() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>()), + key<0>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>()), + key<1>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>()), + key<2>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>()), + key<3>() + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<0>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<1>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<2>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<3>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<4>() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<5>() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<6>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<7>() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<8>() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_map(p<0,0>(), p<1,1>(), p<2,2>(), p<3,3>(), p<6,6>(), p<8,8>()), + key<9>() + ))); +} diff --git a/src/boost/libs/hana/test/map/difference.cpp b/src/boost/libs/hana/test/map/difference.cpp new file mode 100644 index 000000000..5d1b4f450 --- /dev/null +++ b/src/boost/libs/hana/test/map/difference.cpp @@ -0,0 +1,106 @@ +// 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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_map(), + hana::make_map() + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_map(p<1, 1>()), + hana::make_map() + ), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_map(p<1, 1>()), + hana::make_map(p<2, 2>()) + ), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 2>()) + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_map(p<1, 1>(), + p<2, 2>(), + p<3, 3>()), + hana::make_map(p<2, 2>(), + p<4, 4>()) + ), + hana::make_map(p<1, 1>(), + p<3, 3>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_map(p<1, 1>(), + p<2, 2>()), + hana::make_map(p<2, 3>(), + p<1, 4>()) + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_map(p<1, 1>(), + p<2, 2>(), + p<3, 3>(), + p<4, 4>(), + p<5, 5>(), + p<6, 6>(), + p<7, 7>(), + p<8, 8>(), + p<9, 9>(), + p<10, 10>()), + hana::make_map(p<0, 2>(), + p<2, 4>(), + p<3, 6>(), + p<4, 8>(), + p<5, 10>(), + p<20, 30>()) + ), + hana::make_map(p<1, 1>(), + p<6, 6>(), + p<7, 7>(), + p<8, 8>(), + p<9, 9>(), + p<10, 10>()) + )); + +} diff --git a/src/boost/libs/hana/test/map/equal.cpp b/src/boost/libs/hana/test/map/equal.cpp new file mode 100644 index 000000000..c12be4e47 --- /dev/null +++ b/src/boost/libs/hana/test/map/equal.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 +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_map(), + hana::make_map() + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>()), + hana::make_map() + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(), + hana::make_map(p<1, 1>()) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 2>()) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>()), + hana::make_map(p<2, 1>()) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<2, 2>(), p<1, 1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<9, 1>(), p<2, 2>())) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<1, 9>(), p<2, 2>())) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<1, 1>(), p<9, 2>())) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<1, 1>(), p<2, 9>())) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>())) + )); + + // operators + BOOST_HANA_CONSTANT_CHECK( + hana::make_map(p<2, 2>(), p<1, 1>()) + == + hana::make_map(p<1, 1>(), p<2, 2>()) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::make_map(p<1, 1>()) + != + hana::make_map(p<1, 1>(), p<2, 2>()) + ); +} diff --git a/src/boost/libs/hana/test/map/erase_key.cpp b/src/boost/libs/hana/test/map/erase_key.cpp new file mode 100644 index 000000000..ddea439d1 --- /dev/null +++ b/src/boost/libs/hana/test/map/erase_key.cpp @@ -0,0 +1,70 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(), undefined{}), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>()), key<1>()), + hana::make_map() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>()), key<99>()), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>(), p<2, 2>()), key<99>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>(), p<2, 2>()), key<1>()), + hana::make_map(p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>(), p<2, 2>()), key<2>()), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), key<99>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), key<1>()), + hana::make_map(p<2, 2>(), p<3, 3>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), key<2>()), + hana::make_map(p<1, 1>(), p<3, 3>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), key<3>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); +} diff --git a/src/boost/libs/hana/test/map/find_if.cpp b/src/boost/libs/hana/test/map/find_if.cpp new file mode 100644 index 000000000..93579dfca --- /dev/null +++ b/src/boost/libs/hana/test/map/find_if.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_map(), hana::equal.to(key<1>())), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_map(p<1, 1>()), hana::equal.to(key<1>())), + hana::just(val<1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_map(p<1, 1>()), hana::equal.to(key<2>())), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_map(p<1, 1>(), p<2, 2>()), hana::equal.to(key<1>())), + hana::just(val<1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_map(p<1, 1>(), p<2, 2>()), hana::equal.to(key<2>())), + hana::just(val<2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_map(p<1, 1>(), p<2, 2>()), hana::equal.to(key<3>())), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/map/fold_left.cpp b/src/boost/libs/hana/test/map/fold_left.cpp new file mode 100644 index 000000000..558120c9a --- /dev/null +++ b/src/boost/libs/hana/test/map/fold_left.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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +struct undefined { }; + +int main() { + auto sequence = ::seq; + + // Use pointers to work around a Clang ICE + hana::test::_injection<0> f{}; + auto* fp = &f; + + hana::test::ct_eq<999> state{}; + auto* statep = &state; + + auto check = [=](auto ...pairs) { + auto possible_results = hana::transform(hana::permutations(sequence(pairs...)), + [=](auto xs) { + return hana::fold_left(xs, *statep, *fp); + } + ); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + possible_results, + hana::fold_left(hana::make_map(pairs...), state, f) + )); + }; + + check(); + check(p<1, 1>()); + check(p<1, 1>(), p<2, 2>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>(), p<4, 4>()); +} diff --git a/src/boost/libs/hana/test/map/fold_right.cpp b/src/boost/libs/hana/test/map/fold_right.cpp new file mode 100644 index 000000000..2ff88d899 --- /dev/null +++ b/src/boost/libs/hana/test/map/fold_right.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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +struct undefined { }; + +int main() { + auto sequence = ::seq; + + // Use pointers to work around a Clang ICE + hana::test::_injection<0> f{}; + auto* fp = &f; + + hana::test::ct_eq<999> state{}; + auto* statep = &state; + + auto check = [=](auto ...pairs) { + auto possible_results = hana::transform(hana::permutations(sequence(pairs...)), + [=](auto xs) { + return hana::fold_right(xs, *statep, *fp); + } + ); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + possible_results, + hana::fold_right(hana::make_map(pairs...), state, f) + )); + }; + + check(); + check(p<1, 1>()); + check(p<1, 1>(), p<2, 2>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>(), p<4, 4>()); +} diff --git a/src/boost/libs/hana/test/map/insert.cpp b/src/boost/libs/hana/test/map/insert.cpp new file mode 100644 index 000000000..fa8329b96 --- /dev/null +++ b/src/boost/libs/hana/test/map/insert.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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(), p<1, 1>()), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>()), p<1, 99>()), + hana::make_map(p<1, 1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>()), p<2, 2>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>(), p<2, 2>()), p<1, 99>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>(), p<2, 2>()), p<2, 99>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>(), p<2, 2>()), p<3, 3>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), p<1, 99>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), p<2, 99>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), p<3, 99>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()), p<4, 4>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>(), p<4, 4>()) + )); +} diff --git a/src/boost/libs/hana/test/map/intersection.cpp b/src/boost/libs/hana/test/map/intersection.cpp new file mode 100644 index 000000000..7e092ec04 --- /dev/null +++ b/src/boost/libs/hana/test/map/intersection.cpp @@ -0,0 +1,99 @@ +// 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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_map(), + hana::make_map() + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_map(p<1, 1>()), + hana::make_map() + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_map(), + hana::make_map(p<1, 1>()) + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 2>()) + ), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_map( + p<1, 2>(), + p<2, 3>()), + hana::make_map( + p<1, 3>(), + p<2, 4>(), + p<3, 5>()) + ), + hana::make_map( + p<1, 2>(), + p<2, 3>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_map( + p<1, 3>(), + p<2, 4>(), + p<3, 5>()), + hana::make_map( + p<1, 2>(), + p<2, 3>()) + ), + hana::make_map( + p<1, 3>(), + p<2, 4>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_map( + p<1, 100>(), + p<2, 200>()), + hana::make_map( + p<3, 300>(), + p<4, 400>()) + ), + hana::make_map() + )); + +} diff --git a/src/boost/libs/hana/test/map/is_subset.cpp b/src/boost/libs/hana/test/map/is_subset.cpp new file mode 100644 index 000000000..3ac5da1df --- /dev/null +++ b/src/boost/libs/hana/test/map/is_subset.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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_map(), + hana::make_map() + )); + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_map(), + hana::make_map(p<1, 1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_map(), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_map(p<2, 2>(), p<1, 1>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_subset( + hana::make_map(p<3, 3>(), p<1, 1>()), + hana::make_map(p<1, 1>(), p<2, 2>()) + ))); +} diff --git a/src/boost/libs/hana/test/map/keys.cpp b/src/boost/libs/hana/test/map/keys.cpp new file mode 100644 index 000000000..8c54cb9a1 --- /dev/null +++ b/src/boost/libs/hana/test/map/keys.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 +#include +#include +#include +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + constexpr auto list = ::seq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::keys(hana::make_map()), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::keys(hana::make_map(p<1, 1>())), + list(key<1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::permutations(list(key<1>(), key<2>())), + hana::keys(hana::make_map(p<1, 1>(), p<2, 2>())) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::permutations(list(key<1>(), key<2>(), key<3>())), + hana::keys(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>())) + )); +} diff --git a/src/boost/libs/hana/test/map/laws.cpp b/src/boost/libs/hana/test/map/laws.cpp new file mode 100644 index 000000000..c3a0d6709 --- /dev/null +++ b/src/boost/libs/hana/test/map/laws.cpp @@ -0,0 +1,37 @@ +// 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 +#include + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + auto maps = hana::make_tuple( + hana::make_map(), + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 2>()), + hana::make_map(p<1, 1>(), p<2, 2>()), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + ); + + hana::test::TestComparable{maps}; + hana::test::TestSearchable{maps, hana::make_tuple(key<1>(), key<4>())}; + hana::test::TestFoldable{maps}; +} diff --git a/src/boost/libs/hana/test/map/map.cpp b/src/boost/libs/hana/test/map/map.cpp new file mode 100644 index 000000000..bbaceadcd --- /dev/null +++ b/src/boost/libs/hana/test/map/map.cpp @@ -0,0 +1,33 @@ +// 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 + +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct check_map { + static_assert(std::is_same< + hana::map, + decltype(hana::make_map(std::declval()...)) + >{}, ""); +}; + +template +using pair = ::product_t, hana::test::ct_eq<-i>>; + +template struct check_map<>; +template struct check_map>; +template struct check_map, pair<2>>; +template struct check_map, pair<2>, pair<3>>; +template struct check_map, pair<2>, pair<3>, pair<4>>; +template struct check_map, pair<2>, pair<3>, pair<4>, pair<5>>; +template struct check_map, pair<2>, pair<3>, pair<4>, pair<5>, pair<6>>; + +int main() { } diff --git a/src/boost/libs/hana/test/map/symmetric_difference.cpp b/src/boost/libs/hana/test/map/symmetric_difference.cpp new file mode 100644 index 000000000..9fc8c77f0 --- /dev/null +++ b/src/boost/libs/hana/test/map/symmetric_difference.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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_map(), + hana::make_map() + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 1>()) + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_map(p<1, 2>()), + hana::make_map(p<2, 4>()) + ), + hana::make_map(p<1, 2>(), + p<2, 4>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_map(p<1, 2>(), + p<2, 22>()), + hana::make_map(p<2, 4>(), + p<3, 33>()) + ), + hana::make_map(p<1, 2>(), + p<3, 33>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_map(p<1, 2>(), + p<2, 22>(), + p<3, 33>(), + p<5, 55>(), + p<8, 88>()), + hana::make_map(p<2, 4>(), + p<3, 33>(), + p<4, 44>(), + p<9, 99>()) + ), + hana::make_map(p<1, 2>(), + p<5, 55>(), + p<8, 88>(), + p<4, 44>(), + p<9, 99>()) + )); +} diff --git a/src/boost/libs/hana/test/map/to.cpp b/src/boost/libs/hana/test/map/to.cpp new file mode 100644 index 000000000..b1cea4c2e --- /dev/null +++ b/src/boost/libs/hana/test/map/to.cpp @@ -0,0 +1,92 @@ +// 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 +#include +#include +#include +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + constexpr auto foldable = ::seq; + auto sequence = ::seq; + + // Foldable -> Map + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable()), + hana::make_map() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>())), + hana::make_map(p<1, 1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>(), p<2, 2>())), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>(), p<2, 2>(), p<3, 3>())), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + )); + + // with duplicates + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>(), p<1, 99>())), + hana::make_map(p<1, 1>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>(), p<2, 2>(), p<1, 99>())), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>(), p<2, 2>(), p<1, 99>(), p<2, 99>())), + hana::make_map(p<1, 1>(), p<2, 2>()) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>(), p<2, 2>(), p<1, 99>(), p<2, 99>(), p<3, 3>())), + hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>()) + )); + } + + // Map -> Sequence + { + auto check = [=](auto ...xs) { + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::permutations(sequence(xs...)), + hana::to<::Seq>(hana::make_map(xs...)) + )); + }; + + check(); + check(p<1, 1>()); + check(p<1, 1>(), p<2, 2>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>(), p<4, 4>()); + } + + // to_map == to + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_map(foldable(p<1, 1>(), p<2, 2>(), p<1, 99>(), p<2, 99>(), p<3, 3>())), + hana::to(foldable(p<1, 1>(), p<2, 2>(), p<1, 99>(), p<2, 99>(), p<3, 3>())) + )); + } +} diff --git a/src/boost/libs/hana/test/map/union.cpp b/src/boost/libs/hana/test/map/union.cpp new file mode 100644 index 000000000..dfae6ea0e --- /dev/null +++ b/src/boost/libs/hana/test/map/union.cpp @@ -0,0 +1,82 @@ +// 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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_map(), + hana::make_map() + ), + hana::make_map() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_map( + p<1, 1>() + ), + hana::make_map() + ), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_map(), + hana::make_map(p<1, 1>()) + ), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_map(p<1, 1>()), + hana::make_map(p<1, 1>()) + ), + hana::make_map(p<1, 1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_map(p<1, 2>()), + hana::make_map(p<1, 3>()) + ), + hana::make_map(p<1, 3>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_map(p<1, 10>(), + p<2, 20>(), + p<3, 30>()), + hana::make_map(p<4, 40>(), + p<5, 50>(), + p<1, 100>()) + ), + hana::make_map(p<2, 20>(), + p<3, 30>(), + p<4, 40>(), + p<5, 50>(), + p<1, 100>()) + )); +} diff --git a/src/boost/libs/hana/test/map/unpack.cpp b/src/boost/libs/hana/test/map/unpack.cpp new file mode 100644 index 000000000..63db677aa --- /dev/null +++ b/src/boost/libs/hana/test/map/unpack.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 +#include +#include +#include +#include +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +struct undefined { }; + +int main() { + auto sequence = ::seq; + hana::test::_injection<0> f{}; + + auto check = [=](auto ...pairs) { + auto possible_results = hana::transform(hana::permutations(sequence(pairs...)), + [=](auto xs) { return hana::unpack(xs, f); } + ); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + possible_results, + hana::unpack(hana::make_map(pairs...), f) + )); + }; + + check(); + check(p<1, 1>()); + check(p<1, 1>(), p<2, 2>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>()); + check(p<1, 1>(), p<2, 2>(), p<3, 3>(), p<4, 4>()); +} diff --git a/src/boost/libs/hana/test/map/values.cpp b/src/boost/libs/hana/test/map/values.cpp new file mode 100644 index 000000000..08082c187 --- /dev/null +++ b/src/boost/libs/hana/test/map/values.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 +#include +#include +#include +#include + +#include +#include +#include +namespace hana = boost::hana; + + +template +auto key() { return hana::test::ct_eq{}; } + +template +auto val() { return hana::test::ct_eq<-i>{}; } + +template +auto p() { return ::minimal_product(key(), val()); } + +int main() { + constexpr auto list = ::seq; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::values(hana::make_map()), + list() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::values(hana::make_map(p<1, 1>())), + list(val<1>()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::permutations(list(val<1>(), val<2>())), + hana::values(hana::make_map(p<1, 1>(), p<2, 2>())) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::permutations(list(val<1>(), val<2>(), val<3>())), + hana::values(hana::make_map(p<1, 1>(), p<2, 2>(), p<3, 3>())) + )); +} diff --git a/src/boost/libs/hana/test/minimal_product.cpp b/src/boost/libs/hana/test/minimal_product.cpp new file mode 100644 index 000000000..80f214f5f --- /dev/null +++ b/src/boost/libs/hana/test/minimal_product.cpp @@ -0,0 +1,55 @@ +// 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; +using hana::test::ct_ord; + + +int main() { + // Make sure `first` and `second` are "accessors". If they are not, + // `Tracked` should report a double-move. + { + auto prod = ::minimal_product(::Tracked{1}, ::Tracked{2}); + auto fst = hana::first(std::move(prod)); + auto snd = hana::second(std::move(prod)); + } + + ////////////////////////////////////////////////////////////////////////// + // Comparable, Orderable, Foldable, Product + ////////////////////////////////////////////////////////////////////////// + auto eq_elems = hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}); + + auto eqs = hana::make_tuple( + ::minimal_product(ct_eq<3>{}, ct_eq<3>{}) + , ::minimal_product(ct_eq<3>{}, ct_eq<4>{}) + , ::minimal_product(ct_eq<4>{}, ct_eq<3>{}) + , ::minimal_product(ct_eq<4>{}, ct_eq<4>{}) + ); + + auto ords = hana::make_tuple( + ::minimal_product(ct_ord<3>{}, ct_ord<3>{}) + , ::minimal_product(ct_ord<3>{}, ct_ord<4>{}) + , ::minimal_product(ct_ord<4>{}, ct_ord<3>{}) + , ::minimal_product(ct_ord<4>{}, ct_ord<4>{}) + ); + + hana::test::TestComparable<::MinimalProduct>{eqs}; + hana::test::TestOrderable<::MinimalProduct>{ords}; + hana::test::TestFoldable<::MinimalProduct>{eqs}; + hana::test::TestProduct<::MinimalProduct>{eq_elems}; +} diff --git a/src/boost/libs/hana/test/monoid.cpp b/src/boost/libs/hana/test/monoid.cpp new file mode 100644 index 000000000..ca6932611 --- /dev/null +++ b/src/boost/libs/hana/test/monoid.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::TestMonoid{hana::make_tuple(0,1,2,3,4,5)}; + hana::test::TestMonoid{hana::make_tuple(0u,1u,2u,3u,4u,5u)}; + hana::test::TestMonoid{hana::make_tuple(0l,1l,2l,3l,4l,5l)}; + hana::test::TestMonoid{hana::make_tuple(0ul,1ul,2ul,3ul,4ul,5ul)}; + + // zero + static_assert(hana::zero() == 0, ""); + + // plus + static_assert(hana::plus(6, 4) == 6 + 4, ""); +} diff --git a/src/boost/libs/hana/test/numeric/main.hpp b/src/boost/libs/hana/test/numeric/main.hpp new file mode 100644 index 000000000..f092cdee6 --- /dev/null +++ b/src/boost/libs/hana/test/numeric/main.hpp @@ -0,0 +1,511 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct invalid { + template + operator T const() { std::abort(); } +}; + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Comparable + ////////////////////////////////////////////////////////////////////////// + { + hana::test::_injection<0> f{}; + auto x = numeric(1); + auto y = numeric(2); + + // equal + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(x, x)); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::equal(x, y))); + } + + // not_equal + { + BOOST_HANA_CONSTEXPR_CHECK(hana::not_equal(x, y)); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::not_equal(x, x))); + } + + // comparing + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::comparing(f)(x, x), + hana::equal(f(x), f(x)) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::comparing(f)(x, y), + hana::equal(f(x), f(y)) + )); + } + } + + ////////////////////////////////////////////////////////////////////////// + // Orderable + ////////////////////////////////////////////////////////////////////////// + { + auto ord = numeric; + + // _injection is also monotonic + hana::test::_injection<0> f{}; + + // less + { + BOOST_HANA_CONSTEXPR_CHECK(hana::less(ord(0), ord(1))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord(0), ord(0)))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord(1), ord(0)))); + } + + // less_equal + { + BOOST_HANA_CONSTEXPR_CHECK(hana::less_equal(ord(0), ord(1))); + BOOST_HANA_CONSTEXPR_CHECK(hana::less_equal(ord(0), ord(0))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less_equal(ord(1), ord(0)))); + } + + // greater_equal + { + BOOST_HANA_CONSTEXPR_CHECK(hana::greater_equal(ord(1), ord(0))); + BOOST_HANA_CONSTEXPR_CHECK(hana::greater_equal(ord(0), ord(0))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::greater_equal(ord(0), ord(1)))); + } + + // greater + { + BOOST_HANA_CONSTEXPR_CHECK(hana::greater(ord(1), ord(0))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::greater(ord(0), ord(0)))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::greater(ord(0), ord(1)))); + } + + // max + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::max(ord(0), ord(0)), ord(0) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::max(ord(1), ord(0)), ord(1) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::max(ord(0), ord(1)), ord(1) + )); + } + + // min + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::min(ord(0), ord(0)), + ord(0) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::min(ord(1), ord(0)), + ord(0) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::min(ord(0), ord(1)), + ord(0) + )); + } + + // ordering + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::ordering(f)(ord(1), ord(0)), + hana::less(f(ord(1)), f(ord(0))) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::ordering(f)(ord(0), ord(1)), + hana::less(f(ord(0)), f(ord(1))) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::ordering(f)(ord(0), ord(0)), + hana::less(f(ord(0)), f(ord(0))) + )); + } + } + + ////////////////////////////////////////////////////////////////////////// + // Monoid + ////////////////////////////////////////////////////////////////////////// + { + constexpr int x = 2, y = 3; + + // zero + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::zero(), numeric(0) + )); + } + + // plus + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::plus(numeric(x), numeric(y)), + numeric(x + y) + )); + } + } + + ////////////////////////////////////////////////////////////////////////// + // Group + ////////////////////////////////////////////////////////////////////////// + { + constexpr int x = 2, y = 3; + + // minus + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::minus(numeric(x), numeric(y)), + numeric(x - y) + )); + } + + // negate + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::negate(numeric(x)), + numeric(-x) + )); + } + } + + ////////////////////////////////////////////////////////////////////////// + // Ring + ////////////////////////////////////////////////////////////////////////// + { + constexpr int x = 2, y = 3; + + // one + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::one(), + numeric(1) + )); + } + + // mult + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::mult(numeric(x), numeric(y)), + numeric(x * y) + )); + } + + // power + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::power(numeric(x), hana::zero>()), + hana::one() + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::power(numeric(x), hana::one>()), + numeric(x) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::power(numeric(x), cnumeric), + hana::mult(numeric(x), numeric(x)) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::power(numeric(x), cnumeric), + hana::mult(hana::mult(numeric(x), numeric(x)), numeric(x)) + )); + } + } + + ////////////////////////////////////////////////////////////////////////// + // EuclideanRing + ////////////////////////////////////////////////////////////////////////// + { + constexpr int x = 6, y = 3, z = 4; + + // div + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::div(numeric(x), numeric(y)), + numeric(x / y) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::div(numeric(x), numeric(z)), + numeric(x/ z) + )); + } + + // mod + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::mod(numeric(x), numeric(y)), + numeric(x % y) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::mod(numeric(x), numeric(z)), + numeric(x % z) + )); + } + } + + ////////////////////////////////////////////////////////////////////////// + // Logical + ////////////////////////////////////////////////////////////////////////// + { + auto logical = numeric; + auto comparable = numeric; + + // not_ + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::not_(logical(true)), + logical(false) + )); + } + + // and_ + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(true)), + logical(true) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(false)), + logical(false) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(true), logical(true)), + logical(true) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(true), logical(false)), + logical(false) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(false), invalid{}), + logical(false) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(true), logical(true), logical(true)), + logical(true) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(true), logical(true), logical(false)), + logical(false) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(true), logical(false), invalid{}), + logical(false) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::and_(logical(false), invalid{}, invalid{}), + logical(false) + )); + } + + // or_ + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(true)), + logical(true) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(false)), + logical(false) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(false), logical(false)), + logical(false) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(false), logical(true)), + logical(true) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(true), invalid{}), + logical(true) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(false), logical(false), logical(false)), + logical(false) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(false), logical(false), logical(true)), + logical(true) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(false), logical(true), invalid{}), + logical(true) + )); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::or_(logical(true), invalid{}, invalid{}), + logical(true) + )); + } + + // if_ + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::if_(logical(true), comparable(0), comparable(1)), + comparable(0) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::if_(logical(false), comparable(0), comparable(1)), + comparable(1) + )); + } + + // eval_if + { + auto t = [=](auto) { return comparable(0); }; + auto e = [=](auto) { return comparable(1); }; + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::eval_if(logical(true), t, e), + comparable(0) + )); + + BOOST_HANA_CONSTEXPR_CHECK(hana::equal( + hana::eval_if(logical(false), t, e), + comparable(1) + )); + } + + // while_ + { + auto smaller_than = [](auto n) { + return [n](auto v) { return v.size() < n; }; + }; + auto f = [](auto v) { + v.push_back(v.size()); + return v; + }; + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(smaller_than(0u), std::vector{}, f), + std::vector{} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(smaller_than(1u), std::vector{}, f), + std::vector{0} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(smaller_than(2u), std::vector{}, f), + std::vector{0, 1} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(smaller_than(3u), std::vector{}, f), + std::vector{0, 1, 2} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(smaller_than(4u), std::vector{}, f), + std::vector{0, 1, 2, 3} + )); + + // Make sure it can be called with an lvalue state: + std::vector v{}; + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(smaller_than(4u), v, f), + std::vector{0, 1, 2, 3} + )); + } + + // while_ + { + auto less_than = [](auto n) { + return [n](auto v) { return v.size() < n; }; + }; + auto f = [](auto v) { + v.push_back(v.size()); + return v; + }; + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(0u), std::vector{}, f), + std::vector{} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(1u), std::vector{}, f), + std::vector{0} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(2u), std::vector{}, f), + std::vector{0, 1} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(3u), std::vector{}, f), + std::vector{0, 1, 2} + )); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(4u), std::vector{}, f), + std::vector{0, 1, 2, 3} + )); + + // Make sure it can be called with an lvalue state: + std::vector v{}; + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::while_(less_than(4u), v, f), + std::vector{0, 1, 2, 3} + )); + } + } +} diff --git a/src/boost/libs/hana/test/numeric/minus_mcd.cpp b/src/boost/libs/hana/test/numeric/minus_mcd.cpp new file mode 100644 index 000000000..f5f67d808 --- /dev/null +++ b/src/boost/libs/hana/test/numeric/minus_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_GROUP_MINUS_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/numeric/negate_mcd.cpp b/src/boost/libs/hana/test/numeric/negate_mcd.cpp new file mode 100644 index 000000000..996d71ead --- /dev/null +++ b/src/boost/libs/hana/test/numeric/negate_mcd.cpp @@ -0,0 +1,6 @@ +// 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) + +#define BOOST_HANA_TEST_GROUP_NEGATE_MCD +#include "main.hpp" diff --git a/src/boost/libs/hana/test/optional/any_of.cpp b/src/boost/libs/hana/test/optional/any_of.cpp new file mode 100644 index 000000000..74070fb2f --- /dev/null +++ b/src/boost/libs/hana/test/optional/any_of.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + ct_eq<2> x{}; + ct_eq<3> y{}; + + BOOST_HANA_CONSTANT_CHECK(hana::any_of(hana::just(x), hana::equal.to(x))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of(hana::just(x), hana::equal.to(y)))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of(hana::nothing, hana::equal.to(x)))); +} diff --git a/src/boost/libs/hana/test/optional/ap.cpp b/src/boost/libs/hana/test/optional/ap.cpp new file mode 100644 index 000000000..2636729cb --- /dev/null +++ b/src/boost/libs/hana/test/optional/ap.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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::nothing, hana::nothing), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::just(f), hana::nothing), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::nothing, hana::just(ct_eq<3>{})), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::ap(hana::just(f), hana::just(ct_eq<3>{})), + hana::just(f(ct_eq<3>{})) + )); +} diff --git a/src/boost/libs/hana/test/optional/chain.cpp b/src/boost/libs/hana/test/optional/chain.cpp new file mode 100644 index 000000000..be3f0ec65 --- /dev/null +++ b/src/boost/libs/hana/test/optional/chain.cpp @@ -0,0 +1,40 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto f = [](auto x) { + return hana::just(hana::test::_injection<0>{}(x)); + }; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(hana::just(ct_eq<3>{}), f), + f(ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::chain(hana::nothing, f), + hana::nothing + )); + + // test with operators + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::just(ct_eq<3>{}) | f, + f(ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::nothing | f, + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/optional/concat.cpp b/src/boost/libs/hana/test/optional/concat.cpp new file mode 100644 index 000000000..40a2a0daf --- /dev/null +++ b/src/boost/libs/hana/test/optional/concat.cpp @@ -0,0 +1,55 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto rv_nothing = [] { return hana::nothing; }; // rvalue nothing + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(rv_nothing(), hana::nothing), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(hana::nothing, rv_nothing()), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(rv_nothing(), rv_nothing()), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(rv_nothing(), hana::just(ct_eq<0>{})), + hana::just(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(hana::just(ct_eq<0>{}), rv_nothing()), + hana::just(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(hana::nothing, hana::nothing), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(hana::nothing, hana::just(ct_eq<0>{})), + hana::just(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(hana::just(ct_eq<0>{}), hana::nothing), + hana::just(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::concat(hana::just(ct_eq<0>{}), hana::just(ct_eq<1>{})), + hana::just(ct_eq<0>{}) + )); +} diff --git a/src/boost/libs/hana/test/optional/copy.trap_construct.cpp b/src/boost/libs/hana/test/optional/copy.trap_construct.cpp new file mode 100644 index 000000000..09410ab3b --- /dev/null +++ b/src/boost/libs/hana/test/optional/copy.trap_construct.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 + +#include +namespace hana = boost::hana; + + +// This test makes sure that we do not instantiate rogue contructors when +// trying to copy a hana::just. + +int main() { + auto just = hana::just(hana::test::trap_construct{}); + auto implicit_copy = just; + decltype(just) explicit_copy(just); + + (void)implicit_copy; + (void)explicit_copy; +} diff --git a/src/boost/libs/hana/test/optional/empty.cpp b/src/boost/libs/hana/test/optional/empty.cpp new file mode 100644 index 000000000..38f25f396 --- /dev/null +++ b/src/boost/libs/hana/test/optional/empty.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 +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::empty(), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/optional/equal.cpp b/src/boost/libs/hana/test/optional/equal.cpp new file mode 100644 index 000000000..476888fba --- /dev/null +++ b/src/boost/libs/hana/test/optional/equal.cpp @@ -0,0 +1,30 @@ +// 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 +#include +#include +#include // for operator != +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::ct_eq<3> x{}; + hana::test::ct_eq<4> y{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::nothing, hana::nothing)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::nothing, hana::just(x)))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::just(x), hana::nothing))); + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::just(x), hana::just(x))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::just(x), hana::just(y)))); + + BOOST_HANA_CONSTANT_CHECK(hana::nothing == hana::nothing); + BOOST_HANA_CONSTANT_CHECK(hana::just(x) == hana::just(x)); + BOOST_HANA_CONSTANT_CHECK(hana::just(x) != hana::just(y)); + BOOST_HANA_CONSTANT_CHECK(hana::just(x) != hana::nothing); + BOOST_HANA_CONSTANT_CHECK(hana::nothing != hana::just(x)); +} diff --git a/src/boost/libs/hana/test/optional/find_if.cpp b/src/boost/libs/hana/test/optional/find_if.cpp new file mode 100644 index 000000000..7ee20f828 --- /dev/null +++ b/src/boost/libs/hana/test/optional/find_if.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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + ct_eq<2> x{}; + ct_eq<3> y{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::just(x), hana::equal.to(x)), + hana::just(x) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::just(x), hana::equal.to(y)), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::nothing, hana::equal.to(x)), + hana::nothing + )); + + // Previously, there was a bug that would make this fail. + auto non_const_nothing = hana::nothing; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(non_const_nothing, hana::equal.to(x)), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/optional/flatten.cpp b/src/boost/libs/hana/test/optional/flatten.cpp new file mode 100644 index 000000000..6a21a50fa --- /dev/null +++ b/src/boost/libs/hana/test/optional/flatten.cpp @@ -0,0 +1,28 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(hana::nothing), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(hana::just(hana::nothing)), + hana::nothing + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::flatten(hana::just(hana::just(ct_eq<4>{}))), + hana::just(ct_eq<4>{}) + )); +} diff --git a/src/boost/libs/hana/test/optional/fold_left.cpp b/src/boost/libs/hana/test/optional/fold_left.cpp new file mode 100644 index 000000000..8b9dd8014 --- /dev/null +++ b/src/boost/libs/hana/test/optional/fold_left.cpp @@ -0,0 +1,28 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::ct_eq<2> x{}; + hana::test::ct_eq<3> s{}; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::just(x), s, f), + f(s, x) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::nothing, s, f), + s + )); +} diff --git a/src/boost/libs/hana/test/optional/fold_right.cpp b/src/boost/libs/hana/test/optional/fold_right.cpp new file mode 100644 index 000000000..2d3c1f5cd --- /dev/null +++ b/src/boost/libs/hana/test/optional/fold_right.cpp @@ -0,0 +1,28 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::ct_eq<2> x{}; + hana::test::ct_eq<3> s{}; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::just(x), s, f), + f(x, s) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::nothing, s, f), + s + )); +} diff --git a/src/boost/libs/hana/test/optional/is_just.cpp b/src/boost/libs/hana/test/optional/is_just.cpp new file mode 100644 index 000000000..49b1f98c7 --- /dev/null +++ b/src/boost/libs/hana/test/optional/is_just.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 +#include +#include +namespace hana = boost::hana; + + +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_just(hana::just(undefined{}))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_just(hana::nothing))); +} diff --git a/src/boost/libs/hana/test/optional/is_nothing.cpp b/src/boost/libs/hana/test/optional/is_nothing.cpp new file mode 100644 index 000000000..6bf772bad --- /dev/null +++ b/src/boost/libs/hana/test/optional/is_nothing.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 +#include +#include +namespace hana = boost::hana; + + +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_nothing(hana::nothing)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_nothing(hana::just(undefined{})))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_nothing(hana::just(hana::nothing)))); +} diff --git a/src/boost/libs/hana/test/optional/laws.cpp b/src/boost/libs/hana/test/optional/laws.cpp new file mode 100644 index 000000000..9b0b87cc0 --- /dev/null +++ b/src/boost/libs/hana/test/optional/laws.cpp @@ -0,0 +1,72 @@ +// 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; +using hana::test::ct_ord; + + +int main() { + auto ords = hana::make_tuple( + hana::nothing, + hana::just(ct_ord<0>{}), + hana::just(ct_ord<1>{}), + hana::just(ct_ord<2>{}) + ); + + auto eqs = hana::make_tuple( + hana::nothing, + hana::just(ct_eq<0>{}), + hana::just(ct_eq<1>{}), + hana::just(ct_eq<2>{}) + ); + + auto eq_values = hana::make_tuple(ct_eq<0>{}, ct_eq<2>{}, ct_eq<3>{}); + + auto predicates = hana::make_tuple( + hana::equal.to(ct_eq<0>{}), + hana::equal.to(ct_eq<2>{}), + hana::equal.to(ct_eq<3>{}), + hana::always(hana::false_c), + hana::always(hana::true_c) + ); + + auto nested_eqs = hana::make_tuple( + hana::nothing, + hana::just(hana::just(ct_eq<0>{})), + hana::just(hana::nothing), + hana::just(hana::just(ct_eq<2>{})) + ); + + + hana::test::TestComparable{eqs}; + hana::test::TestOrderable{ords}; + hana::test::TestFunctor{eqs, eq_values}; + hana::test::TestApplicative{eqs}; + hana::test::TestMonad{eqs, nested_eqs}; + hana::test::TestMonadPlus{eqs, predicates, eq_values}; + hana::test::TestSearchable{eqs, eq_values}; + hana::test::TestSearchable{ + hana::make_tuple( + hana::just(hana::true_c), + hana::just(hana::false_c), + hana::nothing + ), + hana::make_tuple(hana::true_c, hana::false_c) + }; + hana::test::TestFoldable{eqs}; +} diff --git a/src/boost/libs/hana/test/optional/less.cpp b/src/boost/libs/hana/test/optional/less.cpp new file mode 100644 index 000000000..05c5d8a74 --- /dev/null +++ b/src/boost/libs/hana/test/optional/less.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_ord; + + +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::nothing < hana::just(undefined{})); + BOOST_HANA_CONSTANT_CHECK(hana::just(ct_ord<3>{}) < hana::just(ct_ord<4>{})); + BOOST_HANA_CONSTANT_CHECK(hana::just(ct_ord<3>{}) <= hana::just(ct_ord<4>{})); + BOOST_HANA_CONSTANT_CHECK(hana::just(ct_ord<4>{}) > hana::just(ct_ord<3>{})); + BOOST_HANA_CONSTANT_CHECK(hana::just(ct_ord<4>{}) >= hana::just(ct_ord<3>{})); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + hana::nothing, + hana::just(undefined{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + hana::just(undefined{}), + hana::nothing + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + hana::nothing, + hana::nothing + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + hana::just(ct_ord<3>{}), + hana::just(ct_ord<4>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + hana::just(ct_ord<3>{}), + hana::just(ct_ord<3>{}) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + hana::just(ct_ord<4>{}), + hana::just(ct_ord<3>{}) + ))); +} diff --git a/src/boost/libs/hana/test/optional/lift.cpp b/src/boost/libs/hana/test/optional/lift.cpp new file mode 100644 index 000000000..25641beed --- /dev/null +++ b/src/boost/libs/hana/test/optional/lift.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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::lift(ct_eq<3>{}), + hana::just(ct_eq<3>{}) + )); +} diff --git a/src/boost/libs/hana/test/optional/make.cpp b/src/boost/libs/hana/test/optional/make.cpp new file mode 100644 index 000000000..e436d6ce0 --- /dev/null +++ b/src/boost/libs/hana/test/optional/make.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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(ct_eq<3>{}), + hana::just(ct_eq<3>{}) + )); + + // Check that make_optional == make + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_optional(), + hana::make() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_optional(ct_eq<3>{}), + hana::make(ct_eq<3>{}) + )); +} diff --git a/src/boost/libs/hana/test/optional/maybe.cpp b/src/boost/libs/hana/test/optional/maybe.cpp new file mode 100644 index 000000000..ca3d154e0 --- /dev/null +++ b/src/boost/libs/hana/test/optional/maybe.cpp @@ -0,0 +1,28 @@ +// 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 +#include +#include + +#include +namespace hana = boost::hana; + + +struct undefined { }; + +int main() { + hana::test::_injection<0> f{}; + hana::test::ct_eq<2> x{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maybe(x, undefined{}, hana::nothing), + x + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maybe(undefined{}, f, hana::just(x)), + f(x) + )); +} diff --git a/src/boost/libs/hana/test/optional/nested_type.cpp b/src/boost/libs/hana/test/optional/nested_type.cpp new file mode 100644 index 000000000..6e85c2045 --- /dev/null +++ b/src/boost/libs/hana/test/optional/nested_type.cpp @@ -0,0 +1,33 @@ +// 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 +#include + +#include +namespace hana = boost::hana; + + +// This test makes sure that an optional holding a hana::type has a +// nested ::type alias. + + +template +using void_t = void; + +template +struct has_type : std::false_type { }; + +template +struct has_type> + : std::true_type +{ }; + + +struct T; + +static_assert(std::is_same))::type, T>{}, ""); +static_assert(!has_type{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/optional/operator_arrow.cpp b/src/boost/libs/hana/test/optional/operator_arrow.cpp new file mode 100644 index 000000000..691d8981e --- /dev/null +++ b/src/boost/libs/hana/test/optional/operator_arrow.cpp @@ -0,0 +1,37 @@ +// 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 +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct object { + ct_eq<3> member; +}; + +int main() { + auto lvalue = hana::just(object{}); + ct_eq<3>& ref = lvalue->member; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + ref, + ct_eq<3>{} + )); + + auto const const_lvalue = hana::just(object{}); + ct_eq<3> const& const_ref = const_lvalue->member; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + const_ref, + ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::just(object{})->member, + ct_eq<3>{} + )); +} diff --git a/src/boost/libs/hana/test/optional/operator_deref.cpp b/src/boost/libs/hana/test/optional/operator_deref.cpp new file mode 100644 index 000000000..271094b48 --- /dev/null +++ b/src/boost/libs/hana/test/optional/operator_deref.cpp @@ -0,0 +1,33 @@ +// 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 +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto lvalue = hana::just(ct_eq<3>{}); + ct_eq<3>& ref = *lvalue; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + ref, + ct_eq<3>{} + )); + + auto const const_lvalue = hana::just(ct_eq<3>{}); + ct_eq<3> const& const_ref = *const_lvalue; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + const_ref, + ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + *hana::just(ct_eq<3>{}), + ct_eq<3>{} + )); +} diff --git a/src/boost/libs/hana/test/optional/representation.cpp b/src/boost/libs/hana/test/optional/representation.cpp new file mode 100644 index 000000000..d7a719e30 --- /dev/null +++ b/src/boost/libs/hana/test/optional/representation.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 + +#include +namespace hana = boost::hana; + + +struct Foo { }; + +int main() { + auto just = hana::just(Foo{}); + static_assert(std::is_same>{}, ""); + + auto nothing = hana::nothing; + static_assert(std::is_same>{}, ""); +} diff --git a/src/boost/libs/hana/test/optional/sfinae.cpp b/src/boost/libs/hana/test/optional/sfinae.cpp new file mode 100644 index 000000000..e821c248c --- /dev/null +++ b/src/boost/libs/hana/test/optional/sfinae.cpp @@ -0,0 +1,71 @@ +// 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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct undefined { }; + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sfinae(f)(), + hana::just(f()) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sfinae(f)(ct_eq<0>{}), + hana::just(f(ct_eq<0>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sfinae(f)(ct_eq<0>{}, ct_eq<1>{}), + hana::just(f(ct_eq<0>{}, ct_eq<1>{})) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sfinae(undefined{})(), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sfinae(undefined{})(ct_eq<0>{}), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sfinae(undefined{})(ct_eq<0>{}, ct_eq<1>{}), + hana::nothing + )); + + auto incr = hana::sfinae([](auto x) -> decltype(x + 1) { + return x + 1; + }); + + BOOST_HANA_RUNTIME_CHECK(hana::equal( + incr(1), + hana::just(2) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + incr(undefined{}), + hana::nothing + )); + BOOST_HANA_RUNTIME_CHECK(hana::equal( + hana::chain(hana::just(1), incr), + hana::just(2) + )); + + // using `sfinae` with a non-pod argument used to fail + hana::sfinae(undefined{})(Tracked{1}); + hana::sfinae([t = Tracked{1}](auto) { return 1; })(Tracked{1}); +} diff --git a/src/boost/libs/hana/test/optional/transform.cpp b/src/boost/libs/hana/test/optional/transform.cpp new file mode 100644 index 000000000..84f44dcf8 --- /dev/null +++ b/src/boost/libs/hana/test/optional/transform.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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct undefined { }; + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::nothing, undefined{}), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::just(ct_eq<3>{}), f), + hana::just(f(ct_eq<3>{})) + )); +} diff --git a/src/boost/libs/hana/test/optional/unpack.cpp b/src/boost/libs/hana/test/optional/unpack.cpp new file mode 100644 index 000000000..5968d33a3 --- /dev/null +++ b/src/boost/libs/hana/test/optional/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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::ct_eq<2> x{}; + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::nothing, f), + f() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::just(x), f), + f(x) + )); + + // Previously, there was a bug that would make this fail. + auto non_const_nothing = hana::nothing; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(non_const_nothing, f), + f() + )); +} diff --git a/src/boost/libs/hana/test/optional/value.cpp b/src/boost/libs/hana/test/optional/value.cpp new file mode 100644 index 000000000..710d73c75 --- /dev/null +++ b/src/boost/libs/hana/test/optional/value.cpp @@ -0,0 +1,33 @@ +// 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 +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto lvalue = hana::just(ct_eq<3>{}); + ct_eq<3>& ref = lvalue.value(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + ref, + ct_eq<3>{} + )); + + auto const const_lvalue = hana::just(ct_eq<3>{}); + ct_eq<3> const& const_ref = const_lvalue.value(); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + const_ref, + ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::just(ct_eq<3>{}).value(), + ct_eq<3>{} + )); +} diff --git a/src/boost/libs/hana/test/optional/value_or.cpp b/src/boost/libs/hana/test/optional/value_or.cpp new file mode 100644 index 000000000..05fa784f8 --- /dev/null +++ b/src/boost/libs/hana/test/optional/value_or.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 +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct undefined { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::nothing.value_or(ct_eq<3>{}), + ct_eq<3>{} + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::just(ct_eq<4>{}).value_or(undefined{}), + ct_eq<4>{} + )); +} diff --git a/src/boost/libs/hana/test/orderable.cpp b/src/boost/libs/hana/test/orderable.cpp new file mode 100644 index 000000000..8c6ce4f6b --- /dev/null +++ b/src/boost/libs/hana/test/orderable.cpp @@ -0,0 +1,126 @@ +// 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using namespace std::literals; + + +// Minimal LessThanComparable types +struct ord1 { int value; }; +struct ord2 { + int value; + constexpr operator ord1() const { return {value}; } +}; + +template {} || std::is_same{}) && + (std::is_same{} || std::is_same{}) +>> +constexpr bool operator<(T a, U b) +{ return a.value < b.value; } + +namespace boost { namespace hana { + template + struct equal_impl{} || std::is_same{}) && + (std::is_same{} || std::is_same{}) + >> { + static constexpr bool apply(T a, U b) + { return a.value == b.value; } + }; +}} + +int main() { + // laws + hana::test::TestOrderable{hana::make_tuple(0,1,2,3,4,5)}; + hana::test::TestOrderable{hana::make_tuple(0u,1u,2u,3u,4u,5u)}; + hana::test::TestOrderable{hana::make_tuple(0l,1l,2l,3l,4l,5l)}; + hana::test::TestOrderable{hana::make_tuple(0ul,1ul,2ul,3ul,4ul,5ul)}; + hana::test::TestOrderable{hana::make_tuple(ord1{0}, ord1{1}, ord1{2}, ord1{3}, ord1{4})}; + + // Orderable => Comparable + hana::test::TestComparable{hana::make_tuple(ord1{0}, ord1{1}, ord1{2}, ord1{3}, ord1{4})}; + + // less + { + BOOST_HANA_CONSTEXPR_CHECK(hana::less(5, 6)); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(6, 6))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(7, 6))); + + // Provided model for LessThanComparable types + BOOST_HANA_CONSTEXPR_CHECK(hana::less(ord1{0}, ord1{1})); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord1{0}, ord1{0}))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord1{1}, ord1{0}))); + + BOOST_HANA_CONSTEXPR_CHECK(hana::less(ord1{0}, ord2{1})); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord1{0}, ord2{0}))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord1{1}, ord2{0}))); + + BOOST_HANA_CONSTEXPR_CHECK(hana::less(ord2{0}, ord1{1})); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord2{0}, ord1{0}))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less(ord2{1}, ord1{0}))); + + BOOST_HANA_RUNTIME_CHECK(hana::less("ab", "abc"s)); + BOOST_HANA_RUNTIME_CHECK(hana::less("abc"s, "abcde")); + } + + // greater + { + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::greater(5, 6))); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::greater(6, 6))); + BOOST_HANA_CONSTEXPR_CHECK(hana::greater(7, 6)); + + BOOST_HANA_RUNTIME_CHECK(hana::greater("abcd", "ab"s)); + BOOST_HANA_RUNTIME_CHECK(hana::greater("abc"s, "abb")); + } + + // less_equal + { + BOOST_HANA_CONSTEXPR_CHECK(hana::less_equal(5, 6)); + BOOST_HANA_CONSTEXPR_CHECK(hana::less_equal(6, 6)); + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::less_equal(7, 6))); + + BOOST_HANA_RUNTIME_CHECK(hana::less_equal("ab", "abcd"s)); + BOOST_HANA_RUNTIME_CHECK(hana::less_equal("abc"s, "abc")); + } + + // greater_equal + { + BOOST_HANA_CONSTEXPR_CHECK(hana::not_(hana::greater_equal(5, 6))); + BOOST_HANA_CONSTEXPR_CHECK(hana::greater_equal(6, 6)); + BOOST_HANA_CONSTEXPR_CHECK(hana::greater_equal(7, 6)); + + BOOST_HANA_RUNTIME_CHECK(hana::greater_equal("abcd", "ab"s)); + BOOST_HANA_RUNTIME_CHECK(hana::greater_equal("abc"s, "abc")); + } + + // min + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::min(5, 6), 5)); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::min(6, 5), 5)); + } + + // max + { + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::max(5, 6), 6)); + BOOST_HANA_CONSTEXPR_CHECK(hana::equal(hana::max(6, 5), 6)); + } +} diff --git a/src/boost/libs/hana/test/pair/assign.copy.cpp b/src/boost/libs/hana/test/pair/assign.copy.cpp new file mode 100644 index 000000000..ddcf97c3f --- /dev/null +++ b/src/boost/libs/hana/test/pair/assign.copy.cpp @@ -0,0 +1,40 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +constexpr auto in_constexpr_context(int a, short b) { + hana::pair p1(a, b); + hana::pair p2; + hana::pair p3; + p2 = p1; + p3 = p2; + return p3; +} + +int main() { + { + hana::pair p1(3, 4); + hana::pair p2; + p2 = p1; + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == 3); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); + } + + // make sure that also works in a constexpr context + // (test fails under GCC <= 6 due to buggy constexpr) +#if BOOST_HANA_CONFIG_GCC >= BOOST_HANA_CONFIG_VERSION(7, 0, 0) + { + constexpr auto p = in_constexpr_context(3, 4); + static_assert(hana::first(p) == 3, ""); + static_assert(hana::second(p) == 4, ""); + } +#endif +} diff --git a/src/boost/libs/hana/test/pair/assign.move.cpp b/src/boost/libs/hana/test/pair/assign.move.cpp new file mode 100644 index 000000000..5d3fd18df --- /dev/null +++ b/src/boost/libs/hana/test/pair/assign.move.cpp @@ -0,0 +1,70 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } +}; + +struct MoveOnlyDerived : MoveOnly { + MoveOnlyDerived(MoveOnlyDerived&&) = default; + MoveOnlyDerived(int data = 1) : MoveOnly(data) { } +}; + +constexpr auto in_constexpr_context(int a, short b) { + hana::pair p1(a, b); + hana::pair p2; + hana::pair p3; + p2 = std::move(p1); + p3 = std::move(p2); + return p3; +} + +int main() { + // from pair to pair + { + hana::pair p1(MoveOnly{3}, 4); + hana::pair p2; + p2 = std::move(p1); + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == MoveOnly{3}); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); + } + + // from pair to pair + { + hana::pair p1(MoveOnlyDerived{3}, 4); + hana::pair p2; + p2 = std::move(p1); + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == MoveOnly{3}); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); + } + + // make sure that also works in a constexpr context + // (test fails under GCC <= 6 due to buggy constexpr) +#if BOOST_HANA_CONFIG_GCC >= BOOST_HANA_CONFIG_VERSION(7, 0, 0) + { + constexpr auto p = in_constexpr_context(3, 4); + static_assert(hana::first(p) == 3, ""); + static_assert(hana::second(p) == 4, ""); + } +#endif +} diff --git a/src/boost/libs/hana/test/pair/cnstr.copy.cpp b/src/boost/libs/hana/test/pair/cnstr.copy.cpp new file mode 100644 index 000000000..fcf46c4e6 --- /dev/null +++ b/src/boost/libs/hana/test/pair/cnstr.copy.cpp @@ -0,0 +1,94 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +struct implicit_to { + constexpr operator Target() const { return Target{}; } +}; + +struct NoCopy { + NoCopy() = default; + NoCopy(NoCopy const&) = delete; +}; + +// Note: It is also useful to check with a non-empty class, because that +// triggers different instantiations due to EBO. +struct NoCopy_nonempty { + NoCopy_nonempty() = default; + NoCopy_nonempty(NoCopy_nonempty const&) = delete; + int i; +}; + +int main() { + { + typedef std::pair P1; + hana::pair p1(3, 4); + hana::pair p2 = p1; + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == 3); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); + } + + static_assert(std::is_trivially_copy_constructible>{}, ""); + + // make sure it also works constexpr + { + constexpr hana::pair p1(3, 4); + constexpr hana::pair p2 = p1; + static_assert(hana::first(p2) == 3, ""); + static_assert(hana::second(p2) == 4, ""); + } + + // Make sure it works across pair types (pair -> pair) + { + hana::pair p1(3, 4); + hana::pair p2 = p1; + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == 3); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); + } + { + struct target1 { }; + struct target2 { }; + using Target = hana::pair; + + auto p1_ = hana::make_pair(target1{}, target2{}); + Target p1(p1_); (void)p1; + + auto p2_ = hana::make_pair(implicit_to{}, target2{}); + Target p2(p2_); (void)p2; + + auto p3_ = hana::make_pair(target1{}, implicit_to{}); + Target p3(p3_); (void)p3; + + auto p4_ = hana::make_pair(implicit_to{}, implicit_to{}); + Target p4(p4_); (void)p4; + } + + // And also constexpr across pair types + { + constexpr hana::pair p1(3, 4); + constexpr hana::pair p2 = p1; + static_assert(hana::first(p2) == 3, ""); + static_assert(hana::second(p2) == 4, ""); + } + + // Make sure we don't define the copy constructor when it shouldn't be defined. + { + using Pair1 = hana::pair; + Pair1 pair1; (void)pair1; + static_assert(!std::is_copy_constructible::value, ""); + + using Pair2 = hana::pair; + Pair2 pair2; (void)pair2; + static_assert(!std::is_copy_constructible::value, ""); + } +} diff --git a/src/boost/libs/hana/test/pair/cnstr.default.cpp b/src/boost/libs/hana/test/pair/cnstr.default.cpp new file mode 100644 index 000000000..4bffb7574 --- /dev/null +++ b/src/boost/libs/hana/test/pair/cnstr.default.cpp @@ -0,0 +1,71 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct NoDefault { + NoDefault() = delete; + explicit constexpr NoDefault(int) { } +}; + +struct NoDefault_nonempty { + NoDefault_nonempty() = delete; + explicit constexpr NoDefault_nonempty(int k) : i(k) { } + int i; +}; + +struct DefaultOnly { + DefaultOnly() = default; + DefaultOnly(DefaultOnly const&) = delete; + DefaultOnly(DefaultOnly&&) = delete; +}; + +struct NonConstexprDefault { + NonConstexprDefault() { } +}; + +int main() { + { + hana::pair p; + BOOST_HANA_RUNTIME_CHECK(hana::first(p) == 0.0f); + BOOST_HANA_RUNTIME_CHECK(hana::second(p) == nullptr); + } + + // make sure it also works constexpr + { + constexpr hana::pair p; + static_assert(hana::first(p) == 0.0f, ""); + static_assert(hana::second(p) == nullptr, ""); + } + + // make sure the default constructor is not instantiated when the + // members of the pair are not default-constructible + { + using Pair1 = hana::pair; + Pair1 p1{NoDefault{1}, NoDefault{2}}; (void)p1; + static_assert(!std::is_default_constructible{}, ""); + + using Pair2 = hana::pair; + Pair2 p2{NoDefault_nonempty{1}, NoDefault_nonempty{2}}; (void)p2; + static_assert(!std::is_default_constructible{}, ""); + } + + // make sure it works when only the default constructor is defined + { + hana::pair p; + (void)p; + } + + { + hana::pair p; + (void)p; + } +} diff --git a/src/boost/libs/hana/test/pair/cnstr.memberwise.cpp b/src/boost/libs/hana/test/pair/cnstr.memberwise.cpp new file mode 100644 index 000000000..badede7c1 --- /dev/null +++ b/src/boost/libs/hana/test/pair/cnstr.memberwise.cpp @@ -0,0 +1,87 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } +}; + +class FromInt { + int data_; +public: + constexpr FromInt(int data) : data_(data) { } + constexpr bool operator==(const FromInt& x) const { return data_ == x.data_; } +}; + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Check for the pair(T&&, U&&) constructor + ////////////////////////////////////////////////////////////////////////// + { + hana::pair p(MoveOnly{3}, nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::first(p) == MoveOnly{3}); + BOOST_HANA_RUNTIME_CHECK(hana::second(p) == nullptr); + } + + ////////////////////////////////////////////////////////////////////////// + // Check for the pair(First const&, Second const&) constructor + ////////////////////////////////////////////////////////////////////////// + { + hana::pair p1(3.5f, 0); + BOOST_HANA_RUNTIME_CHECK(hana::first(p1) == 3.5f); + BOOST_HANA_RUNTIME_CHECK(hana::second(p1) == nullptr); + + // brace init + hana::pair p2 = {3.5f, 0}; + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == 3.5f); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == nullptr); + } + { + hana::pair p1(1, 2); + BOOST_HANA_RUNTIME_CHECK(hana::first(p1) == FromInt(1)); + BOOST_HANA_RUNTIME_CHECK(hana::second(p1) == 2); + + // brace init + hana::pair p2 = {1, 2}; + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == FromInt(1)); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 2); + } + + // Make sure the above works constexpr too + { + constexpr hana::pair p1(3.5f, 0); + static_assert(hana::first(p1) == 3.5f, ""); + static_assert(hana::second(p1) == nullptr, ""); + + // brace init + constexpr hana::pair p2 = {3.5f, 0}; + static_assert(hana::first(p2) == 3.5f, ""); + static_assert(hana::second(p2) == nullptr, ""); + } + { + constexpr hana::pair p1(1, 2); + static_assert(hana::first(p1) == FromInt(1), ""); + static_assert(hana::second(p1) == 2, ""); + + // brace init + constexpr hana::pair p2 = {1, 2}; + static_assert(hana::first(p2) == FromInt(1), ""); + static_assert(hana::second(p2) == 2, ""); + } +} diff --git a/src/boost/libs/hana/test/pair/cnstr.move.cpp b/src/boost/libs/hana/test/pair/cnstr.move.cpp new file mode 100644 index 000000000..cb13e7243 --- /dev/null +++ b/src/boost/libs/hana/test/pair/cnstr.move.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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } +}; + +struct MoveOnlyDerived : MoveOnly { + MoveOnlyDerived(MoveOnlyDerived&&) = default; + MoveOnlyDerived(int data = 1) : MoveOnly(data) { } +}; + +template +struct implicit_to { + constexpr operator Target() const { return Target{}; } +}; + +struct NoMove { + NoMove() = default; + NoMove(NoMove const&) = delete; + NoMove(NoMove&&) = delete; +}; + +// Note: It is also useful to check with a non-empty class, because that +// triggers different instantiations due to EBO. +struct NoMove_nonempty { + NoMove_nonempty() = default; + NoMove_nonempty(NoMove_nonempty const&) = delete; + NoMove_nonempty(NoMove_nonempty&&) = delete; + int i; +}; + +int main() { + { + hana::pair p1(MoveOnly{3}, 4); + hana::pair p2(std::move(p1)); + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == MoveOnly{3}); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); + } + + // Make sure it works across pair types + { + hana::pair p1(MoveOnlyDerived{3}, 4); + hana::pair p2 = std::move(p1); + BOOST_HANA_RUNTIME_CHECK(hana::first(p2) == MoveOnly{3}); + BOOST_HANA_RUNTIME_CHECK(hana::second(p2) == 4); + } + { + struct target1 { + target1() = default; + target1(target1 const&) = delete; + target1(target1&&) = default; + }; + + struct target2 { + target2() = default; + target2(target2 const&) = delete; + target2(target2&&) = default; + }; + using Target = hana::pair; + Target p1(hana::make_pair(target1{}, target2{})); (void)p1; + Target p2(hana::make_pair(implicit_to{}, target2{})); (void)p2; + Target p3(hana::make_pair(target1{}, implicit_to{})); (void)p3; + Target p4(hana::make_pair(implicit_to{}, implicit_to{})); (void)p4; + } + + // Make sure we don't define the move constructor when it shouldn't be defined. + { + using Pair1 = hana::pair; + Pair1 pair1; (void)pair1; + static_assert(!std::is_move_constructible::value, ""); + + using Pair2 = hana::pair; + Pair2 pair2; (void)pair2; + static_assert(!std::is_move_constructible::value, ""); + } +} diff --git a/src/boost/libs/hana/test/pair/comparable.cpp b/src/boost/libs/hana/test/pair/comparable.cpp new file mode 100644 index 000000000..13537c9ef --- /dev/null +++ b/src/boost/libs/hana/test/pair/comparable.cpp @@ -0,0 +1,33 @@ +// 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 +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK( + hana::make_pair(ct_eq<1>{}, ct_eq<2>{}) == + hana::make_pair(ct_eq<1>{}, ct_eq<2>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::make_pair(ct_eq<1>{}, ct_eq<3>{}) != + hana::make_pair(ct_eq<1>{}, ct_eq<2>{}) + ); + + hana::test::TestComparable{hana::make_tuple( + hana::make_pair(ct_eq<3>{}, ct_eq<3>{}) + , hana::make_pair(ct_eq<3>{}, ct_eq<4>{}) + , hana::make_pair(ct_eq<4>{}, ct_eq<3>{}) + , hana::make_pair(ct_eq<4>{}, ct_eq<4>{}) + )}; +} diff --git a/src/boost/libs/hana/test/pair/empty_storage.cpp b/src/boost/libs/hana/test/pair/empty_storage.cpp new file mode 100644 index 000000000..000041485 --- /dev/null +++ b/src/boost/libs/hana/test/pair/empty_storage.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 + +#include +namespace hana = boost::hana; + + +struct empty1 { }; +struct empty2 { }; +struct empty3 { }; +struct empty4 { }; + +// Make sure the storage of a pair is compressed +static_assert(sizeof(hana::pair) == sizeof(int), ""); +static_assert(sizeof(hana::pair) == sizeof(int), ""); + +// Also make sure that a pair with only empty members is empty too. This is +// important to ensure, for example, that a tuple of pairs of empty objects +// will get the EBO. +static_assert(std::is_empty>{}, ""); + +// Make sure that a pair of empty pairs is still empty. +static_assert(std::is_empty< + hana::pair, empty3> +>{}, ""); + +static_assert(std::is_empty< + hana::pair, hana::pair> +>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/pair/foldable.cpp b/src/boost/libs/hana/test/pair/foldable.cpp new file mode 100644 index 000000000..88dc68276 --- /dev/null +++ b/src/boost/libs/hana/test/pair/foldable.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 +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_pair(ct_eq<1>{}, ct_eq<2>{}), f), + f(ct_eq<1>{}, ct_eq<2>{}) + )); + + hana::test::TestFoldable{hana::make_tuple( + hana::make_pair(ct_eq<3>{}, ct_eq<3>{}) + , hana::make_pair(ct_eq<3>{}, ct_eq<4>{}) + , hana::make_pair(ct_eq<4>{}, ct_eq<3>{}) + , hana::make_pair(ct_eq<4>{}, ct_eq<4>{}) + )}; +} diff --git a/src/boost/libs/hana/test/pair/issue_90.cpp b/src/boost/libs/hana/test/pair/issue_90.cpp new file mode 100644 index 000000000..a46623e8c --- /dev/null +++ b/src/boost/libs/hana/test/pair/issue_90.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 +#include +#include + +#include +namespace hana = boost::hana; + + +template +T const& cref(T& t) { return t; } + +// a non-movable, non-copyable type +struct RefOnly { + RefOnly() = default; + RefOnly(RefOnly const&) = delete; + RefOnly(RefOnly&&) = delete; +}; + +int main() { + // This test makes sure that we return the proper reference types from + // `first` and `second`. + hana::pair p; + + { + RefOnly&& r1 = hana::first(std::move(p)); + RefOnly& r2 = hana::first(p); + RefOnly const& r3 = hana::first(cref(p)); + + (void)r1; (void)r2; (void)r3; + } + + { + RefOnly&& r1 = hana::second(std::move(p)); + RefOnly& r2 = hana::second(p); + RefOnly const& r3 = hana::second(cref(p)); + + (void)r1; (void)r2; (void)r3; + } +} diff --git a/src/boost/libs/hana/test/pair/make.cpp b/src/boost/libs/hana/test/pair/make.cpp new file mode 100644 index 000000000..3db5030a8 --- /dev/null +++ b/src/boost/libs/hana/test/pair/make.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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } +}; + +int main() { + { + hana::pair p = hana::make_pair(3, 4); + BOOST_HANA_RUNTIME_CHECK(hana::first(p) == 3); + BOOST_HANA_RUNTIME_CHECK(hana::second(p) == 4); + } + + { + hana::pair p = hana::make_pair(MoveOnly{3}, 4); + BOOST_HANA_RUNTIME_CHECK(hana::first(p) == MoveOnly{3}); + BOOST_HANA_RUNTIME_CHECK(hana::second(p) == 4); + } + + { + hana::pair p = hana::make_pair(3, 4); + BOOST_HANA_RUNTIME_CHECK(hana::first(p) == MoveOnly{3}); + BOOST_HANA_RUNTIME_CHECK(hana::second(p) == 4); + } + + { + constexpr hana::pair p = hana::make_pair(3, 4); + static_assert(hana::first(p) == 3, ""); + static_assert(hana::second(p) == 4, ""); + } + + // equivalence with make + { + constexpr hana::pair p = hana::make(3, 4); + static_assert(hana::first(p) == 3, ""); + static_assert(hana::second(p) == 4, ""); + } +} diff --git a/src/boost/libs/hana/test/pair/orderable.cpp b/src/boost/libs/hana/test/pair/orderable.cpp new file mode 100644 index 000000000..fabd828d9 --- /dev/null +++ b/src/boost/libs/hana/test/pair/orderable.cpp @@ -0,0 +1,46 @@ +// 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 +#include +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_ord; + + +int main() { + BOOST_HANA_CONSTANT_CHECK( + hana::make_pair(ct_ord<1>{}, ct_ord<2>{}) < + hana::make_pair(ct_ord<3>{}, ct_ord<2>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::make_pair(ct_ord<1>{}, ct_ord<2>{}) <= + hana::make_pair(ct_ord<3>{}, ct_ord<2>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::make_pair(ct_ord<3>{}, ct_ord<2>{}) >= + hana::make_pair(ct_ord<1>{}, ct_ord<2>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::make_pair(ct_ord<3>{}, ct_ord<2>{}) > + hana::make_pair(ct_ord<1>{}, ct_ord<2>{}) + ); + + hana::test::TestOrderable{hana::make_tuple( + hana::make_pair(ct_ord<3>{}, ct_ord<3>{}) + , hana::make_pair(ct_ord<3>{}, ct_ord<4>{}) + , hana::make_pair(ct_ord<4>{}, ct_ord<3>{}) + , hana::make_pair(ct_ord<4>{}, ct_ord<4>{}) + )}; +} diff --git a/src/boost/libs/hana/test/pair/product.cpp b/src/boost/libs/hana/test/pair/product.cpp new file mode 100644 index 000000000..b87f06ac6 --- /dev/null +++ b/src/boost/libs/hana/test/pair/product.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 +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + // first, second + { + hana::pair, ct_eq<2>> p; + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::first(p), ct_eq<1>{})); + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::second(p), ct_eq<2>{})); + } + + hana::test::TestProduct{hana::make_tuple( + ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{} + )}; +} diff --git a/src/boost/libs/hana/test/pair/tag_of.cpp b/src/boost/libs/hana/test/pair/tag_of.cpp new file mode 100644 index 000000000..285b892e8 --- /dev/null +++ b/src/boost/libs/hana/test/pair/tag_of.cpp @@ -0,0 +1,36 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + { + struct T { }; struct U { }; + static_assert(std::is_same< + hana::tag_of>::type, + hana::pair_tag + >{}, ""); + } + + // Bug #1 + { + using Pair = hana::pair, int>; + using PairTag = hana::tag_of::type; + using Tag = hana::tag_of>::type; + } + + // Bug #2 + { + using Pair = hana::pair, int>; + using PairTag = hana::tag_of::type; + using Tag = hana::tag_of>::type; + } +} diff --git a/src/boost/libs/hana/test/range/at.cpp b/src/boost/libs/hana/test/range/at.cpp new file mode 100644 index 000000000..b57c4de8f --- /dev/null +++ b/src/boost/libs/hana/test/range/at.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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<10>)[hana::int_c<2>], + hana::int_c<2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<0>), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<0>), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<1>), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(hana::make_range(hana::int_c<4>, hana::int_c<90>), hana::int_c<46>), + hana::int_c<50> + )); +} diff --git a/src/boost/libs/hana/test/range/back.cpp b/src/boost/libs/hana/test/range/back.cpp new file mode 100644 index 000000000..c6c666e6d --- /dev/null +++ b/src/boost/libs/hana/test/range/back.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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<0>, hana::int_c<3>)), + hana::int_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::back(hana::make_range(hana::int_c<3>, hana::int_c<6>)), + hana::int_c<5> + )); +} diff --git a/src/boost/libs/hana/test/range/contains.cpp b/src/boost/libs/hana/test/range/contains.cpp new file mode 100644 index 000000000..7a9c50823 --- /dev/null +++ b/src/boost/libs/hana/test/range/contains.cpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + cnumeric + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<1>), + cnumeric + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<10>), + cnumeric + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<10>), + cnumeric + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<-10>, hana::int_c<10>), + cnumeric + )); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::make_range(hana::int_c<-10>, hana::int_c<10>), + cnumeric + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_range(hana::int_c<-10>, hana::int_c<0>), + cnumeric + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + hana::make_range(hana::int_c<0>, hana::int_c<10>), + cnumeric + ))); +} diff --git a/src/boost/libs/hana/test/range/drop_front.cpp b/src/boost/libs/hana/test/range/drop_front.cpp new file mode 100644 index 000000000..16c0e9ef0 --- /dev/null +++ b/src/boost/libs/hana/test/range/drop_front.cpp @@ -0,0 +1,75 @@ +// 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<1>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<2>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<2>), + hana::make_range(hana::int_c<1>, hana::int_c<1>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<3>), + hana::make_range(hana::int_c<3>, hana::int_c<3>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front(hana::make_range(hana::int_c<20>, hana::int_c<50>), hana::int_c<10>), + hana::make_range(hana::int_c<30>, hana::int_c<50>) + )); +} diff --git a/src/boost/libs/hana/test/range/drop_front_exactly.cpp b/src/boost/libs/hana/test/range/drop_front_exactly.cpp new file mode 100644 index 000000000..da9644927 --- /dev/null +++ b/src/boost/libs/hana/test/range/drop_front_exactly.cpp @@ -0,0 +1,63 @@ +// 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<0>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<1>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<1>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<2>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<1>), + hana::make_range(hana::int_c<1>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<2>), + hana::make_range(hana::int_c<2>, hana::int_c<3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<0>, hana::int_c<3>), hana::int_c<3>), + hana::make_range(hana::int_c<3>, hana::int_c<3>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::make_range(hana::int_c<20>, hana::int_c<50>), hana::int_c<10>), + hana::make_range(hana::int_c<30>, hana::int_c<50>) + )); +} diff --git a/src/boost/libs/hana/test/range/equal.cpp b/src/boost/libs/hana/test/range/equal.cpp new file mode 100644 index 000000000..22babe501 --- /dev/null +++ b/src/boost/libs/hana/test/range/equal.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include // for operator != +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK( + hana::make_range(hana::int_c<0>, hana::int_c<0>) == + hana::make_range(hana::int_c<0>, hana::int_c<0>) + ); + BOOST_HANA_CONSTANT_CHECK( + hana::make_range(hana::int_c<0>, hana::int_c<4>) != + hana::make_range(hana::int_c<0>, hana::int_c<0>) + ); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<1>), + hana::make_range(hana::int_c<0>, hana::int_c<0>) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<1>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<2>), + hana::make_range(hana::int_c<0>, hana::int_c<1>) + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<2>), + hana::make_range(hana::int_c<0>, hana::int_c<2>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<0>, hana::int_c<0>), + hana::make_range(hana::int_c<2>, hana::int_c<2>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<2>, hana::int_c<4>), + hana::make_range(hana::int_c<2>, hana::int_c<4>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<-4>, hana::int_c<-3>), + hana::make_range(hana::int_c<-4>, hana::int_c<-3>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_range(hana::int_c<-4>, hana::int_c<2>), + hana::make_range(hana::int_c<-4>, hana::int_c<2>) + )); +} diff --git a/src/boost/libs/hana/test/range/find.cpp b/src/boost/libs/hana/test/range/find.cpp new file mode 100644 index 000000000..29954e8a9 --- /dev/null +++ b/src/boost/libs/hana/test/range/find.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 +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<0>), cnumeric), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<1>), cnumeric), + hana::just(hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<10>), cnumeric), + hana::just(hana::int_c<3>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<10>), cnumeric), + hana::just(hana::int_c<9>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<-10>, hana::int_c<10>), cnumeric), + hana::just(hana::int_c<-10>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<-10>, hana::int_c<10>), cnumeric), + hana::just(hana::int_c<-5>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<-10>, hana::int_c<0>), cnumeric), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(hana::make_range(hana::int_c<0>, hana::int_c<10>), cnumeric), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/range/front.cpp b/src/boost/libs/hana/test/range/front.cpp new file mode 100644 index 000000000..e3777a3b9 --- /dev/null +++ b/src/boost/libs/hana/test/range/front.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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<2>, hana::int_c<5>)), + hana::int_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<5>, hana::int_c<6>)), + hana::int_c<5> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::make_range(hana::int_c<5>, hana::long_c<6>)), + hana::long_c<5> + )); +} diff --git a/src/boost/libs/hana/test/range/is_empty.cpp b/src/boost/libs/hana/test/range/is_empty.cpp new file mode 100644 index 000000000..5ad791374 --- /dev/null +++ b/src/boost/libs/hana/test/range/is_empty.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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty( + hana::make_range(hana::int_c<0>, hana::int_c<0>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::make_range(hana::int_c<0>, hana::int_c<1>) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty( + hana::make_range(hana::int_c<0>, hana::int_c<2>) + ))); +} diff --git a/src/boost/libs/hana/test/range/laws.cpp b/src/boost/libs/hana/test/range/laws.cpp new file mode 100644 index 000000000..070913cba --- /dev/null +++ b/src/boost/libs/hana/test/range/laws.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 +#include +#include + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + auto ranges = hana::make_tuple( + hana::make_range(hana::int_c<0>, hana::int_c<0>) + , hana::make_range(hana::int_c<0>, hana::int_c<1>) + , hana::make_range(hana::int_c<0>, hana::int_c<2>) + , hana::make_range(hana::int_c<1>, hana::int_c<1>) + , hana::make_range(hana::int_c<1>, hana::int_c<2>) + , hana::make_range(hana::int_c<1>, hana::int_c<3>) + , hana::make_range(hana::int_c<50>, hana::int_c<60>) + + , hana::make_range(hana::int_c<50>, hana::long_c<60>) + , hana::make_range(hana::long_c<50>, hana::int_c<60>) + ); + + auto integers = hana::tuple_c; + + hana::test::TestComparable{ranges}; + hana::test::TestFoldable{ranges}; + hana::test::TestIterable{ranges}; + hana::test::TestSearchable{ranges, integers}; +} diff --git a/src/boost/libs/hana/test/range/length.cpp b/src/boost/libs/hana/test/range/length.cpp new file mode 100644 index 000000000..3eb9799f7 --- /dev/null +++ b/src/boost/libs/hana/test/range/length.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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<0>, hana::int_c<0>)), + hana::size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<4>, hana::int_c<4>)), + hana::size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(hana::make_range(hana::int_c<4>, hana::int_c<10>)), + hana::size_c<6> + )); +} diff --git a/src/boost/libs/hana/test/range/make.cpp b/src/boost/libs/hana/test/range/make.cpp new file mode 100644 index 000000000..cd9fe94c5 --- /dev/null +++ b/src/boost/libs/hana/test/range/make.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // make sure make works with arbitrary Constants + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(hana::test::_constant<1>{}, hana::test::_constant<4>{}), + hana::make_range(hana::integral_c, hana::integral_c) + )); +} diff --git a/src/boost/libs/hana/test/range/maximum.cpp b/src/boost/libs/hana/test/range/maximum.cpp new file mode 100644 index 000000000..ca98b16e8 --- /dev/null +++ b/src/boost/libs/hana/test/range/maximum.cpp @@ -0,0 +1,27 @@ +// 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maximum(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maximum(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<4> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::maximum(hana::make_range(hana::int_c<-1>, hana::int_c<6>)), + hana::int_c<5> + )); +} diff --git a/src/boost/libs/hana/test/range/minimum.cpp b/src/boost/libs/hana/test/range/minimum.cpp new file mode 100644 index 000000000..3a5da38cc --- /dev/null +++ b/src/boost/libs/hana/test/range/minimum.cpp @@ -0,0 +1,27 @@ +// 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minimum(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minimum(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::minimum(hana::make_range(hana::int_c<-1>, hana::int_c<5>)), + hana::int_c<-1> + )); +} diff --git a/src/boost/libs/hana/test/range/product.cpp b/src/boost/libs/hana/test/range/product.cpp new file mode 100644 index 000000000..0a15a23c8 --- /dev/null +++ b/src/boost/libs/hana/test/range/product.cpp @@ -0,0 +1,85 @@ +// 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<-3>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<-2>)), + hana::int_c<-3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<-1>)), + hana::int_c<-3 * -2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<0>)), + hana::int_c<-3 * -2 * -1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<1>)), + hana::int_c<-3 * -2 * -1 * 0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<2>)), + hana::int_c<-3 * -2 * -1 * 0 * 1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<-3>, hana::int_c<3>)), + hana::int_c<-3 * -2 * -1 * 0 * 1 * 2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<1>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<2>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<3>)), + hana::int_c<1 * 2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<4>)), + hana::int_c<1 * 2 * 3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<1>, hana::int_c<5>)), + hana::int_c<1 * 2 * 3 * 4> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<3>)), + hana::int_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<3 * 4> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<6>)), + hana::int_c<3 * 4 * 5> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::product<>(hana::make_range(hana::int_c<3>, hana::int_c<7>)), + hana::int_c<3 * 4 * 5 * 6> + )); +} diff --git a/src/boost/libs/hana/test/range/range_c.cpp b/src/boost/libs/hana/test/range/range_c.cpp new file mode 100644 index 000000000..9d384c2da --- /dev/null +++ b/src/boost/libs/hana/test/range/range_c.cpp @@ -0,0 +1,40 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + using T = int; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c, + hana::make_range(hana::integral_c, hana::integral_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c, + hana::make_range(hana::integral_c, hana::integral_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c, + hana::make_range(hana::integral_c, hana::integral_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c, + hana::make_range(hana::integral_c, hana::integral_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c, + hana::make_range(hana::integral_c, hana::integral_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::range_c, + hana::make_range(hana::integral_c, hana::integral_c) + )); +} diff --git a/src/boost/libs/hana/test/range/sum.cpp b/src/boost/libs/hana/test/range/sum.cpp new file mode 100644 index 000000000..3575c3c9a --- /dev/null +++ b/src/boost/libs/hana/test/range/sum.cpp @@ -0,0 +1,85 @@ +// 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<-3>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<-2>)), + hana::int_c<-3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<-1>)), + hana::int_c<-3 + -2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<0>)), + hana::int_c<-3 + -2 + -1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<1>)), + hana::int_c<-3 + -2 + -1 + 0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<2>)), + hana::int_c<-3 + -2 + -1 + 0 + 1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<-3>, hana::int_c<3>)), + hana::int_c<-3 + -2 + -1 + 0 + 1 + 2> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<0>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<1>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<2>)), + hana::int_c<0 + 1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<3>)), + hana::int_c<0 + 1 + 2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<0>, hana::int_c<4>)), + hana::int_c<0 + 1 + 2 + 3> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<3>)), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<4>)), + hana::int_c<3> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<5>)), + hana::int_c<3 + 4> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<6>)), + hana::int_c<3 + 4 + 5> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sum<>(hana::make_range(hana::int_c<3>, hana::int_c<7>)), + hana::int_c<3 + 4 + 5 + 6> + )); +} diff --git a/src/boost/libs/hana/test/range/unpack.cpp b/src/boost/libs/hana/test/range/unpack.cpp new file mode 100644 index 000000000..45b2e7287 --- /dev/null +++ b/src/boost/libs/hana/test/range/unpack.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 +#include +#include +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<0>), f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), f), + f(hana::int_c<0>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<2>), f), + f(hana::int_c<0>, hana::int_c<1>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<3>), f), + f(hana::int_c<0>, hana::int_c<1>, hana::int_c<2>) + )); + + // Previously, we would only unpack with `std::size_t`s. Make + // sure this does not happen. + hana::unpack(hana::make_range(hana::int_c<0>, hana::int_c<1>), [](auto x) { + using T = hana::tag_of_t; + static_assert(std::is_same{}, ""); + }); +} diff --git a/src/boost/libs/hana/test/repeat.cpp b/src/boost/libs/hana/test/repeat.cpp new file mode 100644 index 000000000..0d9e42ec8 --- /dev/null +++ b/src/boost/libs/hana/test/repeat.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 +#include +#include +namespace hana = boost::hana; + + +////////////////////////////////////////////////////////////////////////////// +// Define a simple model of IntegralConstant for use below +template +struct constant { + static constexpr int value = i; + using value_type = int; +}; + +namespace boost { namespace hana { + template + struct IntegralConstant> { + static constexpr bool value = true; + }; + + // definition of `to<>` omitted +}} +////////////////////////////////////////////////////////////////////////////// + +void function() { } + +int main() { + int counter = 0; + hana::repeat(constant<3>{}, [&] { ++counter; }); + BOOST_HANA_RUNTIME_CHECK(counter == 3); + + // Try with a normal function. + hana::repeat(constant<3>{}, function); + + // Try with a function pointer. + hana::repeat(constant<3>{}, static_cast(function)); + + // Make sure we don't read from a non-constexpr variable. + constant<3> three{}; + hana::repeat(three, []{}); +} diff --git a/src/boost/libs/hana/test/ring.cpp b/src/boost/libs/hana/test/ring.cpp new file mode 100644 index 000000000..f1d3fd43a --- /dev/null +++ b/src/boost/libs/hana/test/ring.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::TestRing{hana::make_tuple(0,1,2,3,4,5)}; + hana::test::TestRing{hana::make_tuple(0l,1l,2l,3l,4l,5l)}; + + // one + static_assert(hana::one() == 1, ""); + + // mult + static_assert(hana::mult(6, 4) == 6 * 4, ""); +} diff --git a/src/boost/libs/hana/test/searchable.cpp b/src/boost/libs/hana/test/searchable.cpp new file mode 100644 index 000000000..379fa40d4 --- /dev/null +++ b/src/boost/libs/hana/test/searchable.cpp @@ -0,0 +1,44 @@ +// 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 +#include +#include + +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + ////////////////////////////////////////////////////////////////////////// + // Laws with a minimal Searchable + ////////////////////////////////////////////////////////////////////////// + { + auto eqs = hana::make_tuple( + ::seq() + , ::seq(ct_eq<0>{}) + , ::seq(ct_eq<0>{}, ct_eq<1>{}) + , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , ::seq(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + ); + + auto eq_keys = hana::make_tuple(ct_eq<0>{}, ct_eq<3>{}, ct_eq<10>{}); + + hana::test::TestSearchable<::Seq>{eqs, eq_keys}; + + auto bools = hana::make_tuple( + ::seq(hana::true_c) + , ::seq(hana::false_c) + , ::seq(hana::true_c, hana::true_c) + , ::seq(hana::true_c, hana::false_c) + , ::seq(hana::false_c, hana::true_c) + , ::seq(hana::false_c, hana::false_c) + ); + hana::test::TestSearchable<::Seq>{bools, hana::make_tuple(hana::true_c, hana::false_c)}; + } +} diff --git a/src/boost/libs/hana/test/set/any_of.cpp b/src/boost/libs/hana/test/set/any_of.cpp new file mode 100644 index 000000000..1f092cbeb --- /dev/null +++ b/src/boost/libs/hana/test/set/any_of.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + hana::make_set(), + hana::equal.to(ct_eq<1>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + hana::make_set(ct_eq<1>{}), + hana::equal.to(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + hana::make_set(ct_eq<1>{}), + hana::equal.to(ct_eq<2>{}) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + hana::make_set(ct_eq<1>{}, ct_eq<2>{}), + hana::equal.to(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + hana::make_set(ct_eq<1>{}, ct_eq<2>{}), + hana::equal.to(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + hana::make_set(ct_eq<1>{}, ct_eq<2>{}), + hana::equal.to(ct_eq<3>{}) + ))); +} diff --git a/src/boost/libs/hana/test/set/cnstr.copy.cpp b/src/boost/libs/hana/test/set/cnstr.copy.cpp new file mode 100644 index 000000000..a3fa27571 --- /dev/null +++ b/src/boost/libs/hana/test/set/cnstr.copy.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +namespace hana = boost::hana; + + +int main() { + { + auto t0 = hana::make_set(); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_explicit; + (void)t_implicit; + } + { + auto t0 = hana::make_set(hana::int_c<2>); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_set(hana::int_c<2>, hana::int_c<3>); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_set(hana::int_c<2>, hana::int_c<3>, hana::type_c); + auto t_implicit = t0; + auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } + { + constexpr auto t0 = hana::make_set(hana::int_c<2>, hana::int_c<3>, hana::type_c); + constexpr auto t_implicit = t0; + constexpr auto t_explicit(t0); + + (void)t_implicit; + (void)t_explicit; + } +} diff --git a/src/boost/libs/hana/test/set/cnstr.default.cpp b/src/boost/libs/hana/test/set/cnstr.default.cpp new file mode 100644 index 000000000..bc5ee91db --- /dev/null +++ b/src/boost/libs/hana/test/set/cnstr.default.cpp @@ -0,0 +1,77 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +struct NoDefault { + NoDefault() = delete; + NoDefault(NoDefault const&) = default; + constexpr explicit NoDefault(int) { } +}; + +template +auto operator==(NoDefault const&, NoDefault const&) { return hana::bool_{}; } +template +auto operator!=(NoDefault const&, NoDefault const&) { return hana::bool_{}; } + +template +struct Default { + Default() = default; + Default(Default const&) = default; + constexpr explicit Default(int) { } +}; + +template +auto operator==(Default const&, Default const&) { return hana::bool_{}; } +template +auto operator!=(Default const&, Default const&) { return hana::bool_{}; } + +namespace boost { namespace hana { + template + struct hash_impl> { + static constexpr auto apply(NoDefault const&) + { return hana::type_c>; }; + }; + + template + struct hash_impl> { + static constexpr auto apply(Default const&) + { return hana::type_c>; }; + }; +}} + +int main() { + { + auto set0 = hana::make_set(); + static_assert(std::is_default_constructible{}, ""); + + auto set1 = hana::make_set(Default<0>(int{})); + static_assert(std::is_default_constructible{}, ""); + + auto set2 = hana::make_set(Default<0>(int{}), Default<1>(int{})); + static_assert(std::is_default_constructible{}, ""); + + auto set3 = hana::make_set(Default<0>(int{}), NoDefault<1>(int{}), Default<2>(int{})); + static_assert(!std::is_default_constructible{}, ""); + } + + { + auto set1 = hana::make_set(NoDefault<0>(int{})); + static_assert(!std::is_default_constructible{}, ""); + + auto set2 = hana::make_set(NoDefault<0>(int{}), NoDefault<1>(int{})); + static_assert(!std::is_default_constructible{}, ""); + + auto set3 = hana::make_set(NoDefault<0>(int{}), NoDefault<1>(int{}), NoDefault<2>(int{})); + static_assert(!std::is_default_constructible{}, ""); + } +} \ No newline at end of file diff --git a/src/boost/libs/hana/test/set/cnstr.move.cpp b/src/boost/libs/hana/test/set/cnstr.move.cpp new file mode 100644 index 000000000..e1a985111 --- /dev/null +++ b/src/boost/libs/hana/test/set/cnstr.move.cpp @@ -0,0 +1,63 @@ +// 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 +#include +#include +#include + +#include +#include + +#include +namespace hana = boost::hana; + + +constexpr bool in_constexpr_context() { + auto t0 = hana::make_set(ConstexprMoveOnly<2>{}, ConstexprMoveOnly<3>{}); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + return true; +} + +static_assert(in_constexpr_context(), ""); + + +int main() { + { + auto t0 = hana::make_set(); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_explicit; + (void)t_implicit; + } + { + auto t0 = hana::make_set(TrackedMoveOnly<1>{}); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_set(TrackedMoveOnly<1>{}, TrackedMoveOnly<2>{}); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + } + { + auto t0 = hana::make_set(TrackedMoveOnly<1>{}, TrackedMoveOnly<2>{}, TrackedMoveOnly<3>{}); + auto t_implicit = std::move(t0); + auto t_explicit(std::move(t_implicit)); + + (void)t_implicit; + (void)t_explicit; + } +} diff --git a/src/boost/libs/hana/test/set/cnstr.trap.cpp b/src/boost/libs/hana/test/set/cnstr.trap.cpp new file mode 100644 index 000000000..fd95b15e7 --- /dev/null +++ b/src/boost/libs/hana/test/set/cnstr.trap.cpp @@ -0,0 +1,67 @@ +// 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +// This test makes sure that we do not instantiate rogue constructors when +// doing copies and moves + +template +struct Trap { + Trap() = default; + Trap(Trap const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap(Trap&) = default; +#endif + Trap(Trap&&) = default; + + template + Trap(X&&) { + static_assert(hana::detail::wrong{}, + "this constructor must not be instantiated"); + } +}; + +template +constexpr auto operator==(Trap const&, Trap const&) +{ return hana::bool_c; } + +template +constexpr auto operator!=(Trap const&, Trap const&) +{ return hana::bool_c; } + +namespace boost { namespace hana { + template + struct hash_impl> { + static constexpr auto apply(Trap const&) + { return hana::type_c>; }; + }; +}} + +int main() { + { + auto expr = hana::make_set(Trap<0>{}); + auto implicit_copy = expr; + decltype(expr) explicit_copy(expr); + + (void)implicit_copy; + (void)explicit_copy; + } + { + auto expr = hana::make_set(Trap<0>{}); + auto implicit_move = std::move(expr); + decltype(expr) explicit_move(std::move(implicit_move)); + + (void)implicit_move; + (void)explicit_move; + } +} diff --git a/src/boost/libs/hana/test/set/difference.cpp b/src/boost/libs/hana/test/set/difference.cpp new file mode 100644 index 000000000..fdb7c91c0 --- /dev/null +++ b/src/boost/libs/hana/test/set/difference.cpp @@ -0,0 +1,67 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_set(), + hana::make_set() + ), + hana::make_set() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_set(ct_eq<0>{}), + hana::make_set() + ), + hana::make_set(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set() + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set() + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<1>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<1>{}, ct_eq<3>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<1>{}, ct_eq<3>{}, ct_eq<2>{}) + ), + hana::make_set(ct_eq<0>{}) + )); +} diff --git a/src/boost/libs/hana/test/set/equal.cpp b/src/boost/libs/hana/test/set/equal.cpp new file mode 100644 index 000000000..d0c350734 --- /dev/null +++ b/src/boost/libs/hana/test/set/equal.cpp @@ -0,0 +1,56 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include // for operator != +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto check = [](auto ...keys) { + auto keys_set = hana::make_set(keys...); + auto keys_tuple = hana::make_tuple(keys...); + auto possible_arrangements = hana::permutations(keys_tuple); + + hana::for_each(possible_arrangements, [&](auto perm) { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_set(perm), + keys_set + )); + }); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + keys_set, + hana::make_set(keys..., ct_eq<999>{}) + ))); + }; + + check(); + check(ct_eq<0>{}); + check(ct_eq<0>{}, ct_eq<1>{}); + check(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}); + + // check operators + BOOST_HANA_CONSTANT_CHECK( + hana::make_set(ct_eq<0>{}) + == + hana::make_set(ct_eq<0>{}) + ); + + BOOST_HANA_CONSTANT_CHECK( + hana::make_set(ct_eq<0>{}) + != + hana::make_set(ct_eq<1>{}) + ); +} diff --git a/src/boost/libs/hana/test/set/erase_key.cpp b/src/boost/libs/hana/test/set/erase_key.cpp new file mode 100644 index 000000000..4103144a2 --- /dev/null +++ b/src/boost/libs/hana/test/set/erase_key.cpp @@ -0,0 +1,62 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +struct undefined { }; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(), undefined{}), + hana::make_set() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}), ct_eq<0>{}), + hana::make_set() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}), ct_eq<99>{}), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}, ct_eq<1>{}), ct_eq<0>{}), + hana::make_set(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}, ct_eq<1>{}), ct_eq<1>{}), + hana::make_set(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}, ct_eq<1>{}), ct_eq<99>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), ct_eq<0>{}), + hana::make_set(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), ct_eq<1>{}), + hana::make_set(ct_eq<0>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), ct_eq<2>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::erase_key(hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), ct_eq<99>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); +} diff --git a/src/boost/libs/hana/test/set/find_if.cpp b/src/boost/libs/hana/test/set/find_if.cpp new file mode 100644 index 000000000..190d311e1 --- /dev/null +++ b/src/boost/libs/hana/test/set/find_if.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 +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_set(), hana::equal.to(ct_eq<1>{})), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_set(ct_eq<1>{}), hana::equal.to(ct_eq<1>{})), + hana::just(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_set(ct_eq<1>{}), hana::equal.to(ct_eq<2>{})), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_set(ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(ct_eq<1>{})), + hana::just(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_set(ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(ct_eq<2>{})), + hana::just(ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(hana::make_set(ct_eq<1>{}, ct_eq<2>{}), hana::equal.to(ct_eq<3>{})), + hana::nothing + )); + + // find with operators + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_set(ct_eq<1>{})[ct_eq<1>{}], + ct_eq<1>{} + )); +} diff --git a/src/boost/libs/hana/test/set/insert.cpp b/src/boost/libs/hana/test/set/insert.cpp new file mode 100644 index 000000000..daa50be00 --- /dev/null +++ b/src/boost/libs/hana/test/set/insert.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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_set(), ct_eq<0>{}), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_set(ct_eq<0>{}), ct_eq<0>{}), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_set(ct_eq<0>{}), ct_eq<1>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_set(ct_eq<0>{}, ct_eq<1>{}), ct_eq<1>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_set(ct_eq<0>{}, ct_eq<1>{}), ct_eq<2>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::insert(hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), ct_eq<3>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); +} diff --git a/src/boost/libs/hana/test/set/intersection.cpp b/src/boost/libs/hana/test/set/intersection.cpp new file mode 100644 index 000000000..bb2a2d382 --- /dev/null +++ b/src/boost/libs/hana/test/set/intersection.cpp @@ -0,0 +1,90 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(), + hana::make_set() + ), + hana::make_set() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}), + hana::make_set() + ), + hana::make_set() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(), + hana::make_set(ct_eq<0>{}) + ), + hana::make_set() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<1>{}) + ), + hana::make_set() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<0>{}) + ), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set(ct_eq<2>{}, ct_eq<3>{}) + ), + hana::make_set() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set(ct_eq<1>{}, ct_eq<2>{}) + ), + hana::make_set(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set(ct_eq<1>{}, ct_eq<0>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_set(ct_eq<1>{}, ct_eq<0>{}, ct_eq<4>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::intersection( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}), + hana::make_set(ct_eq<1>{}, ct_eq<0>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<4>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); +} diff --git a/src/boost/libs/hana/test/set/is_subset.cpp b/src/boost/libs/hana/test/set/is_subset.cpp new file mode 100644 index 000000000..7db106aac --- /dev/null +++ b/src/boost/libs/hana/test/set/is_subset.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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_set(), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::is_subset( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_subset( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<3>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + ))); +} diff --git a/src/boost/libs/hana/test/set/laws.cpp b/src/boost/libs/hana/test/set/laws.cpp new file mode 100644 index 000000000..0741ad782 --- /dev/null +++ b/src/boost/libs/hana/test/set/laws.cpp @@ -0,0 +1,33 @@ +// 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 +#include + +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto eqs = hana::make_tuple( + hana::make_set(), + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set(ct_eq<1>{}, ct_eq<0>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + ); + + auto keys = hana::make_tuple( + ct_eq<2>{}, + ct_eq<3>{} + ); + + hana::test::TestComparable{eqs}; + hana::test::TestSearchable{eqs, keys}; + hana::test::TestFoldable{eqs}; +} diff --git a/src/boost/libs/hana/test/set/make.cpp b/src/boost/libs/hana/test/set/make.cpp new file mode 100644 index 000000000..2ec86f7fa --- /dev/null +++ b/src/boost/libs/hana/test/set/make.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 +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(), + hana::make_set() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(ct_eq<0>{}), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); +} diff --git a/src/boost/libs/hana/test/set/symmetric_difference.cpp b/src/boost/libs/hana/test/set/symmetric_difference.cpp new file mode 100644 index 000000000..ac11ad2dd --- /dev/null +++ b/src/boost/libs/hana/test/set/symmetric_difference.cpp @@ -0,0 +1,67 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_set(), + hana::make_set() + ), + hana::make_set() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_set(ct_eq<0>{}), + hana::make_set() + ), + hana::make_set(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set() + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set() + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<1>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<1>{}, ct_eq<3>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::symmetric_difference( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), + hana::make_set(ct_eq<1>{}, ct_eq<3>{}, ct_eq<2>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<3>{}) + )); +} diff --git a/src/boost/libs/hana/test/set/to.cpp b/src/boost/libs/hana/test/set/to.cpp new file mode 100644 index 000000000..c2cc1a5de --- /dev/null +++ b/src/boost/libs/hana/test/set/to.cpp @@ -0,0 +1,84 @@ +// 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 +#include +#include +#include +#include +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto sequence = ::seq; + auto foldable = ::seq; + using S = ::Seq; + + // Set -> Sequence + { + auto check = [=](auto ...xs) { + BOOST_HANA_CONSTANT_CHECK(hana::contains( + hana::permutations(sequence(xs...)), + hana::to(hana::make_set(xs...)) + )); + }; + check(); + check(ct_eq<1>{}); + check(ct_eq<1>{}, ct_eq<2>{}); + check(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + check(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}); + } + + // Foldable -> Set + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable()), + hana::make_set() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable(ct_eq<1>{})), + hana::make_set(ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable(ct_eq<1>{}, ct_eq<1>{})), + hana::make_set(ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable(ct_eq<1>{}, ct_eq<2>{})), + hana::make_set(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable(ct_eq<1>{}, ct_eq<2>{}, ct_eq<1>{})), + hana::make_set(ct_eq<1>{}, ct_eq<2>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable(ct_eq<1>{}, ct_eq<2>{}, ct_eq<2>{})), + hana::make_set(ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{})), + hana::make_set(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(foldable(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{})), + hana::make_set(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + )); + } + + // to_set == to + { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to_set(foldable(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{})), + hana::to(foldable(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<2>{}, ct_eq<1>{})) + )); + } +} diff --git a/src/boost/libs/hana/test/set/union.cpp b/src/boost/libs/hana/test/set/union.cpp new file mode 100644 index 000000000..5316b1b28 --- /dev/null +++ b/src/boost/libs/hana/test/set/union.cpp @@ -0,0 +1,84 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(), + hana::make_set() + ), + hana::make_set() + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(ct_eq<0>{}), + hana::make_set() + ), + hana::make_set(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(), + hana::make_set(ct_eq<0>{}) + ), + hana::make_set(ct_eq<0>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<0>{}) + ), + hana::make_set(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<1>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(ct_eq<0>{}, ct_eq<1>{}), + hana::make_set(ct_eq<1>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(ct_eq<0>{}), + hana::make_set(ct_eq<1>{}, ct_eq<0>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(ct_eq<0>{}, ct_eq<2>{}), + hana::make_set(ct_eq<1>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::union_( + hana::make_set(ct_eq<0>{}, ct_eq<2>{}, ct_eq<5>{}), + hana::make_set(ct_eq<1>{}, ct_eq<3>{}, ct_eq<4>{}) + ), + hana::make_set(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + )); +} diff --git a/src/boost/libs/hana/test/set/unpack.cpp b/src/boost/libs/hana/test/set/unpack.cpp new file mode 100644 index 000000000..4412dd96b --- /dev/null +++ b/src/boost/libs/hana/test/set/unpack.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 +#include +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + hana::test::_injection<0> f{}; + + auto check = [=](auto ...xs) { + auto arg_perms = hana::permutations(hana::make_tuple(xs...)); + auto possible_results = hana::transform(arg_perms, [=](auto args) { + return hana::unpack(args, f); + }); + + BOOST_HANA_CONSTANT_CHECK(hana::contains( + possible_results, + hana::unpack(hana::make_set(xs...), f) + )); + }; + + check(); + check(ct_eq<1>{}); + check(ct_eq<1>{}, ct_eq<2>{}); + check(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}); + check(ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}); +} diff --git a/src/boost/libs/hana/test/string/any_of.cpp b/src/boost/libs/hana/test/string/any_of.cpp new file mode 100644 index 000000000..125a985d8 --- /dev/null +++ b/src/boost/libs/hana/test/string/any_of.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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::any_of( + BOOST_HANA_STRING("abcd"), + hana::equal.to(hana::char_c<'b'>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + BOOST_HANA_STRING(""), + hana::always(hana::true_c) + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::any_of( + BOOST_HANA_STRING("abcd"), + hana::equal.to(hana::char_c<'z'>) + ))); +} diff --git a/src/boost/libs/hana/test/string/at.cpp b/src/boost/libs/hana/test/string/at.cpp new file mode 100644 index 000000000..ea0c24231 --- /dev/null +++ b/src/boost/libs/hana/test/string/at.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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + BOOST_HANA_STRING("abcd")[hana::size_c<2>], + hana::char_c<'c'> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("a"), hana::size_c<0>), + hana::char_c<'a'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("ab"), hana::size_c<0>), + hana::char_c<'a'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("abc"), hana::size_c<0>), + hana::char_c<'a'> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("ab"), hana::size_c<1>), + hana::char_c<'b'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("abc"), hana::size_c<1>), + hana::char_c<'b'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("abcd"), hana::size_c<1>), + hana::char_c<'b'> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("abc"), hana::size_c<2>), + hana::char_c<'c'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::at(BOOST_HANA_STRING("abcd"), hana::size_c<2>), + hana::char_c<'c'> + )); +} diff --git a/src/boost/libs/hana/test/string/c_str.cpp b/src/boost/libs/hana/test/string/c_str.cpp new file mode 100644 index 000000000..b773fc207 --- /dev/null +++ b/src/boost/libs/hana/test/string/c_str.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 +#include + +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + BOOST_HANA_STRING("").c_str(), + "" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + BOOST_HANA_STRING("a").c_str(), + "a" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + BOOST_HANA_STRING("ab").c_str(), + "ab" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + BOOST_HANA_STRING("abc").c_str(), + "abc" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + BOOST_HANA_STRING("abcd").c_str(), + "abcd" + ) == 0); + + // make sure we can turn a non-constexpr hana::string + // into a constexpr char const* + { + auto str = BOOST_HANA_STRING("abcdef"); + constexpr char const* c_str = str.c_str(); + (void)c_str; + } + + // make sure c_str is actually a static member function + { + constexpr char const* c_str = hana::string<'f', 'o', 'o'>::c_str(); + (void)c_str; + } +} diff --git a/src/boost/libs/hana/test/string/cnstr.c_str.cpp b/src/boost/libs/hana/test/string/cnstr.c_str.cpp new file mode 100644 index 000000000..e118f04f2 --- /dev/null +++ b/src/boost/libs/hana/test/string/cnstr.c_str.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 +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +constexpr char const empty[] = ""; +constexpr char const a[] = "a"; +constexpr char const ab[] = "ab"; +constexpr char const abc[] = "abc"; +constexpr char const abcd[] = "abcd"; + +int main() { + { + auto string = hana::to(hana::integral_constant{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<>)); + } + + { + auto string = hana::to(hana::integral_constant{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a'>)); + } + + { + auto string = hana::to(hana::integral_constant{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b'>)); + } + + { + auto string = hana::to(hana::integral_constant{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c'>)); + } + + { + auto string = hana::to(hana::integral_constant{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c', 'd'>)); + } + + // Make sure it also works with std::integral_constant, for example + { + auto string = hana::to(std::integral_constant{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c', 'd'>)); + } + + // Make sure the `to_string` shortcut works + { + auto string = hana::to_string(hana::integral_constant{}); + BOOST_HANA_CONSTANT_CHECK(hana::equal(string, hana::string_c<'a', 'b', 'c', 'd'>)); + } +} diff --git a/src/boost/libs/hana/test/string/cnstr.copy.cpp b/src/boost/libs/hana/test/string/cnstr.copy.cpp new file mode 100644 index 000000000..08bda5b86 --- /dev/null +++ b/src/boost/libs/hana/test/string/cnstr.copy.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 +namespace hana = boost::hana; + + +int main() { + using Str = decltype(hana::string_c<'a', 'b', 'c', 'd'>); + Str s1{}; + Str s2(s1); + Str s3 = s1; + + (void)s2; (void)s3; +} diff --git a/src/boost/libs/hana/test/string/cnstr.default.cpp b/src/boost/libs/hana/test/string/cnstr.default.cpp new file mode 100644 index 000000000..b482e072e --- /dev/null +++ b/src/boost/libs/hana/test/string/cnstr.default.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 +namespace hana = boost::hana; + + +int main() { + using Str = decltype(hana::string_c<'a', 'b', 'c', 'd'>); + Str s{}; + (void)s; +} diff --git a/src/boost/libs/hana/test/string/contains.cpp b/src/boost/libs/hana/test/string/contains.cpp new file mode 100644 index 000000000..18ba68f91 --- /dev/null +++ b/src/boost/libs/hana/test/string/contains.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct invalid { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::contains( + BOOST_HANA_STRING("abcd"), + hana::char_c<'a'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::contains( + BOOST_HANA_STRING("abcd"), + hana::char_c<'c'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + BOOST_HANA_STRING("abcd"), + hana::char_c<'e'> + ))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::contains( + BOOST_HANA_STRING("abcd"), + invalid{} + ))); +} diff --git a/src/boost/libs/hana/test/string/drop_front_exactly.cpp b/src/boost/libs/hana/test/string/drop_front_exactly.cpp new file mode 100644 index 000000000..fbcebe8e1 --- /dev/null +++ b/src/boost/libs/hana/test/string/drop_front_exactly.cpp @@ -0,0 +1,44 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(BOOST_HANA_STRING("a")), + BOOST_HANA_STRING("") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(BOOST_HANA_STRING("ab")), + BOOST_HANA_STRING("b") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(BOOST_HANA_STRING("abc")), + BOOST_HANA_STRING("bc") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(BOOST_HANA_STRING("abcdefghijk")), + BOOST_HANA_STRING("bcdefghijk") + )); + + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(BOOST_HANA_STRING("abc"), hana::size_c<2>), + BOOST_HANA_STRING("c") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(BOOST_HANA_STRING("abcdefghijk"), hana::size_c<3>), + BOOST_HANA_STRING("defghijk") + )); +} diff --git a/src/boost/libs/hana/test/string/equal.cpp b/src/boost/libs/hana/test/string/equal.cpp new file mode 100644 index 000000000..0e4ea9d8e --- /dev/null +++ b/src/boost/libs/hana/test/string/equal.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +#include // for operator != +#include +namespace hana = boost::hana; + + +int main() { + // equal + BOOST_HANA_CONSTANT_CHECK(hana::equal( + BOOST_HANA_STRING("abcd"), + BOOST_HANA_STRING("abcd") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + BOOST_HANA_STRING("abcd"), + BOOST_HANA_STRING("abcde") + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + BOOST_HANA_STRING("abcd"), + BOOST_HANA_STRING("") + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("abcde") + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("") + )); + + // check operators + BOOST_HANA_CONSTANT_CHECK( + BOOST_HANA_STRING("abcd") + == + BOOST_HANA_STRING("abcd") + ); + + BOOST_HANA_CONSTANT_CHECK( + BOOST_HANA_STRING("abcd") + != + BOOST_HANA_STRING("abc") + ); +} diff --git a/src/boost/libs/hana/test/string/find.cpp b/src/boost/libs/hana/test/string/find.cpp new file mode 100644 index 000000000..b8148e5ec --- /dev/null +++ b/src/boost/libs/hana/test/string/find.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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct invalid { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(BOOST_HANA_STRING("abcd"), hana::char_c<'a'>), + hana::just(hana::char_c<'a'>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(BOOST_HANA_STRING("abcd"), hana::char_c<'c'>), + hana::just(hana::char_c<'c'>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find(BOOST_HANA_STRING("abcd"), invalid{}), + hana::nothing + )); +} diff --git a/src/boost/libs/hana/test/string/find_if.cpp b/src/boost/libs/hana/test/string/find_if.cpp new file mode 100644 index 000000000..05d5e98b9 --- /dev/null +++ b/src/boost/libs/hana/test/string/find_if.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 +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(BOOST_HANA_STRING(""), hana::always(hana::true_c)), + hana::nothing + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(BOOST_HANA_STRING("abcd"), hana::equal.to(hana::char_c<'a'>)), + hana::just(hana::char_c<'a'>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(BOOST_HANA_STRING("abcd"), hana::equal.to(hana::char_c<'c'>)), + hana::just(hana::char_c<'c'>) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::find_if(BOOST_HANA_STRING("abcd"), hana::equal.to(hana::char_c<'d'>)), + hana::just(hana::char_c<'d'>) + )); +} diff --git a/src/boost/libs/hana/test/string/front.cpp b/src/boost/libs/hana/test/string/front.cpp new file mode 100644 index 000000000..c8659663b --- /dev/null +++ b/src/boost/libs/hana/test/string/front.cpp @@ -0,0 +1,28 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(BOOST_HANA_STRING("a")), + hana::char_c<'a'> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(BOOST_HANA_STRING("ab")), + hana::char_c<'a'> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(BOOST_HANA_STRING("abc")), + hana::char_c<'a'> + )); +} diff --git a/src/boost/libs/hana/test/string/hash.cpp b/src/boost/libs/hana/test/string/hash.cpp new file mode 100644 index 000000000..c5995e169 --- /dev/null +++ b/src/boost/libs/hana/test/string/hash.cpp @@ -0,0 +1,33 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::hash(hana::string_c<>), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::hash(hana::string_c<'a'>), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::hash(hana::string_c<'a', 'b'>), + hana::type_c> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::hash(hana::string_c<'a', 'b', 'c'>), + hana::type_c> + )); +} diff --git a/src/boost/libs/hana/test/string/is_empty.cpp b/src/boost/libs/hana/test/string/is_empty.cpp new file mode 100644 index 000000000..ab49d5768 --- /dev/null +++ b/src/boost/libs/hana/test/string/is_empty.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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(BOOST_HANA_STRING(""))); + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::string_c<>)); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(BOOST_HANA_STRING("a")))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(BOOST_HANA_STRING("ab")))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(BOOST_HANA_STRING("abc")))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::string_c<'a'>))); +} diff --git a/src/boost/libs/hana/test/string/laws.cpp b/src/boost/libs/hana/test/string/laws.cpp new file mode 100644 index 000000000..201c3f007 --- /dev/null +++ b/src/boost/libs/hana/test/string/laws.cpp @@ -0,0 +1,95 @@ +// 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 +#include + +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + // Comparable and Hashable + { + auto strings = hana::make_tuple( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("a"), + BOOST_HANA_STRING("ab"), + BOOST_HANA_STRING("abc"), + BOOST_HANA_STRING("abcd"), + BOOST_HANA_STRING("abcde"), + BOOST_HANA_STRING("ba") + ); + + hana::test::TestComparable{strings}; + hana::test::TestHashable{strings}; + } + + // Monoid + { + auto strings = hana::make_tuple( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("a"), + BOOST_HANA_STRING("ab"), + BOOST_HANA_STRING("abc"), + BOOST_HANA_STRING("abcd"), + BOOST_HANA_STRING("abcde"), + BOOST_HANA_STRING("ba") + ); + + hana::test::TestMonoid{strings}; + } + + // Foldable and Iterable + { + auto strings = hana::make_tuple( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("a"), + BOOST_HANA_STRING("ab"), + BOOST_HANA_STRING("abc"), + BOOST_HANA_STRING("abcd"), + BOOST_HANA_STRING("abcde"), + BOOST_HANA_STRING("ba"), + BOOST_HANA_STRING("afcd") + ); + + hana::test::TestFoldable{strings}; + hana::test::TestIterable{strings}; + } + + // Orderable + { + auto strings = hana::make_tuple( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("a"), + BOOST_HANA_STRING("ab"), + BOOST_HANA_STRING("abc"), + BOOST_HANA_STRING("ba"), + BOOST_HANA_STRING("abd") + ); + + hana::test::TestOrderable{strings}; + } + + // Searchable + { + auto keys = hana::tuple_c; + auto strings = hana::make_tuple( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("a"), + BOOST_HANA_STRING("ab"), + BOOST_HANA_STRING("abcd"), + BOOST_HANA_STRING("ba"), + BOOST_HANA_STRING("afcd") + ); + + hana::test::TestSearchable{strings, keys}; + } +} diff --git a/src/boost/libs/hana/test/string/length.cpp b/src/boost/libs/hana/test/string/length.cpp new file mode 100644 index 000000000..02fd47183 --- /dev/null +++ b/src/boost/libs/hana/test/string/length.cpp @@ -0,0 +1,30 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(BOOST_HANA_STRING("")), + hana::size_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(BOOST_HANA_STRING("a")), + hana::size_c<1> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(BOOST_HANA_STRING("ab")), + hana::size_c<2> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::length(BOOST_HANA_STRING("abc")), + hana::size_c<3> + )); +} diff --git a/src/boost/libs/hana/test/string/less.cpp b/src/boost/libs/hana/test/string/less.cpp new file mode 100644 index 000000000..53ca1f1c8 --- /dev/null +++ b/src/boost/libs/hana/test/string/less.cpp @@ -0,0 +1,65 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("") + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + BOOST_HANA_STRING(""), + BOOST_HANA_STRING("a") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + BOOST_HANA_STRING("a"), + BOOST_HANA_STRING("") + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + BOOST_HANA_STRING("a"), + BOOST_HANA_STRING("ab") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::less( + BOOST_HANA_STRING("ab"), + BOOST_HANA_STRING("ab") + ))); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + BOOST_HANA_STRING("abc"), + BOOST_HANA_STRING("abcde") + )); + + BOOST_HANA_CONSTANT_CHECK(hana::less( + BOOST_HANA_STRING("abcde"), + BOOST_HANA_STRING("abfde") + )); + + // check operators + BOOST_HANA_CONSTANT_CHECK( + BOOST_HANA_STRING("abc") < BOOST_HANA_STRING("abcd") + ); + BOOST_HANA_CONSTANT_CHECK( + BOOST_HANA_STRING("abc") <= BOOST_HANA_STRING("abcd") + ); + BOOST_HANA_CONSTANT_CHECK( + BOOST_HANA_STRING("abcd") > BOOST_HANA_STRING("abc") + ); + BOOST_HANA_CONSTANT_CHECK( + BOOST_HANA_STRING("abcd") >= BOOST_HANA_STRING("abc") + ); +} diff --git a/src/boost/libs/hana/test/string/macro.cpp b/src/boost/libs/hana/test/string/macro.cpp new file mode 100644 index 000000000..d70e05150 --- /dev/null +++ b/src/boost/libs/hana/test/string/macro.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 +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // make sure string_c and BOOST_HANA_STRING give the same result + + { + auto const s1 = BOOST_HANA_STRING(""); + auto const s2 = hana::string_c<>; + static_assert(std::is_same::value, ""); + } + { + auto const s1 = BOOST_HANA_STRING("a"); + auto const s2 = hana::string_c<'a'>; + static_assert(std::is_same::value, ""); + } + { + auto const s1 = BOOST_HANA_STRING("abcd"); + auto const s2 = hana::string_c<'a', 'b', 'c', 'd'>; + static_assert(std::is_same::value, ""); + } +} diff --git a/src/boost/libs/hana/test/string/make.cpp b/src/boost/libs/hana/test/string/make.cpp new file mode 100644 index 000000000..03235eeea --- /dev/null +++ b/src/boost/libs/hana/test/string/make.cpp @@ -0,0 +1,39 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(), + hana::string_c<> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(hana::char_c<'a'>), + hana::string_c<'a'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(hana::char_c<'a'>, hana::char_c<'b'>), + hana::string_c<'a', 'b'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>), + hana::string_c<'a', 'b', 'c'> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>, hana::char_c<'d'>), + hana::string_c<'a', 'b', 'c', 'd'> + )); + + // make sure make_string == make + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_string(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>), + hana::make(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>) + )); +} diff --git a/src/boost/libs/hana/test/string/plus.cpp b/src/boost/libs/hana/test/string/plus.cpp new file mode 100644 index 000000000..d256a5553 --- /dev/null +++ b/src/boost/libs/hana/test/string/plus.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 +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::plus(BOOST_HANA_STRING(""), BOOST_HANA_STRING("")), + BOOST_HANA_STRING("") + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::plus(BOOST_HANA_STRING("abcd"), BOOST_HANA_STRING("")), + BOOST_HANA_STRING("abcd") + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::plus(BOOST_HANA_STRING(""), BOOST_HANA_STRING("abcd")), + BOOST_HANA_STRING("abcd") + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::plus(BOOST_HANA_STRING("abcd"), BOOST_HANA_STRING("efg")), + BOOST_HANA_STRING("abcdefg") + )); + + // check operator + BOOST_HANA_CONSTANT_CHECK(hana::equal( + BOOST_HANA_STRING("abc") + BOOST_HANA_STRING("def"), + BOOST_HANA_STRING("abcdef") + )); +} diff --git a/src/boost/libs/hana/test/string/to.cpp b/src/boost/libs/hana/test/string/to.cpp new file mode 100644 index 000000000..68c3e00e6 --- /dev/null +++ b/src/boost/libs/hana/test/string/to.cpp @@ -0,0 +1,47 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include + +#include +namespace hana = boost::hana; + + +static_assert(hana::is_convertible{}, ""); +static_assert(!hana::is_embedded{}, ""); + +int main() { + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + hana::to(BOOST_HANA_STRING("")), + "" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + hana::to(BOOST_HANA_STRING("a")), + "a" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + hana::to(BOOST_HANA_STRING("ab")), + "ab" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + hana::to(BOOST_HANA_STRING("abc")), + "abc" + ) == 0); + + BOOST_HANA_RUNTIME_CHECK(std::strcmp( + hana::to(BOOST_HANA_STRING("abcd")), + "abcd" + ) == 0); + + // make sure we can turn a non-constexpr hana::string + // into a constexpr char const* + auto str = BOOST_HANA_STRING("abcdef"); + constexpr char const* c_str = hana::to(str); + (void)c_str; +} diff --git a/src/boost/libs/hana/test/string/udl.cpp b/src/boost/libs/hana/test/string/udl.cpp new file mode 100644 index 000000000..899612b22 --- /dev/null +++ b/src/boost/libs/hana/test/string/udl.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 +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + // Check the _s user-defined literal +#ifdef BOOST_HANA_CONFIG_ENABLE_STRING_UDL + + using namespace hana::literals; + + constexpr auto s1 = "abcd"_s; + constexpr auto s2 = hana::string_c<'a', 'b', 'c', 'd'>; + + static_assert(std::is_same::value, ""); +#endif +} diff --git a/src/boost/libs/hana/test/string/unpack.cpp b/src/boost/libs/hana/test/string/unpack.cpp new file mode 100644 index 000000000..dea55db08 --- /dev/null +++ b/src/boost/libs/hana/test/string/unpack.cpp @@ -0,0 +1,42 @@ +// 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +int main() { + hana::test::_injection<0> f{}; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(BOOST_HANA_STRING(""), f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(BOOST_HANA_STRING("a"), f), + f(hana::char_c<'a'>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(BOOST_HANA_STRING("ab"), f), + f(hana::char_c<'a'>, hana::char_c<'b'>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(BOOST_HANA_STRING("abc"), f), + f(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(BOOST_HANA_STRING("abcd"), f), + f(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>, hana::char_c<'d'>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(BOOST_HANA_STRING("abcde"), f), + f(hana::char_c<'a'>, hana::char_c<'b'>, hana::char_c<'c'>, hana::char_c<'d'>, hana::char_c<'e'>) + )); +} diff --git a/src/boost/libs/hana/test/string/zero.cpp b/src/boost/libs/hana/test/string/zero.cpp new file mode 100644 index 000000000..6cae8c070 --- /dev/null +++ b/src/boost/libs/hana/test/string/zero.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 +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::zero(), + BOOST_HANA_STRING("") + )); +} diff --git a/src/boost/libs/hana/test/tuple/any_of.clang_ice.cpp b/src/boost/libs/hana/test/tuple/any_of.clang_ice.cpp new file mode 100644 index 000000000..4e23874c0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/any_of.clang_ice.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 +#include + +#include +namespace hana = boost::hana; + + +// This used to trigger an ICE on Clang + +struct Car { std::string name; }; + +int main() { + auto stuff = hana::make_tuple(Car{}, Car{}, Car{}); + hana::any_of(stuff, [](auto&&) { return true; }); +} diff --git a/src/boost/libs/hana/test/tuple/assign.convert_copy.cpp b/src/boost/libs/hana/test/tuple/assign.convert_copy.cpp new file mode 100644 index 000000000..b4debb7a6 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.convert_copy.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 +#include +namespace hana = boost::hana; + + +struct B { + int id_; + explicit B(int i = 0) : id_(i) { } +}; + +struct D : B { + explicit D(int i = 0) : B(i) { } +}; + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1; + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1; + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1; + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + D d2(2); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d2); + T1 t1(1.5, 'b', d); + t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } +} diff --git a/src/boost/libs/hana/test/tuple/assign.convert_move.cpp b/src/boost/libs/hana/test/tuple/assign.convert_move.cpp new file mode 100644 index 000000000..6a7a7943e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.convert_move.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 +#include + +#include +#include +namespace hana = boost::hana; + + +struct B { + int id_; + explicit B(int i = 0) : id_(i) {} + virtual ~B() {} +}; + +struct D : B { + explicit D(int i) : B(i) {} +}; + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + D d2(2); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d2); + T1 t1(1.5, 'b', d); + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } + { + using T0 = hana::tuple>; + using T1 = hana::tuple>; + T0 t0(2.5, 'a', std::unique_ptr(new D(3))); + T1 t1; + t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1)->id_ == 3); + } +} diff --git a/src/boost/libs/hana/test/tuple/assign.copy.cpp b/src/boost/libs/hana/test/tuple/assign.copy.cpp new file mode 100644 index 000000000..dedc276a5 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.copy.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 +#include + +#include +namespace hana = boost::hana; + + +int main() { + { + using T = hana::tuple<>; + T t0; + T t; + t = t0; + } + { + using T = hana::tuple; + T t0(2); + T t; + t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + using T = hana::tuple; + T t0(2, 'a'); + T t; + t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + } + { + using T = hana::tuple; + const T t0(2, 'a', "some text"); + T t; + t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "some text"); + } +} diff --git a/src/boost/libs/hana/test/tuple/assign.move.cpp b/src/boost/libs/hana/test/tuple/assign.move.cpp new file mode 100644 index 000000000..6dd776129 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/assign.move.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 +#include + +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + int get() const {return data_;} + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } + bool operator< (const MoveOnly& x) const { return data_ < x.data_; } +}; + +int main() { + { + using T = hana::tuple<>; + T t0; + T t; + t = std::move(t0); + } + { + using T = hana::tuple; + T t0(MoveOnly(0)); + T t; + t = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1)); + T t; + t = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2)); + T t; + t = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + } +} diff --git a/src/boost/libs/hana/test/tuple/at.const.cpp b/src/boost/libs/hana/test/tuple/at.const.cpp new file mode 100644 index 000000000..47d9b624c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/at.const.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 +#include + +#include +namespace hana = boost::hana; + + +struct Empty { }; + +int main() { + { + using T = hana::tuple; + const T t(3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 3); + } + { + using T = hana::tuple; + const T t("high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 5); + } + { + using T = hana::tuple; + constexpr T t(2.718, 5); + static_assert(hana::at_c<0>(t) == 2.718, ""); + static_assert(hana::at_c<1>(t) == 5, ""); + } + { + using T = hana::tuple; + constexpr T t{Empty()}; + constexpr Empty e = hana::at_c<0>(t); (void)e; + } + { + using T = hana::tuple; + double d = 1.5; + const T t(d, "high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5); + hana::at_c<0>(t) = 2.5; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5); + BOOST_HANA_RUNTIME_CHECK(d == 2.5); + } +} diff --git a/src/boost/libs/hana/test/tuple/at.non_const.cpp b/src/boost/libs/hana/test/tuple/at.non_const.cpp new file mode 100644 index 000000000..3e47c35d9 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/at.non_const.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 +#include + +#include +namespace hana = boost::hana; + + +struct Empty {}; + +struct S { + constexpr S() + : a{1, Empty{}}, + k(hana::at_c<0>(a)), + e(hana::at_c<1>(a)) + { } + + hana::tuple a; + int k; + Empty e; +}; + +constexpr hana::tuple getP () { return { 3, 4 }; } + +int main() { + { + using T = hana::tuple; + T t(3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 3); + hana::at_c<0>(t) = 2; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + using T = hana::tuple; + T t("high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 5); + hana::at_c<0>(t) = "four"; + hana::at_c<1>(t) = 4; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == "four"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 4); + } + { + using T = hana::tuple; + double d = 1.5; + T t(d, "high", 5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "high"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 5); + hana::at_c<0>(t) = 2.5; + hana::at_c<1>(t) = "four"; + hana::at_c<2>(t) = 4; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2.5); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == "four"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 4); + BOOST_HANA_RUNTIME_CHECK(d == 2.5); + } + // get on a rvalue tuple + { + static_assert(hana::at_c<0>(hana::tuple{0.0f, 1, 2.0, 3L}) == 0, "" ); + static_assert(hana::at_c<1>(hana::tuple{0.0f, 1, 2.0, 3L}) == 1, "" ); + static_assert(hana::at_c<2>(hana::tuple{0.0f, 1, 2.0, 3L}) == 2, "" ); + static_assert(hana::at_c<3>(hana::tuple{0.0f, 1, 2.0, 3L}) == 3, "" ); + static_assert(S().k == 1, ""); + static_assert(hana::at_c<1>(getP()) == 4, ""); + } + { + // make sure get<> returns the right types + struct T { }; + struct U { }; + struct V { }; + + hana::tuple xs{}; + (void)static_cast(hana::at_c<0>(xs)); + (void)static_cast(hana::at_c<1>(xs)); + (void)static_cast(hana::at_c<2>(xs)); + } +} diff --git a/src/boost/libs/hana/test/tuple/at.rv.cpp b/src/boost/libs/hana/test/tuple/at.rv.cpp new file mode 100644 index 000000000..e1591609b --- /dev/null +++ b/src/boost/libs/hana/test/tuple/at.rv.cpp @@ -0,0 +1,40 @@ +// 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 +#include + +#include + +#include +#include +namespace hana = boost::hana; + + +int main() { + { + using T = hana::tuple>; + T t(std::unique_ptr(new int(3))); + std::unique_ptr p = hana::at_c<0>(std::move(t)); + BOOST_HANA_RUNTIME_CHECK(*p == 3); + } + // make sure we don't double-move and do other weird stuff + { + hana::tuple xs{ + Tracked{1}, Tracked{2}, Tracked{3} + }; + + Tracked a = hana::at_c<0>(std::move(xs)); (void)a; + Tracked b = hana::at_c<1>(std::move(xs)); (void)b; + Tracked c = hana::at_c<2>(std::move(xs)); (void)c; + } + // test with nested closures + { + using Inner = hana::tuple; + hana::tuple xs{Inner{Tracked{1}, Tracked{2}}}; + + Tracked a = hana::at_c<0>(hana::at_c<0>(std::move(xs))); (void)a; + Tracked b = hana::at_c<1>(hana::at_c<0>(std::move(xs))); (void)b; + } +} diff --git a/src/boost/libs/hana/test/tuple/auto/_specs.hpp b/src/boost/libs/hana/test/tuple/auto/_specs.hpp new file mode 100644 index 000000000..0b957f4c8 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/_specs.hpp @@ -0,0 +1,15 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_HANA_TEST_TUPLE_AUTO_SPECS_HPP +#define BOOST_HANA_TEST_TUPLE_AUTO_SPECS_HPP + +#include + + +#define MAKE_TUPLE(...) ::boost::hana::make_tuple(__VA_ARGS__) +#define TUPLE_TYPE(...) ::boost::hana::tuple<__VA_ARGS__> +#define TUPLE_TAG ::boost::hana::tuple_tag + +#endif // !BOOST_HANA_TEST_TUPLE_AUTO_SPECS_HPP diff --git a/src/boost/libs/hana/test/tuple/auto/all_of.cpp b/src/boost/libs/hana/test/tuple/auto/all_of.cpp new file mode 100644 index 000000000..f3e974ffd --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/all_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/any_of.cpp b/src/boost/libs/hana/test/tuple/auto/any_of.cpp new file mode 100644 index 000000000..3065d0175 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/any_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/ap.cpp b/src/boost/libs/hana/test/tuple/auto/ap.cpp new file mode 100644 index 000000000..59c9cb757 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/ap.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/at.cpp b/src/boost/libs/hana/test/tuple/auto/at.cpp new file mode 100644 index 000000000..605265331 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp b/src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp new file mode 100644 index 000000000..b0795e8d7 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/cartesian_product.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/drop_back.cpp b/src/boost/libs/hana/test/tuple/auto/drop_back.cpp new file mode 100644 index 000000000..b283844d6 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/drop_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/drop_front.cpp b/src/boost/libs/hana/test/tuple/auto/drop_front.cpp new file mode 100644 index 000000000..a39d6f450 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/drop_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/drop_while.cpp b/src/boost/libs/hana/test/tuple/auto/drop_while.cpp new file mode 100644 index 000000000..18907f033 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/drop_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/for_each.cpp b/src/boost/libs/hana/test/tuple/auto/for_each.cpp new file mode 100644 index 000000000..714fe03c0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/for_each.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/group.cpp b/src/boost/libs/hana/test/tuple/auto/group.cpp new file mode 100644 index 000000000..0669b496f --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/group.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/index_if.cpp b/src/boost/libs/hana/test/tuple/auto/index_if.cpp new file mode 100644 index 000000000..ef37fe65a --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/index_if.cpp @@ -0,0 +1,9 @@ +// Copyright Louis Dionne 2013-2017 +// Copyright Jason Rice 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/insert.cpp b/src/boost/libs/hana/test/tuple/auto/insert.cpp new file mode 100644 index 000000000..e8efc6dc1 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/insert.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/insert_range.cpp b/src/boost/libs/hana/test/tuple/auto/insert_range.cpp new file mode 100644 index 000000000..05ac5774e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/insert_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/intersperse.cpp b/src/boost/libs/hana/test/tuple/auto/intersperse.cpp new file mode 100644 index 000000000..185c814a9 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/intersperse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/is_empty.cpp b/src/boost/libs/hana/test/tuple/auto/is_empty.cpp new file mode 100644 index 000000000..f175f7ddb --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/is_empty.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/length.cpp b/src/boost/libs/hana/test/tuple/auto/length.cpp new file mode 100644 index 000000000..55111dd60 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/length.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp b/src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp new file mode 100644 index 000000000..4d2f3edf4 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/lexicographical_compare.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/make.cpp b/src/boost/libs/hana/test/tuple/auto/make.cpp new file mode 100644 index 000000000..f90514f16 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/make.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/none_of.cpp b/src/boost/libs/hana/test/tuple/auto/none_of.cpp new file mode 100644 index 000000000..b56a27b47 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/none_of.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/partition.cpp b/src/boost/libs/hana/test/tuple/auto/partition.cpp new file mode 100644 index 000000000..ba9621a6c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/partition.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/permutations.cpp b/src/boost/libs/hana/test/tuple/auto/permutations.cpp new file mode 100644 index 000000000..3c1a6e852 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/permutations.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/remove_at.cpp b/src/boost/libs/hana/test/tuple/auto/remove_at.cpp new file mode 100644 index 000000000..5b7c5af47 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/remove_at.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/remove_range.cpp b/src/boost/libs/hana/test/tuple/auto/remove_range.cpp new file mode 100644 index 000000000..6d7c6e090 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/remove_range.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/reverse.cpp b/src/boost/libs/hana/test/tuple/auto/reverse.cpp new file mode 100644 index 000000000..342278df8 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/reverse.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/scans.cpp b/src/boost/libs/hana/test/tuple/auto/scans.cpp new file mode 100644 index 000000000..36dd32437 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/scans.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/sequence.cpp b/src/boost/libs/hana/test/tuple/auto/sequence.cpp new file mode 100644 index 000000000..4ed01e852 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/sequence.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/slice.cpp b/src/boost/libs/hana/test/tuple/auto/slice.cpp new file mode 100644 index 000000000..3e20df95f --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/slice.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/sort.cpp b/src/boost/libs/hana/test/tuple/auto/sort.cpp new file mode 100644 index 000000000..f639ddeb0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/sort.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/span.cpp b/src/boost/libs/hana/test/tuple/auto/span.cpp new file mode 100644 index 000000000..297b7f174 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/span.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/take_back.cpp b/src/boost/libs/hana/test/tuple/auto/take_back.cpp new file mode 100644 index 000000000..2a91d7d4d --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/take_back.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/take_front.cpp b/src/boost/libs/hana/test/tuple/auto/take_front.cpp new file mode 100644 index 000000000..9a48d2b8c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/take_front.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/take_while.cpp b/src/boost/libs/hana/test/tuple/auto/take_while.cpp new file mode 100644 index 000000000..e58c99aca --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/take_while.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/transform.cpp b/src/boost/libs/hana/test/tuple/auto/transform.cpp new file mode 100644 index 000000000..306c1bc3c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/transform.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/unfolds.cpp b/src/boost/libs/hana/test/tuple/auto/unfolds.cpp new file mode 100644 index 000000000..f8bac9ddc --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/unfolds.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/unique.cpp b/src/boost/libs/hana/test/tuple/auto/unique.cpp new file mode 100644 index 000000000..9c1dc7155 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/unique.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/auto/zips.cpp b/src/boost/libs/hana/test/tuple/auto/zips.cpp new file mode 100644 index 000000000..32ec5cc8a --- /dev/null +++ b/src/boost/libs/hana/test/tuple/auto/zips.cpp @@ -0,0 +1,8 @@ +// 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 "_specs.hpp" +#include + +int main() { } diff --git a/src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp b/src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp new file mode 100644 index 000000000..f8cb0d8de --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.convert_copy.cpp @@ -0,0 +1,93 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +namespace hana = boost::hana; + + +struct A { + int id_; + constexpr A(int i) : id_(i) {} + friend constexpr bool operator==(const A& x, const A& y) + { return x.id_ == y.id_; } +}; + +struct B { + int id_; + explicit B(int i) : id_(i) {} +}; + +struct C { + int id_; + constexpr explicit C(int i) : id_(i) {} + friend constexpr bool operator==(const C& x, const C& y) + { return x.id_ == y.id_; } +}; + +struct D : B { + explicit D(int i) : B(i) {} +}; + + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + constexpr T0 t0(2.5); + constexpr T1 t1 = t0; + static_assert(hana::at_c<0>(t1) == 2, ""); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + constexpr T0 t0(2); + constexpr T1 t1{t0}; + static_assert(hana::at_c<0>(t1) == C(2), ""); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1 = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d); + T1 t1 = t0; + d.id_ = 2; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', 3); + T1 t1(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.convert_move.cpp b/src/boost/libs/hana/test/tuple/cnstr.convert_move.cpp new file mode 100644 index 000000000..f8274429e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.convert_move.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 +#include + +#include +#include +namespace hana = boost::hana; + + +struct B { + int id_; + explicit B(int i) : id_(i) {} + virtual ~B() {} +}; + +struct D : B { + explicit D(int i) : B(i) {} +}; + +int main() { + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a'); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + } + { + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', D(3)); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 3); + } + { + D d(3); + using T0 = hana::tuple; + using T1 = hana::tuple; + T0 t0(2.5, 'a', d); + T1 t1 = std::move(t0); + d.id_ = 2; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1).id_ == 2); + } + { + using T0 = hana::tuple>; + using T1 = hana::tuple>; + T0 t0(2.5, 'a', std::unique_ptr(new D(3))); + T1 t1 = std::move(t0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t1) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t1) == int('a')); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t1)->id_ == 3); + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.copy.cpp b/src/boost/libs/hana/test/tuple/cnstr.copy.cpp new file mode 100644 index 000000000..e0d8638f0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.copy.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 +#include + +#include +namespace hana = boost::hana; + + +struct Empty { }; + +int main() { + { + using T = hana::tuple<>; + T t0; + T t_implicit = t0; + T t_explicit(t0); + + (void)t_explicit; + (void)t_implicit; + } + { + using T = hana::tuple; + T t0(2); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + using T = hana::tuple; + T t0(2, 'a'); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + } + { + using T = hana::tuple; + const T t0(2, 'a', "some text"); + T t = t0; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 'a'); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "some text"); + } + { + using T = hana::tuple; + constexpr T t0(2); + constexpr T t = t0; + static_assert(hana::at_c<0>(t) == 2, ""); + } + { + using T = hana::tuple; + constexpr T t0; + constexpr T t = t0; + constexpr Empty e = hana::at_c<0>(t); (void)e; + } + { + struct T { }; + struct U { }; + + constexpr hana::tuple binary{}; + constexpr hana::tuple copy_implicit = binary; + constexpr hana::tuple copy_explicit(binary); + + (void)copy_implicit; + (void)copy_explicit; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.default.cpp b/src/boost/libs/hana/test/tuple/cnstr.default.cpp new file mode 100644 index 000000000..5d9af67a2 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.default.cpp @@ -0,0 +1,138 @@ +// 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 +#include + +#include +#include +namespace hana = boost::hana; + + +struct DefaultOnly { + int data_; + DefaultOnly(DefaultOnly const&) = delete; + DefaultOnly& operator=(DefaultOnly const&) = delete; + + static int count; + + DefaultOnly() : data_(-1) { ++count; } + ~DefaultOnly() { data_ = 0; --count; } + + friend bool operator==(DefaultOnly const& x, DefaultOnly const& y) + { return x.data_ == y.data_; } + + friend bool operator< (DefaultOnly const& x, DefaultOnly const& y) + { return x.data_ < y.data_; } +}; + +int DefaultOnly::count = 0; + +struct NoDefault { + NoDefault() = delete; + explicit NoDefault(int) { } +}; + +struct IllFormedDefault { + IllFormedDefault(int x) : value(x) {} + template + constexpr IllFormedDefault() { + static_assert(Pred, + "The default constructor should not be instantiated"); + } + int value; +}; + +int main() { + { + hana::tuple<> t; (void)t; + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == ""); + } + { + hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == ""); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == DefaultOnly()); + } + { + // See LLVM bug #21157. + static_assert(!std::is_default_constructible< + hana::tuple + >(), ""); + static_assert(!std::is_default_constructible< + hana::tuple + >(), ""); + static_assert(!std::is_default_constructible< + hana::tuple + >(), ""); + } + { + struct T { }; + struct U { }; + struct V { }; + + constexpr hana::tuple<> z0; (void)z0; + constexpr hana::tuple z1; (void)z1; + constexpr hana::tuple z2; (void)z2; + constexpr hana::tuple z3; (void)z3; + } + { + constexpr hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + constexpr hana::tuple t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + } + + // Make sure we can hold non default-constructible elements, and that + // it does not trigger an error in the default constructor. + { + { + IllFormedDefault v(0); + hana::tuple t1(v); + hana::tuple t2{v}; + hana::tuple t3 = {v}; + (void)t1;(void)t2;(void)t3; // remove spurious unused variable warning on GCC + } + { + hana::tuple t1(0); + hana::tuple t2{0}; + hana::tuple t3 = {0}; + (void)t1;(void)t2;(void)t3; // remove spurious unused variable warning on GCC + } + { + NoDefault v(0); + hana::tuple t1(v); + hana::tuple t2{v}; + hana::tuple t3 = {v}; + (void)t1;(void)t2;(void)t3; // remove spurious unused variable warning on GCC + } + } + + // Make sure a tuple_t can be default-constructed + { + struct T; + struct U; + + using Types = decltype(hana::tuple_t); + Types t{}; (void)t; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.move.cpp b/src/boost/libs/hana/test/tuple/cnstr.move.cpp new file mode 100644 index 000000000..c9644cbad --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.move.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 +#include + +#include +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + int get() const {return data_;} + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } + bool operator< (const MoveOnly& x) const { return data_ < x.data_; } +}; + +int main() { + { + using T = hana::tuple<>; + T t0; + T t = std::move(t0); (void)t; + } + { + using T = hana::tuple; + T t0(MoveOnly(0)); + T t = std::move(t0); (void)t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1)); + T t = std::move(t0); (void)t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + } + { + using T = hana::tuple; + T t0(MoveOnly(0), MoveOnly(1), MoveOnly(2)); + T t = std::move(t0); (void)t; + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + } + { + // Check for SFINAE-friendliness + static_assert(!std::is_constructible< + hana::tuple, MoveOnly const& + >{}, ""); + + static_assert(!std::is_constructible< + hana::tuple, MoveOnly& + >{}, ""); + + static_assert(std::is_constructible< + hana::tuple, MoveOnly + >{}, ""); + + static_assert(std::is_constructible< + hana::tuple, MoveOnly&& + >{}, ""); + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.nested.cpp b/src/boost/libs/hana/test/tuple/cnstr.nested.cpp new file mode 100644 index 000000000..7cbdb5da6 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.nested.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 + +#include +namespace hana = boost::hana; + + +// See this bug: https://llvm.org/bugs/show_bug.cgi?id=24173 + +template +constexpr hana::tuple...> f(Xs&& ...xs) +{ return hana::tuple...>{static_cast(xs)...}; } + +int main() { + f(f(f(f(f(f(f(f(f(f(f(f(1)))))))))))); +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.trap.cpp b/src/boost/libs/hana/test/tuple/cnstr.trap.cpp new file mode 100644 index 000000000..a088b9466 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.trap.cpp @@ -0,0 +1,120 @@ +// 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 + +#include +namespace hana = boost::hana; + + +// Make sure that the tuple(Yn&&...) is not preferred over copy constructors +// in single-element cases and other similar cases. + +struct Trap1 { + Trap1() = default; + Trap1(Trap1 const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap1(Trap1&) = default; +#endif + Trap1(Trap1&&) = default; + + template + Trap1(X&&) { + static_assert(sizeof(X) && false, + "this constructor must not be instantiated"); + } +}; + +struct Trap2 { + Trap2() = default; + Trap2(Trap2 const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap2(Trap2&) = default; +#endif + Trap2(Trap2&&) = default; + + template + Trap2(X) { // not by reference + static_assert(sizeof(X) && false, + "this constructor must not be instantiated"); + } +}; + +struct Trap3 { + Trap3() = default; + Trap3(Trap3 const&) = default; +#ifndef BOOST_HANA_WORKAROUND_MSVC_MULTIPLECTOR_106654 + Trap3(Trap3&) = default; +#endif + Trap3(Trap3&&) = default; + + template + constexpr explicit Trap3(X&&) { // explicit, and constexpr + static_assert(sizeof(X) && false, + "this constructor must not be instantiated"); + } +}; + +struct Trap4 { + Trap4() = default; + template + constexpr explicit Trap4(Args&&) { + static_assert(sizeof(Args) && false, "must never be instantiated"); + } + + Trap4(Trap4 const&) = default; + Trap4(Trap4&&) = default; +}; + +int main() { + { + hana::tuple tuple{}; + hana::tuple implicit_copy = tuple; + hana::tuple explicit_copy(tuple); + hana::tuple implicit_move = std::move(tuple); + hana::tuple explicit_move(std::move(tuple)); + + (void)implicit_copy; + (void)explicit_copy; + (void)implicit_move; + (void)explicit_move; + } + + { + hana::tuple tuple{}; + hana::tuple implicit_copy = tuple; + hana::tuple explicit_copy(tuple); + hana::tuple implicit_move = std::move(tuple); + hana::tuple explicit_move(std::move(tuple)); + + (void)implicit_copy; + (void)explicit_copy; + (void)implicit_move; + (void)explicit_move; + } + + { + hana::tuple tuple{}; + hana::tuple implicit_copy = tuple; + hana::tuple explicit_copy(tuple); + hana::tuple implicit_move = std::move(tuple); + hana::tuple explicit_move(std::move(tuple)); + + (void)implicit_copy; + (void)explicit_copy; + (void)implicit_move; + (void)explicit_move; + } + + // Just defining the structure used to cause a failure, because of the + // explicitly defaulted copy-constructor. + { + struct Foo { + Foo() = default; + Foo(Foo const&) = default; + Foo(Foo&&) = default; + hana::tuple t; + }; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.variadic_array.cpp b/src/boost/libs/hana/test/tuple/cnstr.variadic_array.cpp new file mode 100644 index 000000000..02338b959 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.variadic_array.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 + +#include +namespace hana = boost::hana; + + +// +// This test checks that we can NOT construct a tuple holding array members, +// per the standard. +// + +int main() { + static_assert(!std::is_constructible, int[3]>{}, ""); + static_assert(!std::is_constructible, int[3], float[4]>{}, ""); +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp b/src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp new file mode 100644 index 000000000..44f9f4b8e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.variadic_copy.cpp @@ -0,0 +1,125 @@ +// 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 +#include + +#include +namespace hana = boost::hana; + + +template +struct never { static constexpr bool value = false; }; + +struct NoValueCtor { + NoValueCtor() : id(++count) {} + NoValueCtor(NoValueCtor const & other) : id(other.id) { ++count; } + + // The constexpr is required to make is_constructible instantiate this + // template. The explicit is needed to test-around a similar bug with + // is_convertible. + template + constexpr explicit NoValueCtor(T) + { static_assert(never::value, "This should not be instantiated"); } + + static int count; + int id; +}; + +int NoValueCtor::count = 0; + + +struct NoValueCtorEmpty { + NoValueCtorEmpty() {} + NoValueCtorEmpty(NoValueCtorEmpty const &) {} + + template + constexpr explicit NoValueCtorEmpty(T) + { static_assert(never::value, "This should not be instantiated"); } +}; + +int main() { + { + hana::tuple t(2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + } + { + constexpr hana::tuple t(2); + static_assert(hana::at_c<0>(t) == 2, ""); + } + { + constexpr hana::tuple t; + static_assert(hana::at_c<0>(t) == 0, ""); + } + { + constexpr hana::tuple t(2, nullptr); + static_assert(hana::at_c<0>(t) == 2, ""); + static_assert(hana::at_c<1>(t) == nullptr, ""); + } + { + hana::tuple t(2, nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + } + { + hana::tuple t(2, nullptr, "text"); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == nullptr); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == "text"); + } + { + hana::tuple t(1, NoValueCtor(), 2, 3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t).id == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == 3); + } + { + hana::tuple t(1, NoValueCtorEmpty(), 2, 3); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<3>(t) == 3); + } + { + struct T { }; + struct U { }; + struct V { }; + + constexpr T t{}; + constexpr U u{}; + constexpr V v{}; + + constexpr hana::tuple x1{t}; (void)x1; + constexpr hana::tuple x2{t, u}; (void)x2; + constexpr hana::tuple x3{t, u, v}; (void)x3; + } + { + struct T { }; + struct U { }; + struct V { }; + + // Check for SFINAE-friendliness + static_assert(!std::is_constructible< + hana::tuple, T + >{}, ""); + + static_assert(!std::is_constructible< + hana::tuple, U, T + >{}, ""); + + static_assert(!std::is_constructible< + hana::tuple, T, U, V + >{}, ""); + } + + // Make sure we can initialize elements with the brace-init syntax. + { + struct Member { }; + struct Element { Member member; }; + + hana::tuple xs{{Member()}, {Member()}}; + hana::tuple ys = {{Member()}, {Member()}}; + (void)xs; (void)ys; + } +} diff --git a/src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp b/src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp new file mode 100644 index 000000000..dc69ba738 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/cnstr.variadic_forward.cpp @@ -0,0 +1,114 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include + +#include +namespace hana = boost::hana; + + +struct MoveOnly { + int data_; + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; + MoveOnly(int data = 1) : data_(data) { } + MoveOnly(MoveOnly&& x) : data_(x.data_) { x.data_ = 0; } + + MoveOnly& operator=(MoveOnly&& x) + { data_ = x.data_; x.data_ = 0; return *this; } + + int get() const {return data_;} + bool operator==(const MoveOnly& x) const { return data_ == x.data_; } + bool operator< (const MoveOnly& x) const { return data_ < x.data_; } +}; + +struct Empty { }; +struct A { + int id_; + explicit constexpr A(int i) : id_(i) {} +}; + +struct NoDefault { NoDefault() = delete; }; + +int main() { + { + hana::tuple t(MoveOnly(0)); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + } + { + hana::tuple t(MoveOnly(0), MoveOnly(1)); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + } + { + hana::tuple t( + MoveOnly(0), MoveOnly(1), MoveOnly(2) + ); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<0>(t) == 0); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<1>(t) == 1); + BOOST_HANA_RUNTIME_CHECK(hana::at_c<2>(t) == 2); + } + { + constexpr hana::tuple t0{Empty()}; (void)t0; + } + { + constexpr hana::tuple t(3, 2); + static_assert(hana::at_c<0>(t).id_ == 3, ""); + } + { + typedef hana::tuple Tuple; + + static_assert(!std::is_constructible< + Tuple, + MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + Tuple, + MoveOnly, NoDefault + >::value, ""); + } + { + typedef hana::tuple Tuple; + + static_assert(!std::is_constructible< + Tuple, + MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + Tuple, + MoveOnly, MoveOnly, NoDefault + >::value, ""); + } + { + typedef hana::tuple Tuple; + typedef hana::tuple NestedTuple; + + static_assert(!std::is_constructible< + NestedTuple, + MoveOnly, MoveOnly, MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + NestedTuple, + MoveOnly, Tuple, MoveOnly, MoveOnly + >::value, ""); + } + { + typedef hana::tuple Tuple; + typedef hana::tuple NestedTuple; + + static_assert(!std::is_constructible< + NestedTuple, + MoveOnly, MoveOnly, MoveOnly, MoveOnly + >::value, ""); + + static_assert(std::is_constructible< + NestedTuple, + MoveOnly, Tuple, MoveOnly, MoveOnly + >::value, ""); + } +} diff --git a/src/boost/libs/hana/test/tuple/empty_member.cpp b/src/boost/libs/hana/test/tuple/empty_member.cpp new file mode 100644 index 000000000..1bab83185 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/empty_member.cpp @@ -0,0 +1,33 @@ +// 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 +namespace hana = boost::hana; + + +struct A { }; +struct B { }; + +int main() { + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } + { + using T = hana::tuple; + static_assert(sizeof(T) == sizeof(int), ""); + } +} diff --git a/src/boost/libs/hana/test/tuple/hold_refs.cpp b/src/boost/libs/hana/test/tuple/hold_refs.cpp new file mode 100644 index 000000000..fb900194e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/hold_refs.cpp @@ -0,0 +1,78 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include + +#include +namespace hana = boost::hana; + + +// a non-movable, non-copyable type +struct RefOnly { + RefOnly() = default; + RefOnly(RefOnly const&) = delete; + RefOnly(RefOnly&&) = delete; +}; + +struct Empty { }; + +int main() { + // Make sure we can create a tuple of rvalue references + { + RefOnly e{}; + hana::tuple xs{std::move(e)}; + hana::tuple ys{std::move(e), std::move(e)}; + (void)xs; (void)ys; + + hana::tuple xs2 = {std::move(e)}; + hana::tuple ys2 = {std::move(e), std::move(e)}; + (void)xs2; (void)ys2; + } + + // Make sure we can create a tuple of non-const lvalue references + { + RefOnly e{}; + hana::tuple xs{e}; + hana::tuple ys{e, e}; + (void)xs; (void)ys; + + hana::tuple xs2 = {e}; + hana::tuple ys2 = {e, e}; + (void)xs2; (void)ys2; + } + + // Make sure we can create a tuple of const lvalue references + { + RefOnly const e{}; + hana::tuple xs{e}; + hana::tuple ys{e, e}; + (void)xs; (void)ys; + + hana::tuple xs2 = {e}; + hana::tuple ys2 = {e, e}; + (void)xs2; (void)ys2; + } + + // Try to construct tuples with mixed references and non-reference members. + { + RefOnly r{}; + Empty e{}; + + { + hana::tuple xs{r, e}; + hana::tuple ys = {r, e}; + (void)xs; (void)ys; + } + { + hana::tuple xs{r, e}; + hana::tuple ys = {r, e}; + (void)xs; (void)ys; + } + { + hana::tuple xs{std::move(r), e}; + hana::tuple ys = {std::move(r), e}; + (void)xs; (void)ys; + } + } +} diff --git a/src/boost/libs/hana/test/tuple/issue_90.cpp b/src/boost/libs/hana/test/tuple/issue_90.cpp new file mode 100644 index 000000000..ab78440d0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/issue_90.cpp @@ -0,0 +1,72 @@ +// 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 +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +template +T const& cref(T& t) { return t; } + +// a non-movable, non-copyable type +struct RefOnly { + RefOnly() = default; + RefOnly(RefOnly const&) = delete; + RefOnly(RefOnly&&) = delete; +}; + +template +struct RefOnly_i : hana::int_ { + RefOnly_i() = default; + RefOnly_i(RefOnly_i const&) = delete; + RefOnly_i(RefOnly_i&&) = delete; +}; + +int main() { + hana::tuple t; + + // Make sure that we return the proper reference types from `at`. + { + RefOnly&& r1 = hana::at_c<0>(std::move(t)); + RefOnly& r2 = hana::at_c<0>(t); + RefOnly const& r3 = hana::at_c<0>(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `front`. + { + RefOnly&& r1 = hana::front(std::move(t)); + RefOnly& r2 = hana::front(t); + RefOnly const& r3 = hana::front(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `back`. + { + RefOnly&& r1 = hana::back(std::move(t)); + RefOnly& r2 = hana::back(t); + RefOnly const& r3 = hana::back(cref(t)); + + (void)r1; (void)r2; (void)r3; + } + + // Make sure we return the proper reference types from `at_key`. + { + hana::tuple> t{}; + RefOnly_i<3>& r1 = hana::at_key(t, RefOnly_i<3>{}); + RefOnly_i<3> const& r2 = hana::at_key(cref(t), RefOnly_i<3>{}); + RefOnly_i<3>&& r3 = hana::at_key(std::move(t), RefOnly_i<3>{}); + + (void)r1; (void)r2; (void)r3; + } +} diff --git a/src/boost/libs/hana/test/tuple/laws.cpp b/src/boost/libs/hana/test/tuple/laws.cpp new file mode 100644 index 000000000..fc79fe9af --- /dev/null +++ b/src/boost/libs/hana/test/tuple/laws.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 + +#include +#include +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; +using hana::test::ct_ord; + + +int main() { + auto eq_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_eq<0>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + ); + + auto ord_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_ord<0>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}) + , hana::make_tuple(ct_ord<0>{}, ct_ord<1>{}, ct_ord<2>{}, ct_ord<3>{}, ct_ord<4>{}) + ); + + hana::test::TestComparable{eq_tuples}; + hana::test::TestOrderable{ord_tuples}; + hana::test::TestFoldable{eq_tuples}; + hana::test::TestIterable{eq_tuples}; + hana::test::TestSequence{}; +} diff --git a/src/boost/libs/hana/test/tuple/laws.functor.cpp b/src/boost/libs/hana/test/tuple/laws.functor.cpp new file mode 100644 index 000000000..7a72d2d56 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/laws.functor.cpp @@ -0,0 +1,64 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto eq_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_eq<0>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}, ct_eq<5>{}) + ); + + auto eq_values = hana::make_tuple( + ct_eq<0>{}, + ct_eq<2>{}, + ct_eq<4>{} + ); + + auto predicates = hana::make_tuple( + hana::equal.to(ct_eq<0>{}), + hana::equal.to(ct_eq<2>{}), + hana::equal.to(ct_eq<4>{}), + hana::always(hana::true_c), + hana::always(hana::false_c) + ); + + auto nested_eqs = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple( + hana::make_tuple(ct_eq<0>{}) + ) + , hana::make_tuple( + hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}) + ) + , hana::make_tuple( + hana::make_tuple(ct_eq<0>{}), + hana::make_tuple(ct_eq<1>{}, ct_eq<2>{}), + hana::make_tuple(ct_eq<3>{}, ct_eq<4>{}) + ) + ); + + hana::test::TestFunctor{eq_tuples, eq_values}; + hana::test::TestApplicative{eq_tuples}; + hana::test::TestMonad{eq_tuples, nested_eqs}; + hana::test::TestMonadPlus{eq_tuples, predicates, eq_values}; +} diff --git a/src/boost/libs/hana/test/tuple/laws.searchable.cpp b/src/boost/libs/hana/test/tuple/laws.searchable.cpp new file mode 100644 index 000000000..6aa096899 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/laws.searchable.cpp @@ -0,0 +1,40 @@ +// 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 +#include + +#include +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +int main() { + auto eq_tuples = hana::make_tuple( + hana::make_tuple() + , hana::make_tuple(ct_eq<0>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}) + , hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}, ct_eq<3>{}, ct_eq<4>{}) + ); + hana::test::TestSearchable{ + eq_tuples, + hana::make_tuple(ct_eq<3>{}, ct_eq<5>{}) + }; + + auto bool_tuples = hana::make_tuple( + hana::make_tuple(hana::true_c) + , hana::make_tuple(hana::false_c) + , hana::make_tuple(hana::true_c, hana::true_c) + , hana::make_tuple(hana::true_c, hana::false_c) + , hana::make_tuple(hana::false_c, hana::true_c) + , hana::make_tuple(hana::false_c, hana::false_c) + ); + hana::test::TestSearchable{ + bool_tuples, + hana::make_tuple(hana::true_c, hana::false_c) + }; +} diff --git a/src/boost/libs/hana/test/tuple/move_only.cpp b/src/boost/libs/hana/test/tuple/move_only.cpp new file mode 100644 index 000000000..3f78316cc --- /dev/null +++ b/src/boost/libs/hana/test/tuple/move_only.cpp @@ -0,0 +1,55 @@ +// 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 +#include +#include +#include + +#include +namespace hana = boost::hana; + + +// This test checks for move-only friendliness and reference semantics. + +struct MoveOnly { + MoveOnly() = default; + MoveOnly(MoveOnly&&) = default; + MoveOnly& operator=(MoveOnly&&) = default; + + MoveOnly(MoveOnly const&) = delete; + MoveOnly& operator=(MoveOnly const&) = delete; +}; + +int main() { + { + auto xs = hana::make_tuple(MoveOnly{}); + auto by_val = [](auto) { }; + + by_val(std::move(xs)); + by_val(hana::front(std::move(xs))); + by_val(hana::at_c<0>(std::move(xs))); + by_val(hana::back(std::move(xs))); + } + + { + auto const& xs = hana::make_tuple(MoveOnly{}); + auto by_const_ref = [](auto const&) { }; + + by_const_ref(xs); + by_const_ref(hana::front(xs)); + by_const_ref(hana::at_c<0>(xs)); + by_const_ref(hana::back(xs)); + } + + { + auto xs = hana::make_tuple(MoveOnly{}); + auto by_ref = [](auto&) { }; + + by_ref(xs); + by_ref(hana::front(xs)); + by_ref(hana::at_c<0>(xs)); + by_ref(hana::back(xs)); + } +} diff --git a/src/boost/libs/hana/test/tuple/pair_interop.cpp b/src/boost/libs/hana/test/tuple/pair_interop.cpp new file mode 100644 index 000000000..1e079f437 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/pair_interop.cpp @@ -0,0 +1,75 @@ +// Copyright Louis Dionne 2013-2016 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +// This test makes sure that tuples containing pairs behave properly. It is +// useful to test this specific case because tuple and pair (may) share a lot +// of implementation details (for EBO), and that can easily lead to subtle bugs. +// For example, if both pair and tuple inherit from similar base classes for +// EBO, accessing a tuple of pairs or a pair of tuples (which requires some +// base class casting magic) can lead to ambiguous overloads. + +int main() { + struct empty1 { }; + struct empty2 { }; + + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + { + hana::tuple> t{}; + hana::first(hana::at_c<0>(t)); + hana::second(hana::at_c<0>(t)); + } + + { + hana::pair, hana::tuple<>> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } + { + hana::pair, hana::tuple> p{}; + hana::first(p); + hana::second(p); + } +} diff --git a/src/boost/libs/hana/test/tuple/smart_ptr.cpp b/src/boost/libs/hana/test/tuple/smart_ptr.cpp new file mode 100644 index 000000000..aea7dc857 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/smart_ptr.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 + +#include +namespace hana = boost::hana; + + +// Tuples of smart pointers; based on LLVM bug #18350 +int main() { + { + hana::tuple> up; + hana::tuple> sp; + hana::tuple> wp; + } + { + hana::tuple> up; + hana::tuple> sp; + hana::tuple> wp; + } +} diff --git a/src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp b/src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp new file mode 100644 index 000000000..1092c5216 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.drop_front_exactly.cpp @@ -0,0 +1,46 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_t), + hana::tuple_t<> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_t), + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_t), + hana::tuple_t + )); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_c), + hana::tuple_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_c), + hana::tuple_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::drop_front_exactly(hana::tuple_c), + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.empty.cpp b/src/boost/libs/hana/test/tuple/special.empty.cpp new file mode 100644 index 000000000..2cbb36d31 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.empty.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 +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::empty(), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::empty(), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::empty(), + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.equal.cpp b/src/boost/libs/hana/test/tuple/special.equal.cpp new file mode 100644 index 000000000..27694f2bc --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.equal.cpp @@ -0,0 +1,76 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t<>, + hana::tuple_t<> + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t, + hana::tuple_t<>) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t<>, + hana::tuple_t) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t, + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t, + hana::tuple_t) + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_t, + hana::tuple_t) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t, + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_t, + hana::tuple_t + )); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_c, + hana::tuple_c + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal( + hana::tuple_c, + hana::tuple_c + ))); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::tuple_c, + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.fill.cpp b/src/boost/libs/hana/test/tuple/special.fill.cpp new file mode 100644 index 000000000..d764083fb --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.fill.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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct x1; +struct x2; +struct x3; +struct z; + +int main() { + // fill a tuple_t with a hana::type + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t<>, hana::type_c), + hana::tuple_t<> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t, hana::type_c), + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t, hana::type_c), + hana::tuple_t + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fill(hana::tuple_t, hana::type_c), + hana::tuple_t + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.fold_left.cpp b/src/boost/libs/hana/test/tuple/special.fold_left.cpp new file mode 100644 index 000000000..cf121ebb8 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.fold_left.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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct F { struct type; }; + +struct x0; +struct x1; +struct x2; +struct x3; + +int main() { + // tuple_t and initial state + { + auto f = hana::metafunction; + auto s = hana::type_c; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t<>, s, f), + s + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(s, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(f(s, hana::type_c), hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(f(f(s, hana::type_c), hana::type_c), hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, s, f), + f(f(f(f(s, hana::type_c), hana::type_c), hana::type_c), hana::type_c) + )); + } + + // tuple_t and no initial state + { + auto f = hana::metafunction; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + f(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + f(f(hana::type_c, hana::type_c), hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_left(hana::tuple_t, f), + f(f(f(hana::type_c, hana::type_c), hana::type_c), hana::type_c) + )); + } +} diff --git a/src/boost/libs/hana/test/tuple/special.fold_right.cpp b/src/boost/libs/hana/test/tuple/special.fold_right.cpp new file mode 100644 index 000000000..a78d40ed3 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.fold_right.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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct F { struct type; }; + +struct x0; +struct x1; +struct x2; +struct x3; + +int main() { + // tuple_t and an initial state + { + auto f = hana::metafunction; + auto s = hana::type_c; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t<>, s, f), + s + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, s) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, f(hana::type_c, s)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, f(hana::type_c, f(hana::type_c, s))) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, s, f), + f(hana::type_c, f(hana::type_c, f(hana::type_c, f(hana::type_c, s)))) + )); + } + + // tuple_t and no initial state + { + auto f = hana::metafunction; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + f(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + f(hana::type_c, f(hana::type_c, hana::type_c)) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::fold_right(hana::tuple_t, f), + f(hana::type_c, f(hana::type_c, f(hana::type_c, hana::type_c))) + )); + } +} diff --git a/src/boost/libs/hana/test/tuple/special.front.cpp b/src/boost/libs/hana/test/tuple/special.front.cpp new file mode 100644 index 000000000..9dc712d5c --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.front.cpp @@ -0,0 +1,46 @@ +// 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 +#include +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_t), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_t), + hana::type_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_t), + hana::type_c + )); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_c), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_c), + hana::int_c<0> + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::front(hana::tuple_c), + hana::int_c<0> + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.is_empty.cpp b/src/boost/libs/hana/test/tuple/special.is_empty.cpp new file mode 100644 index 000000000..3bf0cf780 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.is_empty.cpp @@ -0,0 +1,28 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + + +struct x0; +struct x1; +struct x2; + +int main() { + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::tuple_t<>)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_t))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_t))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_t))); + + // tuple_c + BOOST_HANA_CONSTANT_CHECK(hana::is_empty(hana::tuple_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_c))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_c))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_empty(hana::tuple_c))); +} diff --git a/src/boost/libs/hana/test/tuple/special.prepend.cpp b/src/boost/libs/hana/test/tuple/special.prepend.cpp new file mode 100644 index 000000000..267f7dd4e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.prepend.cpp @@ -0,0 +1,30 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::long_c<0>), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::uint_c<0>), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::llong_c<0>), + hana::tuple_c + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::prepend(hana::tuple_c, hana::ulong_c<0>), + hana::tuple_c + )); +} diff --git a/src/boost/libs/hana/test/tuple/special.transform.cpp b/src/boost/libs/hana/test/tuple/special.transform.cpp new file mode 100644 index 000000000..86d141c6e --- /dev/null +++ b/src/boost/libs/hana/test/tuple/special.transform.cpp @@ -0,0 +1,52 @@ +// 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 +#include +#include +#include +#include +namespace hana = boost::hana; + + +template +struct F { struct type; }; + +struct x1; +struct x2; +struct x3; +struct x4; + +int main() { + // transform with tuple_t and a metafunction + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t<>, hana::metafunction), + hana::tuple_t<> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type, F::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type, F::type, F::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::metafunction), + hana::tuple_t::type, F::type, F::type, F::type> + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::transform(hana::tuple_t, hana::template_), + hana::tuple_t, F, F, F> + )); +} diff --git a/src/boost/libs/hana/test/tuple/to.cpp b/src/boost/libs/hana/test/tuple/to.cpp new file mode 100644 index 000000000..d0862c3c2 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/to.cpp @@ -0,0 +1,18 @@ +// 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 +#include +#include +#include +namespace hana = boost::hana; + + +int main() { + // make sure to_tuple == to + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::to(hana::tuple_t), + hana::to_tuple(hana::tuple_t) + )); +} diff --git a/src/boost/libs/hana/test/tuple/unpack.cpp b/src/boost/libs/hana/test/tuple/unpack.cpp new file mode 100644 index 000000000..3838ea299 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/unpack.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; +using hana::test::ct_eq; + + +template +struct F { struct type; }; + +struct x0; +struct x1; +struct x2; +struct x3; + +int main() { + hana::test::_injection<0> f{}; + + // tuple + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(), f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(ct_eq<0>{}), f), + f(ct_eq<0>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}), f), + f(ct_eq<0>{}, ct_eq<1>{}) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::make_tuple(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}), f), + f(ct_eq<0>{}, ct_eq<1>{}, ct_eq<2>{}) + )); + + // tuple_t + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t<>, f), + f() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c, hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, f), + f(hana::type_c, hana::type_c, hana::type_c, hana::type_c) + )); + + // tuple_t with metafunction + auto g = hana::metafunction; + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t<>, g), + g() + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c, hana::type_c, hana::type_c) + )); + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::unpack(hana::tuple_t, g), + g(hana::type_c, hana::type_c, hana::type_c, hana::type_c) + )); +} diff --git a/src/boost/libs/hana/test/tuple/usability_of_types.cpp b/src/boost/libs/hana/test/tuple/usability_of_types.cpp new file mode 100644 index 000000000..261b47ad0 --- /dev/null +++ b/src/boost/libs/hana/test/tuple/usability_of_types.cpp @@ -0,0 +1,41 @@ +// 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 +#include +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +// The fact that a reference to a `type<...>` is returned from `front(types)` +// and friends used to break the `decltype(front(types))::type` pattern, +// because we would be trying to fetch `::type` inside a reference. To work +// around this, a unary `operator+` turning a lvalue `type` into a rvalue +// `type` was added. + +struct T; struct U; struct V; + +int main() { + auto check = [](auto types) { + static_assert(std::is_same< + typename decltype(+hana::front(types))::type, T + >{}, ""); + + static_assert(std::is_same< + typename decltype(+hana::at(types, hana::size_c<1>))::type, U + >{}, ""); + + static_assert(std::is_same< + typename decltype(+hana::back(types))::type, V + >{}, ""); + }; + + check(hana::make_tuple(hana::type_c, hana::type_c, hana::type_c)); + check(hana::tuple_t); +} diff --git a/src/boost/libs/hana/test/type/adl.cpp b/src/boost/libs/hana/test/type/adl.cpp new file mode 100644 index 000000000..35a75c20c --- /dev/null +++ b/src/boost/libs/hana/test/type/adl.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 +namespace hana = boost::hana; + + +template +struct invalid { static_assert(b, "invalid must not be instantiated"); }; + +template void adl(T) { } +template void adl_pattern(hana::basic_type) { } + + +int main() { + // ADL kicks in but `invalid<>` must not instantiated + adl(hana::type_c>); + adl_pattern(hana::type_c>); + + // ADL instantiates the types recursively, make sure that works too + adl(hana::typeid_(hana::type_c>)); + adl_pattern(hana::typeid_(hana::type_c>)); +} diff --git a/src/boost/libs/hana/test/type/alignof.cpp b/src/boost/libs/hana/test/type/alignof.cpp new file mode 100644 index 000000000..6b8203b21 --- /dev/null +++ b/src/boost/libs/hana/test/type/alignof.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct T { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::alignof_(T{}), + hana::size_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::alignof_(hana::type_c), + hana::size_c + )); + + // make sure we don't read from non-constexpr variables + { + auto t = hana::type_c; + auto x = 1; + constexpr auto r1 = hana::alignof_(t); (void)r1; + constexpr auto r2 = hana::alignof_(x); (void)r2; + } +} diff --git a/src/boost/libs/hana/test/type/decltype.cpp b/src/boost/libs/hana/test/type/decltype.cpp new file mode 100644 index 000000000..b956c324e --- /dev/null +++ b/src/boost/libs/hana/test/type/decltype.cpp @@ -0,0 +1,182 @@ +// 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 +#include +#include +namespace hana = boost::hana; + + +using Function = void(); +void function() { } + +int main() { + { + struct T { }; + T t; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(T{}), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(t), + hana::type_c + )); + } + + // [cv-qualified] reference types + { + struct T { }; + T t; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + } + + // [cv-qualified] rvalue reference types + { + struct T { }; + T t; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(static_cast(t)), + hana::type_c + )); + } + + // decltype_(type_c) is the identity function + { + struct T; + auto const type_const = hana::type_c; + auto const& type_const_ref = hana::type_c; + auto& type_ref = hana::type_c; + auto&& type_ref_ref = static_cast(type_ref); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(hana::type_c), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(type_const), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(type_const_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(type_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(type_ref_ref), + hana::type_c + )); + } + + // make sure we don't read from non-constexpr variables + { + struct T; + auto t = hana::type_c; + auto x = 1; + constexpr auto r1 = hana::decltype_(t); (void)r1; + constexpr auto r2 = hana::decltype_(x); (void)r2; + } + + // decltype_ with builtin arrays, function pointers and other weirdos + { + struct T { }; + using A = T[3]; + A a; + A& a_ref = a; + A const& a_const_ref = a; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(a), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(a_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(a_const_ref), + hana::type_c + )); + } + { + using Fptr = int(*)(); + Fptr f; + Fptr& f_ref = f; + Fptr const& f_const_ref = f; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(f), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(f_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(f_const_ref), + hana::type_c + )); + } + { + Function& function_ref = function; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(function), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::decltype_(function_ref), + hana::type_c + )); + } +} diff --git a/src/boost/libs/hana/test/type/equal.cpp b/src/boost/libs/hana/test/type/equal.cpp new file mode 100644 index 000000000..4d5a18a84 --- /dev/null +++ b/src/boost/libs/hana/test/type/equal.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 +#include +#include +#include // for operator != +#include +namespace hana = boost::hana; + + +struct T; +struct U; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c, hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c, hana::type_c))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c, hana::type_c))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c, hana::type_c))); + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c, hana::type_c)); + + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c, hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c, hana::type_c))); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::equal(hana::type_c, hana::type_c))); + BOOST_HANA_CONSTANT_CHECK(hana::equal(hana::type_c, hana::type_c)); + + // make sure we don't read from a non-constexpr variable in hana::equal + auto t = hana::type_c; + static_assert(hana::equal(t, hana::type_c), ""); + + // check operators + BOOST_HANA_CONSTANT_CHECK(hana::type_c == hana::type_c); + BOOST_HANA_CONSTANT_CHECK(hana::type_c != hana::type_c); +} diff --git a/src/boost/libs/hana/test/type/hash.cpp b/src/boost/libs/hana/test/type/hash.cpp new file mode 100644 index 000000000..88bcf3352 --- /dev/null +++ b/src/boost/libs/hana/test/type/hash.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 +#include +#include +#include +namespace hana = boost::hana; + + +struct T; + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::hash(hana::type_c), + hana::type_c +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::hash(hana::basic_type{}), + hana::type_c +)); + +int main() { } diff --git a/src/boost/libs/hana/test/type/inherit_basic_type.cpp b/src/boost/libs/hana/test/type/inherit_basic_type.cpp new file mode 100644 index 000000000..e42e82801 --- /dev/null +++ b/src/boost/libs/hana/test/type/inherit_basic_type.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 + +#include +namespace hana = boost::hana; + + +// `hana::type` should inherit `hana::basic_type`. + +struct T; +static_assert(std::is_base_of, decltype(hana::type_c)>{}, ""); +static_assert(std::is_base_of, hana::type>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/type/integral.cpp b/src/boost/libs/hana/test/type/integral.cpp new file mode 100644 index 000000000..e3159bbc3 --- /dev/null +++ b/src/boost/libs/hana/test/type/integral.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct x1; struct x2; struct x3; +struct y1 { }; struct y2 { }; struct y3 { }; + +template struct mf { struct type { }; }; +struct mfc { template struct apply { struct type { }; }; }; +template struct tpl { }; + +// make sure `integral(f)(...)` returns the right type +static_assert(std::is_same< + decltype(hana::integral(hana::metafunction)()), + mf<>::type +>{}, ""); +static_assert(std::is_same< + decltype(hana::integral(hana::metafunction)(hana::type_c)), + mf::type +>{}, ""); +static_assert(std::is_same< + decltype(hana::integral(hana::metafunction)(hana::type_c, hana::type_c)), + mf::type +>{}, ""); + +static_assert(std::is_same< + decltype(hana::integral(hana::template_)()), + tpl<> +>{}, ""); +static_assert(std::is_same< + decltype(hana::integral(hana::template_)(hana::type_c)), + tpl +>{}, ""); +static_assert(std::is_same< + decltype(hana::integral(hana::template_)(hana::type_c, hana::type_c)), + tpl +>{}, ""); + +static_assert(std::is_same< + decltype(hana::integral(hana::metafunction_class)()), + mfc::apply<>::type +>{}, ""); +static_assert(std::is_same< + decltype(hana::integral(hana::metafunction_class)(hana::type_c)), + mfc::apply::type +>{}, ""); +static_assert(std::is_same< + decltype(hana::integral(hana::metafunction_class)(hana::type_c, hana::type_c)), + mfc::apply::type +>{}, ""); + +// Make sure integral is SFINAE-friendly +struct invalid_hana_metafunction { + template struct apply { /* missing type alias */ }; +}; +auto invalid_integral = hana::integral(invalid_hana_metafunction{}); +BOOST_HANA_CONSTANT_CHECK(hana::not_( + hana::is_valid(invalid_integral)(hana::type_c, hana::type_c) +)); + + +int main() { + // Make sure we can perform the call; we already made sure the return type was correct + constexpr auto a = hana::integral(hana::metafunction)(); (void)a; + constexpr auto b = hana::integral(hana::metafunction)(hana::type_c); (void)b; + constexpr auto c = hana::integral(hana::metafunction)(hana::type_c, hana::type_c); (void)c; + constexpr auto d = hana::integral(hana::metafunction)(hana::type_c, hana::type_c, hana::type_c); (void)d; + + // Make sure we don't read from a non-constexpr variable + auto t = hana::type_c; + constexpr auto r = hana::integral(hana::metafunction)(t); + (void)r; +} diff --git a/src/boost/libs/hana/test/type/is_valid.cpp b/src/boost/libs/hana/test/type/is_valid.cpp new file mode 100644 index 000000000..2f2abcd35 --- /dev/null +++ b/src/boost/libs/hana/test/type/is_valid.cpp @@ -0,0 +1,206 @@ +// 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 +#include +#include +#include +#include + +#include + +#include +namespace hana = boost::hana; + + +struct undefined { }; + +struct static_nested_member { static const int member = 1; }; +struct static_nested_member_array { static int member[3]; }; +struct nested_template_struct { template struct nested; }; +struct nested_template_alias { template using nested = void; }; + +int main() { + // Check for a non-static member + { + struct yes { int member; }; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype( + hana::traits::declval(t).member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype( + t.member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + + // Check for a non-static member function + { + struct yes { int member() const; }; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype( + hana::traits::declval(t).member() + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype( + t.member() + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + + // Check for a static member + { + using yes = static_nested_member; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype( + decltype(t)::type::member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype( + std::remove_reference_t::member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + + // Check for a nested type + { + struct yes { using nested = void; }; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype(hana::type_c< + typename decltype(t)::type::nested + >) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype(hana::type_c< + typename std::remove_reference_t::nested + >) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + + // Check for a nested template + { + { // template struct + using yes = nested_template_struct; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype(hana::template_< + decltype(t)::type::template nested + >) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype(hana::template_< + std::remove_reference_t::template nested + >) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + + { // template alias + using yes = nested_template_alias; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype(hana::template_< + decltype(t)::type::template nested + >) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype(hana::template_< + std::remove_reference_t::template nested + >) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + } + + // Make sure that checking for a nested static or non-static member + // works even when the type of that member is an array type or + // something that can't be returned from a function. + { + { // non-static member + struct yes { int member[3]; }; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype( + (void)hana::traits::declval(t).member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype( + (void)t.member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + + { // static member + using yes = static_nested_member_array; + struct no { }; + + auto from_type = hana::is_valid([](auto t) -> decltype( + (void)decltype(t)::type::member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_type(hana::type_c)); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_type(hana::type_c))); + + auto from_object = hana::is_valid([](auto&& t) -> decltype( + (void)std::remove_reference_t::member + ) { }); + BOOST_HANA_CONSTANT_CHECK(from_object(yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(from_object(no{}))); + } + } + + // Make sure the result of a `is_valid` function is constexpr + // even when called on non-constexpr arguments. + { + int i; + auto f = hana::is_valid([](auto) { }); + constexpr auto result = f(i); + (void)result; + } + + // Make sure `is_valid` works with non-PODs. + { + hana::is_valid(undefined{})(Tracked{1}); + hana::is_valid([t = Tracked{1}](auto) { return 1; })(Tracked{1}); + } + + // Check `is_valid` with a nullary function. + { + auto f = [](auto ...x) { (void)sizeof...(x); /* -Wunused-param */ }; + auto g = [](auto ...x) -> char(*)[sizeof...(x)] { }; + BOOST_HANA_CONSTANT_CHECK(hana::is_valid(f)()); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_valid(g)())); + } + + // Call `is_valid` in the non-curried form. + { + struct yes { int member; }; + struct no { }; + + auto f = [](auto&& t) -> decltype(t.member) { }; + + BOOST_HANA_CONSTANT_CHECK(hana::is_valid(f, yes{})); + BOOST_HANA_CONSTANT_CHECK(hana::not_(hana::is_valid(f, no{}))); + } +} diff --git a/src/boost/libs/hana/test/type/laws.cpp b/src/boost/libs/hana/test/type/laws.cpp new file mode 100644 index 000000000..622840f9b --- /dev/null +++ b/src/boost/libs/hana/test/type/laws.cpp @@ -0,0 +1,28 @@ +// 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 +#include + +#include +#include +namespace hana = boost::hana; + + +struct T; + +int main() { + auto types = hana::make_tuple( + hana::type_c, + hana::type_c, + hana::type_c, + hana::type_c, + hana::type_c, + hana::type_c, + hana::type_c + ); + + hana::test::TestComparable{types}; + hana::test::TestHashable{types}; +} diff --git a/src/boost/libs/hana/test/type/make.cpp b/src/boost/libs/hana/test/type/make.cpp new file mode 100644 index 000000000..68a6a9839 --- /dev/null +++ b/src/boost/libs/hana/test/type/make.cpp @@ -0,0 +1,41 @@ +// 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 +#include +#include +namespace hana = boost::hana; + + +struct T { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(T{}), + hana::decltype_(T{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make(hana::type_c), + hana::decltype_(hana::type_c) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_type(T{}), + hana::make(T{}) + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::make_type(hana::type_c), + hana::make(hana::type_c) + )); + + // make sure we don't read from non-constexpr variables + { + auto t = hana::type_c; + auto x = 1; + constexpr auto r1 = hana::make(t); (void)r1; + constexpr auto r2 = hana::make(x); (void)r2; + } +} diff --git a/src/boost/libs/hana/test/type/metafunction.cpp b/src/boost/libs/hana/test/type/metafunction.cpp new file mode 100644 index 000000000..aa52c1f38 --- /dev/null +++ b/src/boost/libs/hana/test/type/metafunction.cpp @@ -0,0 +1,72 @@ +// 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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct x1; struct x2; struct x3; +struct y1 { }; struct y2 { }; struct y3 { }; +template struct f { struct type; }; + +template +constexpr auto valid_call(F f, T ...t) -> decltype(((void)f(t...)), true) +{ return true; } +constexpr auto valid_call(...) +{ return false; } + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction(), + hana::type_c::type> +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction(hana::type_c), + hana::type_c::type> +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction(hana::type_c, hana::type_c), + hana::type_c::type> +)); + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction(hana::type_c, hana::type_c, hana::type_c), + hana::type_c::type> +)); + +using F = decltype(hana::metafunction); +static_assert(std::is_same, f<>>::value, ""); +static_assert(std::is_same, f>::value, ""); +static_assert(std::is_same, f>::value, ""); +static_assert(std::is_same, f>::value, ""); + +// Make sure we're SFINAE-friendly +template struct no_type { }; +static_assert(!valid_call(hana::metafunction), ""); +static_assert(!valid_call(hana::metafunction, hana::type_c), ""); + +// Make sure we model the Metafunction concept +static_assert(hana::Metafunction)>::value, ""); +static_assert(hana::Metafunction)&>::value, ""); + +// Make sure metafunction is SFINAE-friendly +template struct not_a_metafunction { }; +BOOST_HANA_CONSTANT_CHECK(hana::not_( + hana::is_valid(hana::metafunction)(hana::type_c) +)); + + +// Make sure we don't read from a non-constexpr variable +int main() { + auto t = hana::type_c; + constexpr auto r = hana::metafunction(t); + (void)r; +} diff --git a/src/boost/libs/hana/test/type/metafunction_class.cpp b/src/boost/libs/hana/test/type/metafunction_class.cpp new file mode 100644 index 000000000..b0123708b --- /dev/null +++ b/src/boost/libs/hana/test/type/metafunction_class.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct x1; struct x2; struct x3; +struct y1 { }; struct y2 { }; struct y3 { }; +struct f { template struct apply { struct type; }; }; + +template +constexpr auto valid_call(F f, T ...t) -> decltype(((void)f(t...)), true) +{ return true; } +constexpr auto valid_call(...) +{ return false; } + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction_class(), + hana::type_c::type> +)); +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction_class(hana::type_c), + hana::type_c::type> +)); +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction_class(hana::type_c, hana::type_c), + hana::type_c::type> +)); +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::metafunction_class(hana::type_c, hana::type_c, hana::type_c), + hana::type_c::type> +)); + +using F = decltype(hana::metafunction_class); +static_assert(std::is_same, f::apply<>>{}, ""); +static_assert(std::is_same, f::apply>{}, ""); +static_assert(std::is_same, f::apply>{}, ""); +static_assert(std::is_same, f::apply>{}, ""); + +// Make sure we're SFINAE-friendly +struct no_type { template struct apply { }; }; +static_assert(!valid_call(hana::metafunction_class), ""); +static_assert(!valid_call(hana::metafunction_class, hana::type_c), ""); + +// Make sure we model the Metafunction concept +static_assert(hana::Metafunction)>::value, ""); +static_assert(hana::Metafunction)&>::value, ""); + +// Make sure metafunction_class is SFINAE-friendly +struct not_a_mfc1 { template struct apply { }; }; +struct not_a_mfc2 { }; +BOOST_HANA_CONSTANT_CHECK(hana::not_( + hana::is_valid(hana::metafunction_class)(hana::type_c) +)); +BOOST_HANA_CONSTANT_CHECK(hana::not_( + hana::is_valid(hana::metafunction_class)(hana::type_c) +)); + + +// Make sure we don't read from a non-constexpr variable +int main() { + auto t = hana::type_c; + constexpr auto r = hana::metafunction_class(t); + (void)r; +} diff --git a/src/boost/libs/hana/test/type/nested_type.cpp b/src/boost/libs/hana/test/type/nested_type.cpp new file mode 100644 index 000000000..6e0410dff --- /dev/null +++ b/src/boost/libs/hana/test/type/nested_type.cpp @@ -0,0 +1,18 @@ +// 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 + +#include +namespace hana = boost::hana; + + +// Makes sure that `hana::type`s have a nested ::type alias + +struct T; + +static_assert(std::is_same)::type, T>{}, ""); +static_assert(std::is_same::type, T>{}, ""); + +int main() { } diff --git a/src/boost/libs/hana/test/type/sizeof.cpp b/src/boost/libs/hana/test/type/sizeof.cpp new file mode 100644 index 000000000..85110d295 --- /dev/null +++ b/src/boost/libs/hana/test/type/sizeof.cpp @@ -0,0 +1,32 @@ +// Copyright Louis Dionne 2013-2017 +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include +namespace hana = boost::hana; + + +struct T { }; + +int main() { + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sizeof_(T{}), + hana::size_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::sizeof_(hana::type_c), + hana::size_c + )); + + // make sure we don't read from non-constexpr variables + { + auto t = hana::type_c; + auto x = 1; + constexpr auto r1 = hana::sizeof_(t); (void)r1; + constexpr auto r2 = hana::sizeof_(x); (void)r2; + } +} diff --git a/src/boost/libs/hana/test/type/template.cpp b/src/boost/libs/hana/test/type/template.cpp new file mode 100644 index 000000000..6b35d35e7 --- /dev/null +++ b/src/boost/libs/hana/test/type/template.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 +#include +#include +#include +#include + +#include +namespace hana = boost::hana; + + +struct x1; struct x2; struct x3; +struct y1 { }; struct y2 { }; struct y3 { }; +template struct f; + +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::template_(), + hana::type_c> +)); +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::template_(hana::type_c), + hana::type_c> +)); +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::template_(hana::type_c, hana::type_c), + hana::type_c> +)); +BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::template_(hana::type_c, hana::type_c, hana::type_c), + hana::type_c> +)); + +using F = decltype(hana::template_); +static_assert(std::is_same::type, f<>>{}, ""); +static_assert(std::is_same::type, f>{}, ""); +static_assert(std::is_same::type, f>{}, ""); +static_assert(std::is_same::type, f>{}, ""); + +// Make sure we model the Metafunction concept +static_assert(hana::Metafunction)>::value, ""); +static_assert(hana::Metafunction)&>::value, ""); + +// Make sure we can use aliases +template using alias = T; +static_assert(hana::template_(hana::type_c) == hana::type_c, ""); + +// Make sure template_ is SFINAE-friendly +template struct unary; +BOOST_HANA_CONSTANT_CHECK(hana::not_( + hana::is_valid(hana::template_)(hana::type_c, hana::type_c) +)); + +// Make sure we don't read from a non-constexpr variable +int main() { + auto t = hana::type_c; + constexpr auto r = hana::template_(t); + (void)r; +} diff --git a/src/boost/libs/hana/test/type/traits.cpp b/src/boost/libs/hana/test/type/traits.cpp new file mode 100644 index 000000000..dd2e3d7e0 --- /dev/null +++ b/src/boost/libs/hana/test/type/traits.cpp @@ -0,0 +1,154 @@ +// 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 + +#include +#include +#include +namespace hana = boost::hana; + + +enum Enumeration { }; +struct Structure { }; +constexpr auto e = hana::type_c; +constexpr auto s = hana::type_c; + +int main() { + // We just make sure that they compile. If the forwarding to `std::` is + // well done, it is the job of `std::` to return the right thing. + + /////////////////////// + // Type properties + /////////////////////// + // Primary type categories + static_assert(!hana::traits::is_void(s), "the traits should be compile-time checkable"); + hana::traits::is_null_pointer(s); + hana::traits::is_integral(s); + hana::traits::is_floating_point(s); + hana::traits::is_array(s); + hana::traits::is_enum(s); + hana::traits::is_union(s); + hana::traits::is_class(s); + hana::traits::is_function(s); + hana::traits::is_pointer(s); + hana::traits::is_lvalue_reference(s); + hana::traits::is_rvalue_reference(s); + hana::traits::is_member_object_pointer(s); + hana::traits::is_member_function_pointer(s); + + // Composite type categories + hana::traits::is_fundamental(s); + hana::traits::is_arithmetic(s); + hana::traits::is_scalar(s); + hana::traits::is_object(s); + hana::traits::is_compound(s); + hana::traits::is_reference(s); + hana::traits::is_member_pointer(s); + + // Type properties + hana::traits::is_const(s); + hana::traits::is_volatile(s); + hana::traits::is_trivial(s); + hana::traits::is_trivially_copyable(s); + hana::traits::is_standard_layout(s); + hana::traits::is_pod(s); + hana::traits::is_literal_type(s); + hana::traits::is_empty(s); + hana::traits::is_polymorphic(s); + hana::traits::is_abstract(s); + hana::traits::is_signed(s); + hana::traits::is_unsigned(s); + + // Supported operations + hana::traits::is_constructible(s, s); + hana::traits::is_trivially_constructible(s, s); + hana::traits::is_nothrow_constructible(s, s); + + hana::traits::is_default_constructible(s); + hana::traits::is_trivially_default_constructible(s); + hana::traits::is_nothrow_default_constructible(s); + + hana::traits::is_copy_constructible(s); + hana::traits::is_trivially_copy_constructible(s); + hana::traits::is_nothrow_copy_constructible(s); + + hana::traits::is_move_constructible(s); + hana::traits::is_trivially_move_constructible(s); + hana::traits::is_nothrow_move_constructible(s); + + hana::traits::is_assignable(s, s); + hana::traits::is_trivially_assignable(s, s); + hana::traits::is_nothrow_assignable(s, s); + + hana::traits::is_copy_assignable(s); + hana::traits::is_trivially_copy_assignable(s); + hana::traits::is_nothrow_copy_assignable(s); + + hana::traits::is_move_assignable(s); + hana::traits::is_trivially_move_assignable(s); + hana::traits::is_nothrow_move_assignable(s); + + hana::traits::is_destructible(s); + hana::traits::is_trivially_destructible(s); + hana::traits::is_nothrow_destructible(s); + + hana::traits::has_virtual_destructor(s); + + // Property queries + hana::traits::alignment_of(s); + hana::traits::rank(s); + hana::traits::extent(s); + hana::traits::extent(hana::type_c, hana::uint_c<1>); + + // Type relationships + hana::traits::is_same(s, s); + hana::traits::is_base_of(s, s); + hana::traits::is_convertible(s, s); + + /////////////////////// + // Type modifications + /////////////////////// + // Const-volatility specifiers + hana::traits::remove_cv(s); + hana::traits::remove_const(s); + hana::traits::remove_volatile(s); + + hana::traits::add_cv(s); + hana::traits::add_const(s); + hana::traits::add_volatile(s); + + // References + hana::traits::remove_reference(s); + hana::traits::add_lvalue_reference(s); + hana::traits::add_rvalue_reference(s); + + // Pointers + hana::traits::remove_pointer(s); + hana::traits::add_pointer(s); + + // Sign modifiers + hana::traits::make_signed(hana::type_c); + hana::traits::make_unsigned(hana::type_c); + + // Arrays + hana::traits::remove_extent(s); + hana::traits::remove_all_extents(s); + + // Miscellaneous transformations + hana::traits::aligned_storage(hana::size_c<1>); + hana::traits::aligned_storage(hana::size_c<1>, hana::size_c<1>); + hana::traits::aligned_union(hana::size_c<0>, s); + hana::traits::decay(s); + + hana::traits::common_type(s, s); + hana::traits::underlying_type(e); + using FunctionPointer = void(*)(); + hana::traits::result_of(hana::type_c); + + /////////////////////// + // Utilities + /////////////////////// + using Z = decltype(hana::traits::declval(hana::type_c)); +} diff --git a/src/boost/libs/hana/test/type/typeid.cpp b/src/boost/libs/hana/test/type/typeid.cpp new file mode 100644 index 000000000..44b7c3a49 --- /dev/null +++ b/src/boost/libs/hana/test/type/typeid.cpp @@ -0,0 +1,182 @@ +// 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 +#include +#include +namespace hana = boost::hana; + + +using Function = void(); +void function() { } + +int main() { + { + struct T { }; + T t; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(T{}), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(t), + hana::type_c + )); + } + + // [cv-qualified] reference types + { + struct T { }; + T t; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + } + + // [cv-qualified] rvalue reference types + { + struct T { }; + T t; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(static_cast(t)), + hana::type_c + )); + } + + // typeid_(type_c) is the identity function + { + struct T; + auto const type_const = hana::type_c; + auto const& type_const_ref = hana::type_c; + auto& type_ref = hana::type_c; + auto&& type_ref_ref = static_cast(type_ref); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(hana::type_c), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(type_const), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(type_const_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(type_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(type_ref_ref), + hana::type_c + )); + } + + // make sure we don't read from non-constexpr variables + { + struct T; + auto t = hana::type_c; + auto x = 1; + constexpr auto r1 = hana::typeid_(t); (void)r1; + constexpr auto r2 = hana::typeid_(x); (void)r2; + } + + // typeid_ with builtin arrays, function pointers and other weirdos + { + struct T { }; + using A = T[3]; + A a; + A& a_ref = a; + A const& a_const_ref = a; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(a), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(a_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(a_const_ref), + hana::type_c + )); + } + { + using Fptr = int(*)(); + Fptr f; + Fptr& f_ref = f; + Fptr const& f_const_ref = f; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(f), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(f_ref), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(f_const_ref), + hana::type_c + )); + } + { + Function& function_ref = function; + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(function), + hana::type_c + )); + + BOOST_HANA_CONSTANT_CHECK(hana::equal( + hana::typeid_(function_ref), + hana::type_c + )); + } +} diff --git a/src/boost/libs/hana/test/type/unary_plus.cpp b/src/boost/libs/hana/test/type/unary_plus.cpp new file mode 100644 index 000000000..b9aa8feba --- /dev/null +++ b/src/boost/libs/hana/test/type/unary_plus.cpp @@ -0,0 +1,39 @@ +// 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 +#include +#include + +#include +namespace hana = boost::hana; + + +// This test checks that the unary + operator on types works as expected. +// The unary + operator is supposed to turn a reference to a hana::type +// object into an equivalent prvalue. + +struct T; + +int main() { + auto& ref = hana::type_c; + auto const& cref = hana::type_c; + auto&& rref = hana::type_c; + auto val = hana::type_c; + + BOOST_HANA_CONSTANT_CHECK(hana::equal(val, +val)); + BOOST_HANA_CONSTANT_CHECK(hana::equal(val, +ref)); + BOOST_HANA_CONSTANT_CHECK(hana::equal(val, +cref)); + BOOST_HANA_CONSTANT_CHECK(hana::equal(val, +rref)); + + static_assert(!std::is_reference{}, ""); + static_assert(!std::is_reference{}, ""); + static_assert(!std::is_reference{}, ""); + static_assert(!std::is_reference{}, ""); + + using T1 = decltype(+val)::type; + using T2 = decltype(+ref)::type; + using T3 = decltype(+cref)::type; + using T4 = decltype(+rref)::type; +} -- cgit v1.2.3