rogfer01 created this revision.
rogfer01 added reviewers: mclow.lists, EricWF, rmaprath.
rogfer01 added a subscriber: cfe-commits.

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.


https://reviews.llvm.org/D26142

Files:
  
test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
  
test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp

Index: test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp
+++ 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
 // <optional>
 
 // void swap(optional&)
@@ -19,6 +18,8 @@
 #include <type_traits>
 #include <cassert>
 
+#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<bool>(opt2) == true);
         assert(*opt2 == 1);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     {
         optional<Z> opt1;
         optional<Z> opt2;
@@ -307,4 +309,5 @@
         assert(static_cast<bool>(opt2) == true);
         assert(*opt2 == 2);
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp
@@ -8,15 +8,16 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // <optional>
 
 // constexpr const T& optional<T>::value() const;
 
 #include <experimental/optional>
 #include <type_traits>
 #include <cassert>
 
+#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<X> opt(in_place);
         assert(opt.value().test() == 3);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     {
         const optional<X> opt;
         try
@@ -51,4 +53,5 @@
         {
         }
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp
@@ -8,15 +8,16 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // <optional>
 
 // T& optional<T>::value();
 
 #include <experimental/optional>
 #include <type_traits>
 #include <cassert>
 
+#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<X> opt;
         try
@@ -46,4 +48,5 @@
         {
         }
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp
+++ 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
 
 // <optional>
 
@@ -18,6 +17,8 @@
 #include <type_traits>
 #include <cassert>
 
+#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: test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -8,15 +8,16 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // <optional>
 
 // optional(optional<T>&& rhs) noexcept(is_nothrow_move_constructible<T>::value);
 
 #include <experimental/optional>
 #include <type_traits>
 #include <cassert>
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 template <class T>
@@ -26,16 +27,20 @@
     static_assert(std::is_nothrow_move_constructible<optional<T>>::value ==
                   std::is_nothrow_move_constructible<T>::value, "");
     bool rhs_engaged = static_cast<bool>(rhs);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
+#endif
     {
         optional<T> lhs = std::move(rhs);
         assert(is_going_to_throw == false);
         assert(static_cast<bool>(lhs) == rhs_engaged);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     catch (int i)
     {
         assert(i == 6);
     }
+#endif
 }
 
 class X
@@ -68,7 +73,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_;}
@@ -127,6 +132,7 @@
         optional<T> rhs(Y(3));
         test(rhs);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     {
         typedef Z T;
         optional<T> rhs;
@@ -137,4 +143,5 @@
         optional<T> rhs(Z(3));
         test(rhs, true);
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
+++ 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
 // <optional>
 
 // template <class U, class... Args>
@@ -20,6 +19,8 @@
 #include <vector>
 #include <cassert>
 
+#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<int> 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<optional<Z>, std::initializer_list<int>&>::value, "");
         try
@@ -112,4 +114,5 @@
             assert(i == 6);
         }
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp
+++ 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
 
 // <optional>
 
@@ -19,6 +18,7 @@
 #include <type_traits>
 #include <cassert>
 
+#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: test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -8,34 +8,39 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // <optional>
 
 // optional(const optional<T>& rhs);
 
 #include <experimental/optional>
 #include <type_traits>
 #include <cassert>
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 template <class T>
 void
 test(const optional<T>& rhs, bool is_going_to_throw = false)
 {
     bool rhs_engaged = static_cast<bool>(rhs);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     try
+#endif
     {
         optional<T> lhs = rhs;
         assert(is_going_to_throw == false);
         assert(static_cast<bool>(lhs) == rhs_engaged);
         if (rhs_engaged)
             assert(*lhs == *rhs);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     catch (int i)
     {
         assert(i == 6);
     }
+#endif
 }
 
 class X
@@ -68,7 +73,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_;}
@@ -117,6 +122,7 @@
         optional<T> rhs(Y(3));
         test(rhs);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     {
         typedef Z T;
         optional<T> rhs;
@@ -127,4 +133,5 @@
         optional<T> rhs(Z(3));
         test(rhs, true);
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp
+++ 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
 
 // <optional>
 
@@ -18,6 +17,8 @@
 #include <type_traits>
 #include <cassert>
 
+#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: test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp
+++ 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>
 
 // optional<T>& operator=(optional<T>&& rhs)
@@ -19,6 +18,8 @@
 #include <type_traits>
 #include <cassert>
 
+#include "test_macros.h"
+
 using std::experimental::optional;
 
 struct AllowConstAssign {
@@ -36,18 +37,18 @@
     X(X&&)
     {
         if (throw_now)
-            throw 6;
+            TEST_THROW(6);
     }
     X& operator=(X&&) noexcept
     {
         return *this;
     }
 };
 
-struct Y {};
-
 bool X::throw_now = false;
 
+struct Y {};
+
 int main()
 {
     {
@@ -88,6 +89,7 @@
         optional<const AllowConstAssign> opt2;
         opt = std::move(opt2);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     {
         static_assert(!std::is_nothrow_move_assignable<optional<X>>::value, "");
         optional<X> opt;
@@ -105,6 +107,7 @@
             assert(static_cast<bool>(opt) == false);
         }
     }
+#endif
     {
         static_assert(std::is_nothrow_move_assignable<optional<Y>>::value, "");
     }
Index: test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
+++ 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
 // <optional>
 
 // template <class U, class... Args>
@@ -19,6 +18,8 @@
 #include <cassert>
 #include <vector>
 
+#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<int> 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<bool>(opt) == true);
         assert(*opt == Y({1, 2}));
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     {
         Z z;
         optional<Z> opt(z);
@@ -120,4 +122,5 @@
             assert(Z::dtor_called == true);
         }
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp
+++ 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
 // <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 @@
 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<Z> opt(z);
@@ -147,4 +149,5 @@
             assert(Z::dtor_called == true);
         }
     }
+#endif
 }
Index: test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
===================================================================
--- test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
+++ test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp
@@ -8,15 +8,16 @@
 //===----------------------------------------------------------------------===//
 
 // UNSUPPORTED: c++98, c++03, c++11
-// XFAIL: libcpp-no-exceptions
 // <optional>
 
 // optional<T>& operator=(const optional<T>& rhs);
 
 #include <experimental/optional>
 #include <type_traits>
 #include <cassert>
 
+#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<bool>(opt) == static_cast<bool>(opt2));
         assert(*opt == *opt2);
     }
+#ifndef TEST_HAS_NO_EXCEPTIONS
     {
         optional<X> opt;
         optional<X> opt2(X{});
@@ -95,4 +97,5 @@
             assert(static_cast<bool>(opt) == false);
         }
     }
+#endif
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to