Protect bitset tests under libcpp-no-exceptions

Bitset tests feature a sequence of tests of increasing bitset sizes,
but these tests rely on exceptions when the bitset size is less than
50 elements.

This change adds a flag to tell whether a test should throw. If it must
throw it will be skipped under no-exceptions.

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

llvm-svn: 286474
diff --git a/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp b/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
index 161afd1..1a2d706 100644
--- a/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
+++ b/libcxx/test/std/utilities/template.bitset/bitset.members/test.pass.cpp
@@ -7,13 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-// XFAIL: libcpp-no-exceptions
 // test constexpr bool test(size_t pos) const;
 
 #include <bitset>
 #include <cstdlib>
 #include <cassert>
 
+#include "test_macros.h"
+
 template <std::size_t N>
 std::bitset<N>
 make_bitset()
@@ -25,30 +26,38 @@
 }
 
 template <std::size_t N>
-void test_test()
+void test_test(bool test_throws)
 {
     const std::bitset<N> v1 = make_bitset<N>();
+#ifdef TEST_HAS_NO_EXCEPTIONS
+    if (test_throws) return;
+#else
     try
     {
+#endif
         bool b = v1.test(50);
         if (50 >= v1.size())
             assert(false);
         assert(b == v1[50]);
+        assert(!test_throws);
+#ifndef TEST_HAS_NO_EXCEPTIONS
     }
     catch (std::out_of_range&)
     {
+        assert(test_throws);
     }
+#endif
 }
 
 int main()
 {
-    test_test<0>();
-    test_test<1>();
-    test_test<31>();
-    test_test<32>();
-    test_test<33>();
-    test_test<63>();
-    test_test<64>();
-    test_test<65>();
-    test_test<1000>();
+    test_test<0>(true);
+    test_test<1>(true);
+    test_test<31>(true);
+    test_test<32>(true);
+    test_test<33>(true);
+    test_test<63>(false);
+    test_test<64>(false);
+    test_test<65>(false);
+    test_test<1000>(false);
 }