Skip to content

Commit

Permalink
Added ObjC++ variants of NestedExceptions test.
Browse files Browse the repository at this point in the history
Adapted to throw NSString objects instead of using "Test" class, as it seems to expose a different ARC issue.
  • Loading branch information
triplef committed Dec 2, 2019
1 parent 3a8b7f0 commit 6219249
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Test/CMakeLists.txt
Expand Up @@ -60,6 +60,8 @@ if (ENABLE_OBJCXX)
list(APPEND TESTS
ExceptionTestObjCXX.mm
ExceptionTestObjCXX_arc.mm
NestedExceptionsObjCXX.mm
NestedExceptionsObjCXX_arc.mm
)
endif()

Expand Down
35 changes: 35 additions & 0 deletions Test/NestedExceptionsObjCXX.mm
@@ -0,0 +1,35 @@
#include "Test.h"


id a;
int throwException(void)
{
@throw a;
}


int main(void)
{
id e1 = @"Exception 1";
id e2 = @"Exception 2";
@try
{
a = e1;
throwException();
}
@catch (id x)
{
assert(x == e1);
@try {
a = e2;
@throw a;
}
@catch (id y)
{
assert(y == e2);
}
}
[e1 dealloc];
[e2 dealloc];
return 0;
}
33 changes: 33 additions & 0 deletions Test/NestedExceptionsObjCXX_arc.mm
@@ -0,0 +1,33 @@
#include "Test.h"


id a;
int throwException(void)
{
@throw a;
}


int main(void)
{
id e1 = @"Exception 1";
id e2 = @"Exception 2";
@try
{
a = e1;
throwException();
}
@catch (id x)
{
assert(x == e1);
@try {
a = e2;
@throw a;
}
@catch (id y)
{
assert(y == e2);
}
}
return 0;
}

0 comments on commit 6219249

Please sign in to comment.