3 $C{COMPILE} $DIR/future0.m -o future0.dylib -dynamiclib
4 $C{COMPILE} $DIR/future2.m -x none future0.dylib -o future2.dylib -dynamiclib
5 $C{COMPILE} $DIR/future.m -x none future0.dylib -o future.out
11 #if __has_feature(objc_arc)
15 testwarn("rdar://10041403 future class API is not ARC-compatible");
22 #include <objc/runtime.h>
23 #include <malloc/malloc.h>
37 @implementation SubSub2
39 return 1 + [super method];
54 // objc_getFutureClass with existing class
55 oldTestRoot = objc_getFutureClass("TestRoot");
56 testassert(oldTestRoot == [TestRoot class]);
58 // objc_getFutureClass with missing class
59 oldSub1 = objc_getFutureClass("Sub1");
61 testassert(malloc_size(objc_unretainedPointer(oldSub1)) > 0);
62 testassert(objc_getClass("Sub1") == Nil);
64 // objc_getFutureClass a second time
65 testassert(oldSub1 == objc_getFutureClass("Sub1"));
68 // objc_setFutureClass with existing class
69 oldSub2 = objc_getClass("Sub2");
70 testassert(oldSub2 == [Sub2 class]);
71 testassert(oldSub2 == class_getSuperclass(objc_getClass("SubSub2")));
72 objc_setFutureClass((Class)buf, "Sub2");
73 testassert(0 == strcmp(class_getName((Class)buf), "Sub2"));
74 newSub2 = objc_getClass("Sub2");
75 testassert(newSub2 == (Class)buf);
76 testassert(newSub2 != oldSub2);
78 testassert(newSub2 == [Sub2 class]);
79 testassert(newSub2 == [newSub2 class]);
80 testassert(newSub2 == [newSub2 classref]);
81 testassert(newSub2 != [oldSub2 class]);
82 // check superclass chains
83 testassert(newSub2 == class_getSuperclass(objc_getClass("SubSub2")));
85 // 64-bit ABI ignores objc_setFutureClass.
89 dlopen("future2.dylib", 0);
91 // Verify use of future class
92 newSub1 = objc_getClass("Sub1");
93 testassert(oldSub1 == newSub1);
94 testassert(newSub1 == [newSub1 classref]);
95 testassert(newSub1 == class_getSuperclass(objc_getClass("SubSub1")));
97 testassert(1 == [oldSub1 method]);
98 testassert(1 == [newSub1 method]);
100 testassert(2 == [newSub2 method]);
101 testassert(2 == [oldSub2 method]);
102 testassert(3 == [SubSub2 method]);