summaryrefslogtreecommitdiff
path: root/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp')
-rw-r--r--test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
new file mode 100644
index 000000000000..bf567a30243a
--- /dev/null
+++ b/test/libcxx/thread/futures/futures.promise/set_exception.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-has-no-threads
+// UNSUPPORTED: c++98, c++03
+
+// <future>
+
+// class promise<R>
+
+// void set_exception(exception_ptr p);
+// Test that a null exception_ptr is diagnosed.
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? ((void)0) : throw 42)
+
+#define _LIBCPP_DEBUG 0
+#include <future>
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+
+int main()
+{
+ {
+ typedef int T;
+ std::promise<T> p;
+ try {
+ p.set_exception(std::exception_ptr());
+ assert(false);
+ } catch (int const& value) {
+ assert(value == 42);
+ }
+ }
+ {
+ typedef int& T;
+ std::promise<T> p;
+ try {
+ p.set_exception(std::exception_ptr());
+ assert(false);
+ } catch (int const& value) {
+ assert(value == 42);
+ }
+ }
+}