Add tests that got missed in r271247.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@271248 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-05-31 01:51:34 +00:00
parent b169bb00d1
commit 57c164f2a2
2 changed files with 106 additions and 0 deletions

View File

@@ -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);
}
}
}

View File

@@ -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_on_thread_exit(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_at_thread_exit(std::exception_ptr());
assert(false);
} catch (int const& value) {
assert(value == 42);
}
}
{
typedef int& T;
std::promise<T> p;
try {
p.set_exception_at_thread_exit(std::exception_ptr());
assert(false);
} catch (int const& value) {
assert(value == 42);
}
}
}