1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // The LLVM Compiler Infrastructure
5 //
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
8 //
9 //===----------------------------------------------------------------------===//
10
11 // UNSUPPORTED: libcpp-no-exceptions
12 // MODULES_DEFINES: _LIBCPP_DEBUG=1
13 // MODULES_DEFINES: _LIBCPP_DEBUG_USE_EXCEPTIONS
14
15 // Can't test the system lib because this test enables debug mode
16 // UNSUPPORTED: with_system_cxx_lib
17
18 // Test that defining _LIBCPP_DEBUG_USE_EXCEPTIONS causes _LIBCPP_ASSERT
19 // to throw on failure.
20
21 #define _LIBCPP_DEBUG 1
22 #define _LIBCPP_DEBUG_USE_EXCEPTIONS
23
24 #include <cstdlib>
25 #include <exception>
26 #include <type_traits>
27 #include <__debug>
28 #include <cassert>
29
main()30 int main()
31 {
32 try {
33 _LIBCPP_ASSERT(false, "foo");
34 assert(false);
35 } catch (...) {}
36 }
37