]> git.saurik.com Git - apple/objc4.git/blob - test/nopool.m
objc4-680.tar.gz
[apple/objc4.git] / test / nopool.m
1 // TEST_CONFIG MEM=mrc
2
3 #include "test.h"
4 #include "testroot.i"
5
6 @implementation TestRoot (Loader)
7 +(void)load
8 {
9 [[TestRoot new] autorelease];
10 testassert(TestRootAutorelease == 1);
11 testassert(TestRootDealloc == 0);
12 }
13 @end
14
15 int main()
16 {
17 // +load's autoreleased object should have deallocated
18 testassert(TestRootDealloc == 1);
19
20 [[TestRoot new] autorelease];
21 testassert(TestRootAutorelease == 2);
22
23 objc_autoreleasePoolPop(objc_autoreleasePoolPush());
24
25 [[TestRoot new] autorelease];
26 testassert(TestRootAutorelease == 3);
27
28 testonthread(^{
29 [[TestRoot new] autorelease];
30 testassert(TestRootAutorelease == 4);
31 testassert(TestRootDealloc == 1);
32 });
33
34 // thread's autoreleased object should have deallocated
35 testassert(TestRootDealloc == 2);
36
37 succeed(__FILE__);
38 }