From 8f1a545c9fab68367062110b7b5834807d0a5982 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Mon, 2 Dec 2019 11:24:01 +0100 Subject: [PATCH] Added ObjC++ variants of NestedExceptions test. Adapted to throw short NSString objects which should fit in a small object, as it seems to expose a different ARC issue. --- Test/CMakeLists.txt | 2 ++ Test/NestedExceptionsObjCXX.mm | 33 ++++++++++++++++++++++++++++++ Test/NestedExceptionsObjCXX_arc.mm | 33 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 Test/NestedExceptionsObjCXX.mm create mode 100644 Test/NestedExceptionsObjCXX_arc.mm diff --git a/Test/CMakeLists.txt b/Test/CMakeLists.txt index 3dce2525..5bc5a1a8 100644 --- a/Test/CMakeLists.txt +++ b/Test/CMakeLists.txt @@ -63,6 +63,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; +}