Protect std::experimental::optional tests under libcpp-no-exceptions

In these tests there are some paths that explicitly throw, so use
the TEST_THROW macro that was proposed for this and then skip the tests
that may enter the throwing path.

Differential Revision: https://reviews.llvm.org/D26142



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@286099 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Roger Ferrer Ibanez
2016-11-07 08:23:59 +00:00
parent d87eb99b80
commit 240b8c875b
13 changed files with 77 additions and 27 deletions

View File

@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11
// XFAIL: libcpp-no-exceptions
// <optional>
// template <class... Args> void optional<T>::emplace(Args&&... args);
@@ -18,6 +17,8 @@
#include <cassert>
#include <memory>
#include "test_macros.h"
using std::experimental::optional;
class X
@@ -48,7 +49,7 @@ class Z
public:
static bool dtor_called;
Z() = default;
Z(int) {throw 6;}
Z(int) {TEST_THROW(6);}
~Z() {dtor_called = true;}
};
@@ -131,6 +132,7 @@ int main()
assert(Y::dtor_called == true);
}
}
#ifndef TEST_HAS_NO_EXCEPTIONS
{
Z z;
optional<Z> opt(z);
@@ -147,4 +149,5 @@ int main()
assert(Z::dtor_called == true);
}
}
#endif
}