3 objc\[\d+\]: class `DoesNotExist\' not linked into application
13 #include <mach-o/ldsyms.h>
14 #include <objc/objc-runtime.h>
16 @interface Super { id isa; } @end
19 +class { return self; }
22 @interface Sub : Super { } @end
23 @implementation Sub @end
30 unsigned int count, count0, count2;
39 // This shouldn't touch any classes.
40 dladdr(&_mh_execute_header, &info);
41 names = objc_copyClassNamesForImage(info.dli_fname, &count);
43 testassert(count == 2);
44 testassert(names[count] == NULL);
47 for (i = 0; i < count; i++) {
48 if (0 == strcmp(names[i], "Super")) foundSuper++;
49 if (0 == strcmp(names[i], "Sub")) foundSub++;
51 testassert(foundSuper == 1);
52 testassert(foundSub == 1);
55 // class Sub hasn't been touched - make sure it's in the class list too
56 count0 = objc_getClassList(NULL, 0);
57 testassert(count0 >= 2 && count0 < 100);
59 list[count0-1] = NULL;
60 count = objc_getClassList(list, count0-1);
61 testassert(list[count0-1] == NULL);
62 testassert(count == count0);
64 count = objc_getClassList(list, count0);
65 testassert(count == count0);
68 for (i = 0; i < count; i++) {
69 if (0 == strcmp(class_getName(list[i]), "Super")) foundSuper++;
70 if (0 == strcmp(class_getName(list[i]), "Sub")) foundSub++;
71 // list should be non-meta classes only
72 testassert(!class_isMetaClass(list[i]));
74 testassert(foundSuper == 1);
75 testassert(foundSub == 1);
77 // fixme check class handler
78 testassert(objc_getClass("Super") == [Super class]);
79 testassert(objc_getClass("DoesNotExist") == nil);
80 testassert(objc_getClass(NULL) == nil);
82 testassert(objc_getMetaClass("Super") == [Super class]->isa);
83 testassert(objc_getMetaClass("DoesNotExist") == nil);
84 testassert(objc_getMetaClass(NULL) == nil);
86 // fixme check class no handler
87 testassert(objc_lookUpClass("Super") == [Super class]);
88 testassert(objc_lookUpClass("DoesNotExist") == nil);
89 testassert(objc_lookUpClass(NULL) == nil);
91 list2 = objc_copyClassList(&count2);
92 testassert(count2 == count);
94 testassert(malloc_size(list2) >= (1+count2) * sizeof(Class));
95 for (i = 0; i < count; i++) {
96 testassert(list[i] == list2[i]);
98 testassert(list2[count] == NULL);
100 free(objc_copyClassList(NULL));