Skip to content

Commit 6219249

Browse files
committed
Added ObjC++ variants of NestedExceptions test.
Adapted to throw NSString objects instead of using "Test" class, as it seems to expose a different ARC issue.
1 parent 3a8b7f0 commit 6219249

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

Test/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ if (ENABLE_OBJCXX)
6060
list(APPEND TESTS
6161
ExceptionTestObjCXX.mm
6262
ExceptionTestObjCXX_arc.mm
63+
NestedExceptionsObjCXX.mm
64+
NestedExceptionsObjCXX_arc.mm
6365
)
6466
endif()
6567

Test/NestedExceptionsObjCXX.mm

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#include "Test.h"
2+
3+
4+
id a;
5+
int throwException(void)
6+
{
7+
@throw a;
8+
}
9+
10+
11+
int main(void)
12+
{
13+
id e1 = @"Exception 1";
14+
id e2 = @"Exception 2";
15+
@try
16+
{
17+
a = e1;
18+
throwException();
19+
}
20+
@catch (id x)
21+
{
22+
assert(x == e1);
23+
@try {
24+
a = e2;
25+
@throw a;
26+
}
27+
@catch (id y)
28+
{
29+
assert(y == e2);
30+
}
31+
}
32+
[e1 dealloc];
33+
[e2 dealloc];
34+
return 0;
35+
}

Test/NestedExceptionsObjCXX_arc.mm

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#include "Test.h"
2+
3+
4+
id a;
5+
int throwException(void)
6+
{
7+
@throw a;
8+
}
9+
10+
11+
int main(void)
12+
{
13+
id e1 = @"Exception 1";
14+
id e2 = @"Exception 2";
15+
@try
16+
{
17+
a = e1;
18+
throwException();
19+
}
20+
@catch (id x)
21+
{
22+
assert(x == e1);
23+
@try {
24+
a = e2;
25+
@throw a;
26+
}
27+
@catch (id y)
28+
{
29+
assert(y == e2);
30+
}
31+
}
32+
return 0;
33+
}

0 commit comments

Comments
 (0)