summaryrefslogtreecommitdiffstats
path: root/libcxx/test/language.support/support.exception/exception.unexpected
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-11 19:42:16 +0000
commit3e519524c118651123eecf60c2bbc5d65ad9bac3 (patch)
treeb2dd4168cfe448920a602cd7d2e40f95da187153 /libcxx/test/language.support/support.exception/exception.unexpected
parent9132c59d43b6c590c9bb33496eebf9f192d6857a (diff)
downloadbcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.tar.gz
bcm5719-llvm-3e519524c118651123eecf60c2bbc5d65ad9bac3.zip
libcxx initial import
llvm-svn: 103490
Diffstat (limited to 'libcxx/test/language.support/support.exception/exception.unexpected')
-rw-r--r--libcxx/test/language.support/support.exception/exception.unexpected/bad.exception/bad_exception.pass.cpp27
-rw-r--r--libcxx/test/language.support/support.exception/exception.unexpected/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/language.support/support.exception/exception.unexpected/set.unexpected/set_unexpected.pass.cpp22
-rw-r--r--libcxx/test/language.support/support.exception/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp19
-rw-r--r--libcxx/test/language.support/support.exception/exception.unexpected/unexpected/unexpected.pass.cpp26
5 files changed, 106 insertions, 0 deletions
diff --git a/libcxx/test/language.support/support.exception/exception.unexpected/bad.exception/bad_exception.pass.cpp b/libcxx/test/language.support/support.exception/exception.unexpected/bad.exception/bad_exception.pass.cpp
new file mode 100644
index 00000000000..9f32dac7e75
--- /dev/null
+++ b/libcxx/test/language.support/support.exception/exception.unexpected/bad.exception/bad_exception.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test bad_exception
+
+#include <exception>
+#include <type_traits>
+#include <cassert>
+
+int main()
+{
+ static_assert((std::is_base_of<std::exception, std::bad_exception>::value),
+ "std::is_base_of<std::exception, std::bad_exception>::value");
+ static_assert(std::is_polymorphic<std::bad_exception>::value,
+ "std::is_polymorphic<std::bad_exception>::value");
+ std::bad_exception b;
+ std::bad_exception b2 = b;
+ b2 = b;
+ const char* w = b2.what();
+ assert(w);
+}
diff --git a/libcxx/test/language.support/support.exception/exception.unexpected/nothing_to_do.pass.cpp b/libcxx/test/language.support/support.exception/exception.unexpected/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..fa4d462f18d
--- /dev/null
+++ b/libcxx/test/language.support/support.exception/exception.unexpected/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/language.support/support.exception/exception.unexpected/set.unexpected/set_unexpected.pass.cpp b/libcxx/test/language.support/support.exception/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
new file mode 100644
index 00000000000..6f52ab772aa
--- /dev/null
+++ b/libcxx/test/language.support/support.exception/exception.unexpected/set.unexpected/set_unexpected.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test set_unexpected
+
+#include <exception>
+#include <cassert>
+
+void f1() {}
+void f2() {}
+
+int main()
+{
+ assert(std::set_unexpected(f1) == std::terminate);
+ assert(std::set_unexpected(f2) == f1);
+}
diff --git a/libcxx/test/language.support/support.exception/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp b/libcxx/test/language.support/support.exception/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
new file mode 100644
index 00000000000..dbb56069d48
--- /dev/null
+++ b/libcxx/test/language.support/support.exception/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unexpected_handler
+
+#include <exception>
+
+void f() {}
+
+int main()
+{
+ std::unexpected_handler p = f;
+}
diff --git a/libcxx/test/language.support/support.exception/exception.unexpected/unexpected/unexpected.pass.cpp b/libcxx/test/language.support/support.exception/exception.unexpected/unexpected/unexpected.pass.cpp
new file mode 100644
index 00000000000..0f441e2b6e7
--- /dev/null
+++ b/libcxx/test/language.support/support.exception/exception.unexpected/unexpected/unexpected.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// test unexpected
+
+#include <exception>
+#include <cstdlib>
+#include <cassert>
+
+void f1()
+{
+ std::exit(0);
+}
+
+int main()
+{
+ std::set_unexpected(f1);
+ std::unexpected();
+ assert(false);
+}
OpenPOWER on IntegriCloud