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 short NSString objects which should fit in a small object, as it seems to expose a different ARC issue.
  • Loading branch information
triplef committed May 2, 2020
1 parent 7f460e4 commit b6ef305
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Test/CMakeLists.txt
Expand Up @@ -62,6 +62,8 @@ if (ENABLE_OBJCXX)
list(APPEND TESTS
ExceptionTestObjCXX.mm
ExceptionTestObjCXX_arc.mm
NestedExceptionsObjCXX.mm
NestedExceptionsObjCXX_arc.mm
)
endif()

Expand Down
33 changes: 33 additions & 0 deletions 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;
}
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 = @"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;
}

0 comments on commit b6ef305

Please sign in to comment.