summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-06-01 21:05:53 +0000
committerEric Fiselier <eric@efcs.ca>2016-06-01 21:05:53 +0000
commiteb5cfb02d6a3c757940d8ad3f31a4286535a32ad (patch)
tree61c64393998a42a844b8ee101abb75128f377bd7 /libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
parentf807dce6da05ef506b6a21b611f855f9eb209692 (diff)
downloadbcm5719-llvm-eb5cfb02d6a3c757940d8ad3f31a4286535a32ad.tar.gz
bcm5719-llvm-eb5cfb02d6a3c757940d8ad3f31a4286535a32ad.zip
Cleanup non-standard tests as reported by STL@microsoft.com. NFC.
This patch addresses the following issues in the test suite: 1. Move "std::bad_array_length" test from std/ to libcxx/ test directory since the feature is not a part of the standard. 2. Rename "futures.tas" test directory to "futures.task" since that is the correct stable name. 3. Move tests for "packaged_task<T>::result_type" from std/ to libcxx/ test directory since the typedef is a libc++ extension. llvm-svn: 271430
Diffstat (limited to 'libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp')
-rw-r--r--libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp b/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
new file mode 100644
index 00000000000..c8e5d6efd6b
--- /dev/null
+++ b/libcxx/test/std/thread/futures/futures.task/futures.task.members/get_future.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+//
+// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// <future>
+
+// class packaged_task<R(ArgTypes...)>
+
+// future<R> get_future();
+
+#include <future>
+#include <cassert>
+
+class A
+{
+ long data_;
+
+public:
+ explicit A(long i) : data_(i) {}
+
+ long operator()(long i, long j) const {return data_ + i + j;}
+};
+
+int main()
+{
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ p(3, 'a');
+ assert(f.get() == 105.0);
+ }
+ {
+ std::packaged_task<double(int, char)> p(A(5));
+ std::future<double> f = p.get_future();
+ try
+ {
+ f = p.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::future_already_retrieved));
+ }
+ }
+ {
+ std::packaged_task<double(int, char)> p;
+ try
+ {
+ std::future<double> f = p.get_future();
+ assert(false);
+ }
+ catch (const std::future_error& e)
+ {
+ assert(e.code() == make_error_code(std::future_errc::no_state));
+ }
+ }
+}
OpenPOWER on IntegriCloud