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
10 #include <objc/objc-runtime.h>
11 #include <malloc/malloc.h>
25 @implementation SubSub2
27 return 1 + [super method];
42 // objc_getFutureClass with existing class
43 oldSuper = objc_getFutureClass("Super");
44 testassert(oldSuper == [Super class]);
46 // objc_getFutureClass with missing class
47 oldSub1 = objc_getFutureClass("Sub1");
49 testassert(malloc_size(oldSub1) > 0);
50 testassert(objc_getClass("Sub1") == Nil);
52 // objc_getFutureClass a second time
53 testassert(oldSub1 == objc_getFutureClass("Sub1"));
56 // objc_setFutureClass with existing class
57 oldSub2 = objc_getClass("Sub2");
58 testassert(oldSub2 == [Sub2 class]);
59 testassert(oldSub2 == class_getSuperclass(objc_getClass("SubSub2")));
60 objc_setFutureClass((Class)buf, "Sub2");
61 testassert(0 == strcmp(class_getName((Class)buf), "Sub2"));
62 newSub2 = objc_getClass("Sub2");
63 testassert(newSub2 == (Class)buf);
64 testassert(newSub2 != oldSub2);
66 testassert(newSub2 == [Sub2 class]);
67 testassert(newSub2 == [newSub2 class]);
68 testassert(newSub2 == [newSub2 classref]);
69 testassert(newSub2 != [oldSub2 class]);
70 // check superclass chains
71 testassert(newSub2 == class_getSuperclass(objc_getClass("SubSub2")));
73 // 64-bit ABI ignores objc_setFutureClass.
77 dlopen("future2.dylib", 0);
79 // Verify use of future class
80 newSub1 = objc_getClass("Sub1");
81 testassert(oldSub1 == newSub1);
82 testassert(newSub1 == [newSub1 classref]);
83 testassert(newSub1 == class_getSuperclass(objc_getClass("SubSub1")));
85 testassert(1 == [oldSub1 method]);
86 testassert(1 == [newSub1 method]);
88 testassert(2 == [newSub2 method]);
89 testassert(2 == [oldSub2 method]);
90 testassert(3 == [SubSub2 method]);