summaryrefslogtreecommitdiff
path: root/test/std/utilities/function.objects
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-16 16:03:23 +0000
commit0dc0969cd0a732760f0aa79942a04e0eaef297c4 (patch)
tree051bdb57b1ac6ee143f61ddbb47bd0da619f6f0c /test/std/utilities/function.objects
parent868847c6900e575417c03bced6e562b3af891318 (diff)
Notes
Diffstat (limited to 'test/std/utilities/function.objects')
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp9
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp4
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp4
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp2
-rw-r--r--test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp23
-rw-r--r--test/std/utilities/function.objects/unord.hash/enum.pass.cpp4
-rw-r--r--test/std/utilities/function.objects/unord.hash/floating.pass.cpp3
-rw-r--r--test/std/utilities/function.objects/unord.hash/integral.pass.cpp54
-rw-r--r--test/std/utilities/function.objects/unord.hash/pointer.pass.cpp16
17 files changed, 94 insertions, 41 deletions
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp
index 5e347c4c5715..943e162172b0 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/PR23141_invoke_not_constexpr.pass.cpp
@@ -16,7 +16,7 @@
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
-// https://llvm.org/bugs/show_bug.cgi?id=23141
+// https://bugs.llvm.org/show_bug.cgi?id=23141
#include <functional>
#include <type_traits>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
index ad03e8fb6bb2..a4d502bb800e 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp
@@ -16,7 +16,7 @@
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
-// http://llvm.org/bugs/show_bug.cgi?id=16385
+// https://bugs.llvm.org/show_bug.cgi?id=16385
#include <functional>
#include <cmath>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
index 180433109f26..a9a38b83cb4e 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp
@@ -16,7 +16,7 @@
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
-// http://llvm.org/bugs/show_bug.cgi?id=22003
+// https://bugs.llvm.org/show_bug.cgi?id=22003
#include <functional>
diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
index 0d4244b4d860..5b660da617a8 100644
--- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
+++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
@@ -16,7 +16,7 @@
// template<Returnable R, CopyConstructible Fn, CopyConstructible... Types>
// unspecified bind(Fn, Types...);
-// http://llvm.org/bugs/show_bug.cgi?id=16343
+// https://bugs.llvm.org/show_bug.cgi?id=16343
#include <cmath>
#include <functional>
diff --git a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
index 47a3e1cc5969..2b19211be9bf 100644
--- a/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
+++ b/test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
@@ -414,7 +414,14 @@ void throws_in_constructor_test()
throw 42;
}
ThrowsOnCopy() = default;
- bool operator()() const { assert(false); }
+ bool operator()() const {
+ assert(false);
+#if defined(_LIBCPP_MSVC)
+ __assume(0);
+#else
+ __builtin_unreachable();
+#endif
+ }
};
{
ThrowsOnCopy cp;
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
index 5bdf9e98e897..812f6fc502d9 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/derive_from.pass.cpp
@@ -8,11 +8,11 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
-// REQUIRES-ANY: c++11, c++14
+// REQUIRES: c++11 || c++14
// <functional>
-// See https://llvm.org/bugs/show_bug.cgi?id=20002
+// See https://bugs.llvm.org/show_bug.cgi?id=20002
#include <functional>
#include <type_traits>
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
index f89bde8e6544..3affd984af60 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp
@@ -14,7 +14,7 @@
// function(Fp);
// Ensure that __not_null works for all function types.
-// See https://llvm.org/bugs/show_bug.cgi?id=23589
+// See https://bugs.llvm.org/show_bug.cgi?id=23589
//------------------------------------------------------------------------------
// TESTING std::function<...>::__not_null(Callable)
@@ -31,7 +31,7 @@
// types can be null. The other categories are not tested here.
// 3) '__not_null(Callable)' is well formed when the call signature includes
// varargs.
-// 4) '__not_null(Callable)' works for Callable types with all aritys less
+// 4) '__not_null(Callable)' works for Callable types with all arities less
// than or equal to 3 in C++03.
// 5) '__not_null(Callable)' works when 'Callable' is a member function
// pointer to a cv or ref qualified function type.
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
index 392dfc1993bc..adc7856357e7 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc.pass.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// <functional>
-// REQUIRES-ANY: c++98, c++03, c++11, c++14
+// REQUIRES: c++98 || c++03 || c++11 || c++14
// class function<R(ArgTypes...)>
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
index 8d454723320c..4c1a1ca95ff4 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_F.pass.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// <functional>
-// REQUIRES-ANY: c++98, c++03, c++11, c++14
+// REQUIRES: c++98 || c++03 || c++11 ||c++14
// class function<R(ArgTypes...)>
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
index 718aa49341d2..8b0e831287a5 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_function.pass.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// <functional>
-// REQUIRES-ANY: c++98, c++03, c++11, c++14
+// REQUIRES: c++98 || c++03 || c++11 || c++14
// class function<R(ArgTypes...)>
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
index 354ad955f207..943e170878f2 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_nullptr.pass.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// <functional>
-// REQUIRES-ANY: c++98, c++03, c++11, c++14
+// REQUIRES: c++98 || c++03 || c++11 || c++14
// class function<R(ArgTypes...)>
diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
index e328481b274d..3e5435da1a16 100644
--- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
+++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/alloc_rfunction.pass.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03
-// REQUIRES-ANY: c++11, c++14
+// REQUIRES: c++11 || c++14
// <functional>
diff --git a/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp b/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp
new file mode 100644
index 000000000000..775247fc80b6
--- /dev/null
+++ b/test/std/utilities/function.objects/unord.hash/enabled_hashes.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03
+
+// <functional>
+
+// Test that <functional> provides all of the arithmetic, enum, and pointer
+// hash specializations.
+
+#include <functional>
+
+#include "poisoned_hash_helper.hpp"
+
+int main() {
+ test_library_hash_specializations_available();
+}
diff --git a/test/std/utilities/function.objects/unord.hash/enum.pass.cpp b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
index af367789a105..a7ddd9a49997 100644
--- a/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
+++ b/test/std/utilities/function.objects/unord.hash/enum.pass.cpp
@@ -36,6 +36,7 @@ test()
typedef std::hash<T> H;
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ ASSERT_NOEXCEPT(H()(T()));
typedef typename std::underlying_type<T>::type under_type;
H h1;
@@ -43,7 +44,8 @@ test()
for (int i = 0; i <= 5; ++i)
{
T t(static_cast<T> (i));
- if (sizeof(T) <= sizeof(std::size_t))
+ const bool small = std::integral_constant<bool, sizeof(T) <= sizeof(std::size_t)>::value; // avoid compiler warnings
+ if (small)
assert(h1(t) == h2(static_cast<under_type>(i)));
}
}
diff --git a/test/std/utilities/function.objects/unord.hash/floating.pass.cpp b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp
index 643e2d8c5d86..e67aa016c1e7 100644
--- a/test/std/utilities/function.objects/unord.hash/floating.pass.cpp
+++ b/test/std/utilities/function.objects/unord.hash/floating.pass.cpp
@@ -24,6 +24,8 @@
#include <limits>
#include <cmath>
+#include "test_macros.h"
+
template <class T>
void
test()
@@ -31,6 +33,7 @@ test()
typedef std::hash<T> H;
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ ASSERT_NOEXCEPT(H()(T()));
H h;
std::size_t t0 = h(0.);
diff --git a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
index 2f3f9bee4bc3..ce87f5918b20 100644
--- a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -31,12 +31,14 @@ test()
typedef std::hash<T> H;
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ ASSERT_NOEXCEPT(H()(T()));
H h;
for (int i = 0; i <= 5; ++i)
{
T t(static_cast<T>(i));
- if (sizeof(T) <= sizeof(std::size_t))
+ const bool small = std::integral_constant<bool, sizeof(T) <= sizeof(std::size_t)>::value; // avoid compiler warnings
+ if (small)
{
const std::size_t result = h(t);
LIBCPP_ASSERT(result == static_cast<size_t>(t));
@@ -63,42 +65,42 @@ int main()
test<long long>();
test<unsigned long long>();
-// LWG #2119
+// LWG #2119
test<std::ptrdiff_t>();
test<size_t>();
- test<int8_t>();
- test<int16_t>();
- test<int32_t>();
- test<int64_t>();
+ test<int8_t>();
+ test<int16_t>();
+ test<int32_t>();
+ test<int64_t>();
- test<int_fast8_t>();
- test<int_fast16_t>();
- test<int_fast32_t>();
- test<int_fast64_t>();
+ test<int_fast8_t>();
+ test<int_fast16_t>();
+ test<int_fast32_t>();
+ test<int_fast64_t>();
- test<int_least8_t>();
- test<int_least16_t>();
- test<int_least32_t>();
- test<int_least64_t>();
+ test<int_least8_t>();
+ test<int_least16_t>();
+ test<int_least32_t>();
+ test<int_least64_t>();
test<intmax_t>();
test<intptr_t>();
- test<uint8_t>();
- test<uint16_t>();
- test<uint32_t>();
- test<uint64_t>();
+ test<uint8_t>();
+ test<uint16_t>();
+ test<uint32_t>();
+ test<uint64_t>();
- test<uint_fast8_t>();
- test<uint_fast16_t>();
- test<uint_fast32_t>();
- test<uint_fast64_t>();
+ test<uint_fast8_t>();
+ test<uint_fast16_t>();
+ test<uint_fast32_t>();
+ test<uint_fast64_t>();
- test<uint_least8_t>();
- test<uint_least16_t>();
- test<uint_least32_t>();
- test<uint_least64_t>();
+ test<uint_least8_t>();
+ test<uint_least16_t>();
+ test<uint_least32_t>();
+ test<uint_least64_t>();
test<uintmax_t>();
test<uintptr_t>();
diff --git a/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
index a48394495e2d..36280a38e0a7 100644
--- a/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
+++ b/test/std/utilities/function.objects/unord.hash/pointer.pass.cpp
@@ -23,6 +23,8 @@
#include <type_traits>
#include <limits>
+#include "test_macros.h"
+
template <class T>
void
test()
@@ -30,6 +32,7 @@ test()
typedef std::hash<T> H;
static_assert((std::is_same<typename H::argument_type, T>::value), "" );
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ ASSERT_NOEXCEPT(H()(T()));
H h;
typedef typename std::remove_pointer<T>::type type;
@@ -38,7 +41,20 @@ test()
assert(h(&i) != h(&j));
}
+// can't hash nullptr_t until c++17
+void test_nullptr()
+{
+#if TEST_STD_VER > 14
+ typedef std::nullptr_t T;
+ typedef std::hash<T> H;
+ static_assert((std::is_same<typename H::argument_type, T>::value), "" );
+ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
+ ASSERT_NOEXCEPT(H()(T()));
+#endif
+}
+
int main()
{
test<int*>();
+ test_nullptr();
}