]> git.saurik.com Git - apple/objc4.git/blob - test/nsprotocol.m
objc4-680.tar.gz
[apple/objc4.git] / test / nsprotocol.m
1 // TEST_CONFIG
2
3 #include "test.h"
4
5 #if __OBJC2__
6
7 #include <objc/Protocol.h>
8
9 int main()
10 {
11 // Class Protocol is always a subclass of NSObject
12
13 testassert(objc_getClass("NSObject"));
14
15 Class cls = objc_getClass("Protocol");
16 testassert(class_getInstanceMethod(cls, sel_registerName("isProxy")));
17 testassert(class_getSuperclass(cls) == objc_getClass("NSObject"));
18
19 succeed(__FILE__);
20 }
21
22 #else
23
24 #include <dlfcn.h>
25 #include <objc/Protocol.h>
26
27 int main()
28 {
29 // Class Protocol is never a subclass of NSObject
30 // CoreFoundation adds NSObject methods to Protocol when it loads
31
32 testassert(objc_getClass("NSObject"));
33
34 Class cls = objc_getClass("Protocol");
35 testassert(!class_getInstanceMethod(cls, sel_registerName("isProxy")));
36 testassert(class_getSuperclass(cls) != objc_getClass("NSObject"));
37
38 void *dl = dlopen("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation", RTLD_LAZY);
39 testassert(dl);
40
41 testassert(class_getInstanceMethod(cls, sel_registerName("isProxy")));
42 testassert(class_getSuperclass(cls) != objc_getClass("NSObject"));
43
44 succeed(__FILE__);
45 }
46
47 #endif