Fix std::experimental::optional tests. Patch from Casey Carter.
authorEric Fiselier <eric@efcs.ca>
Sun, 17 Jul 2016 20:32:30 +0000 (20:32 +0000)
committerEric Fiselier <eric@efcs.ca>
Sun, 17 Jul 2016 20:32:30 +0000 (20:32 +0000)
llvm-svn: 275732

libcxx/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp
libcxx/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp
libcxx/test/std/experimental/optional/optional.specalg/make_optional.pass.cpp
libcxx/test/std/experimental/optional/optional.syn/optional_const_nullopt_t.fail.cpp
libcxx/test/std/experimental/optional/optional.syn/optional_nullopt_t.fail.cpp

index bb8fcd5..fec3740 100644 (file)
@@ -59,7 +59,7 @@ public:
     static bool dtor_called;
     constexpr Z() : i_(0) {}
     constexpr Z(int i) : i_(i) {}
-    constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
+    Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
         {throw 6;}
     ~Z() {dtor_called = true;}
 
index acc139e..9bd6b18 100644 (file)
@@ -59,7 +59,7 @@ class Z
 public:
     constexpr Z() : i_(0) {}
     constexpr Z(int i) : i_(i) {}
-    constexpr Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
+    Z(std::initializer_list<int> il) : i_(il.begin()[0]), j_(il.begin()[1])
         {throw 6;}
 
     friend constexpr bool operator==(const Z& x, const Z& y)
@@ -97,6 +97,8 @@ int main()
                 : optional<Y>(in_place, i) {}
         };
 
+        constexpr test_constexpr_ctor dopt(in_place, {42, 101, -1});
+        static_assert(*dopt == Y{42, 101, -1}, "");
     }
     {
         static_assert(std::is_constructible<optional<Z>, std::initializer_list<int>&>::value, "");
@@ -109,13 +111,5 @@ int main()
         {
             assert(i == 6);
         }
-
-        struct test_constexpr_ctor
-            : public optional<Z>
-        {
-            constexpr test_constexpr_ctor(in_place_t, std::initializer_list<int> i)
-                : optional<Z>(in_place, i) {}
-        };
-
     }
 }
index 7f5ffea..9abd87b 100644 (file)
@@ -20,6 +20,8 @@
 #include <memory>
 #include <cassert>
 
+#include "test_macros.h"
+
 int main()
 {
     using std::experimental::optional;
@@ -38,7 +40,7 @@ int main()
         std::string s("123");
         optional<std::string> opt = make_optional(std::move(s));
         assert(*opt == "123");
-        assert(s.empty());
+        LIBCPP_ASSERT(s.empty());
     }
     {
         std::unique_ptr<int> s(new int(3));
index fb695d2..89c2073 100644 (file)
@@ -11,7 +11,7 @@
 // <optional>
 
 // A program that necessitates the instantiation of template optional for
-// (possibly cv-qualified) null_opt_t is ill-formed.
+// (possibly cv-qualified) nullopt_t is ill-formed.
 
 #include <experimental/optional>
 
index 9b62c9b..3d276d6 100644 (file)
@@ -11,7 +11,7 @@
 // <optional>
 
 // A program that necessitates the instantiation of template optional for
-// (possibly cv-qualified) null_opt_t is ill-formed.
+// (possibly cv-qualified) nullopt_t is ill-formed.
 
 #include <experimental/optional>