diff --git a/Test/CMakeLists.txt b/Test/CMakeLists.txt index 40350315..ed0d01a8 100644 --- a/Test/CMakeLists.txt +++ b/Test/CMakeLists.txt @@ -62,6 +62,8 @@ if (ENABLE_OBJCXX) list(APPEND TESTS ExceptionTestObjCXX.mm ExceptionTestObjCXX_arc.mm + NestedExceptionsObjCXX.mm + NestedExceptionsObjCXX_arc.mm ) endif() diff --git a/Test/NestedExceptionsObjCXX.mm b/Test/NestedExceptionsObjCXX.mm new file mode 100644 index 00000000..e0bab9ac --- /dev/null +++ b/Test/NestedExceptionsObjCXX.mm @@ -0,0 +1,33 @@ +#include "Test.h" + + +id a; +int throwException(void) +{ + @throw a; +} + + +int main(void) +{ + id e1 = @"e1"; + id e2 = @"e2"; + @try + { + a = e1; + throwException(); + } + @catch (id x) + { + assert(x == e1); + @try { + a = e2; + @throw a; + } + @catch (id y) + { + assert(y == e2); + } + } + return 0; +} diff --git a/Test/NestedExceptionsObjCXX_arc.mm b/Test/NestedExceptionsObjCXX_arc.mm new file mode 100644 index 00000000..e0bab9ac --- /dev/null +++ b/Test/NestedExceptionsObjCXX_arc.mm @@ -0,0 +1,33 @@ +#include "Test.h" + + +id a; +int throwException(void) +{ + @throw a; +} + + +int main(void) +{ + id e1 = @"e1"; + id e2 = @"e2"; + @try + { + a = e1; + throwException(); + } + @catch (id x) + { + assert(x == e1); + @try { + a = e2; + @throw a; + } + @catch (id y) + { + assert(y == e2); + } + } + return 0; +}