Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // optional& operator=(const optional& rhs); @@ -17,6 +16,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; struct AllowConstAssign { @@ -34,7 +35,7 @@ X(const X&) { if (throw_now) - throw 6; + TEST_THROW(6); } }; @@ -79,6 +80,7 @@ assert(static_cast(opt) == static_cast(opt2)); assert(*opt == *opt2); } +#ifndef TEST_HAS_NO_EXCEPTIONS { optional opt; optional opt2(X{}); @@ -95,4 +97,5 @@ assert(static_cast(opt) == false); } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // template void optional::emplace(Args&&... args); @@ -18,6 +17,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; class X @@ -48,7 +49,7 @@ public: static bool dtor_called; Z() = default; - Z(int) {throw 6;} + Z(int) {TEST_THROW(6);} ~Z() {dtor_called = true;} }; @@ -131,6 +132,7 @@ assert(Y::dtor_called == true); } } +#ifndef TEST_HAS_NO_EXCEPTIONS { Z z; optional opt(z); @@ -147,4 +149,5 @@ assert(Z::dtor_called == true); } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // template @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; class X @@ -60,7 +61,7 @@ constexpr Z() : i_(0) {} constexpr Z(int i) : i_(i) {} Z(std::initializer_list il) : i_(il.begin()[0]), j_(il.begin()[1]) - {throw 6;} + {TEST_THROW(6);} ~Z() {dtor_called = true;} friend constexpr bool operator==(const Z& x, const Z& y) @@ -104,6 +105,7 @@ assert(static_cast(opt) == true); assert(*opt == Y({1, 2})); } +#ifndef TEST_HAS_NO_EXCEPTIONS { Z z; optional opt(z); @@ -120,4 +122,5 @@ assert(Z::dtor_called == true); } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // optional& operator=(optional&& rhs) @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; struct AllowConstAssign { @@ -36,7 +37,7 @@ X(X&&) { if (throw_now) - throw 6; + TEST_THROW(6); } X& operator=(X&&) noexcept { @@ -44,10 +45,10 @@ } }; -struct Y {}; - bool X::throw_now = false; +struct Y {}; + int main() { { @@ -88,6 +89,7 @@ optional opt2; opt = std::move(opt2); } +#ifndef TEST_HAS_NO_EXCEPTIONS { static_assert(!std::is_nothrow_move_assignable>::value, ""); optional opt; @@ -105,6 +107,7 @@ assert(static_cast(opt) == false); } } +#endif { static_assert(std::is_nothrow_move_assignable>::value, ""); } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // @@ -18,6 +17,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; class X @@ -42,7 +43,7 @@ { public: Z(int) {} - Z(const Z&) {throw 6;} + Z(const Z&) {TEST_THROW(6);} }; @@ -97,6 +98,7 @@ }; } +#ifndef TEST_HAS_NO_EXCEPTIONS { typedef Z T; try @@ -110,4 +112,5 @@ assert(i == 6); } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // optional(const optional& rhs); @@ -17,6 +16,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; template @@ -24,7 +25,12 @@ test(const optional& rhs, bool is_going_to_throw = false) { bool rhs_engaged = static_cast(rhs); +#ifdef TEST_HAS_NO_EXCEPTIONS + if (is_going_to_throw) + return; +#else try +#endif { optional lhs = rhs; assert(is_going_to_throw == false); @@ -32,10 +38,13 @@ if (rhs_engaged) assert(*lhs == *rhs); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (int i) { assert(i == 6); + assert(is_going_to_throw); } +#endif } class X @@ -68,7 +77,7 @@ Z(const Z&) { if (++count == 2) - throw 6; + TEST_THROW(6); } friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // @@ -19,6 +18,7 @@ #include #include +#include "test_macros.h" using std::experimental::optional; using std::experimental::in_place_t; @@ -55,7 +55,7 @@ class Z { public: - Z(int i) {throw 6;} + Z(int i) {TEST_THROW(6);} }; @@ -128,6 +128,7 @@ }; } +#ifndef TEST_HAS_NO_EXCEPTIONS { try { @@ -139,4 +140,5 @@ assert(i == 6); } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // template @@ -20,6 +19,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; using std::experimental::in_place_t; using std::experimental::in_place; @@ -60,7 +61,7 @@ constexpr Z() : i_(0) {} constexpr Z(int i) : i_(i) {} Z(std::initializer_list il) : i_(il.begin()[0]), j_(il.begin()[1]) - {throw 6;} + {TEST_THROW(6);} friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_ && x.j_ == y.j_;} @@ -100,6 +101,7 @@ constexpr test_constexpr_ctor dopt(in_place, {42, 101, -1}); static_assert(*dopt == Y{42, 101, -1}, ""); } +#ifndef TEST_HAS_NO_EXCEPTIONS { static_assert(std::is_constructible, std::initializer_list&>::value, ""); try @@ -112,4 +114,5 @@ assert(i == 6); } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // optional(optional&& rhs) noexcept(is_nothrow_move_constructible::value); @@ -17,6 +16,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; template @@ -26,16 +27,24 @@ static_assert(std::is_nothrow_move_constructible>::value == std::is_nothrow_move_constructible::value, ""); bool rhs_engaged = static_cast(rhs); +#ifdef TEST_HAS_NO_EXCEPTIONS + if (is_going_to_throw) + return; +#else try +#endif { optional lhs = std::move(rhs); assert(is_going_to_throw == false); assert(static_cast(lhs) == rhs_engaged); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (int i) { assert(i == 6); + assert(is_going_to_throw); } +#endif } class X @@ -68,7 +77,7 @@ Z(Z&&) { if (++count == 2) - throw 6; + TEST_THROW(6); } friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // @@ -18,6 +17,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; class X @@ -44,7 +45,7 @@ { public: Z(int) {} - Z(Z&&) {throw 6;} + Z(Z&&) {TEST_THROW(6);} }; @@ -92,6 +93,7 @@ constexpr test_constexpr_ctor(T&&) {} }; } +#ifndef TEST_HAS_NO_EXCEPTIONS { typedef Z T; try @@ -104,4 +106,5 @@ assert(i == 6); } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // T& optional::value(); @@ -17,6 +16,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; using std::experimental::bad_optional_access; @@ -35,6 +36,7 @@ opt.emplace(); assert(opt.value().test() == 4); } +#ifndef TEST_HAS_NO_EXCEPTIONS { optional opt; try @@ -46,4 +48,5 @@ { } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // constexpr const T& optional::value() const; @@ -17,6 +16,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; using std::experimental::in_place_t; using std::experimental::in_place; @@ -40,6 +41,7 @@ const optional opt(in_place); assert(opt.value().test() == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS { const optional opt; try @@ -51,4 +53,5 @@ { } } +#endif } Index: libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp =================================================================== --- libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp +++ libcxx/trunk/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++98, c++03, c++11 -// XFAIL: libcpp-no-exceptions // // void swap(optional&) @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + using std::experimental::optional; class X @@ -56,10 +57,10 @@ int i_; public: Z(int i) : i_(i) {} - Z(Z&&) {throw 7;} + Z(Z&&) {TEST_THROW(7);} friend constexpr bool operator==(const Z& x, const Z& y) {return x.i_ == y.i_;} - friend void swap(Z& x, Z& y) {throw 6;} + friend void swap(Z& x, Z& y) {TEST_THROW(6);} }; struct ConstSwappable { @@ -231,6 +232,7 @@ assert(static_cast(opt2) == true); assert(*opt2 == 1); } +#ifndef TEST_HAS_NO_EXCEPTIONS { optional opt1; optional opt2; @@ -307,4 +309,5 @@ assert(static_cast(opt2) == true); assert(*opt2 == 2); } +#endif }