Skip to content

Commit b1622ad

Browse files
committed
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.
1 parent 111e309 commit b1622ad

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

Test/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ if (ENABLE_OBJCXX)
6262
list(APPEND TESTS
6363
ExceptionTestObjCXX.mm
6464
ExceptionTestObjCXX_arc.mm
65+
NestedExceptionsObjCXX.mm
66+
NestedExceptionsObjCXX_arc.mm
6567
)
6668
endif()
6769

Test/NestedExceptionsObjCXX.mm

+33
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 = @"e1";
14+
id e2 = @"e2";
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+
}

Test/NestedExceptionsObjCXX_arc.mm

+33
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 = @"e1";
14+
id e2 = @"e2";
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)