]> git.saurik.com Git - apple/objc4.git/blob - test/gdb.m
objc4-680.tar.gz
[apple/objc4.git] / test / gdb.m
1 // TEST_CFLAGS -Wno-deprecated-declarations
2
3 #include "test.h"
4
5 #if TARGET_OS_IPHONE
6
7 int main()
8 {
9 succeed(__FILE__);
10 }
11
12 #else
13
14 #include "testroot.i"
15 #include <objc/objc-gdb.h>
16 #include <objc/runtime.h>
17
18 int main()
19 {
20 // Class hashes
21 #if __OBJC2__
22
23 Class result;
24
25 // Class should not be realized yet
26 // fixme not true during class hash rearrangement
27 // result = NXMapGet(gdb_objc_realized_classes, "TestRoot");
28 // testassert(!result);
29
30 [TestRoot class];
31 // Now class should be realized
32
33 result = (Class)objc_unretainedObject(NXMapGet(gdb_objc_realized_classes, "TestRoot"));
34 testassert(result);
35 testassert(result == [TestRoot class]);
36
37 result = (Class)objc_unretainedObject(NXMapGet(gdb_objc_realized_classes, "DoesNotExist"));
38 testassert(!result);
39
40 #else
41
42 struct objc_class query;
43 Class result;
44
45 query.name = "TestRoot";
46 result = (Class)NXHashGet(_objc_debug_class_hash, &query);
47 testassert(result);
48 testassert((id)result == [TestRoot class]);
49
50 query.name = "DoesNotExist";
51 result = (Class)NXHashGet(_objc_debug_class_hash, &query);
52 testassert(!result);
53
54 #endif
55
56 succeed(__FILE__);
57 }
58
59 #endif