2 #include <objc/runtime.h>
4 @interface Super1 { id isa; } @end
6 +class { return self; }
8 +(int)classMethod { return 1; }
9 -(int)instanceMethod { return 10000; }
12 @interface Super2 { id isa; } @end
13 @implementation Super2
14 +class { return self; }
16 +(int)classMethod { return 2; }
17 -(int)instanceMethod { return 20000; }
20 @interface Sub : Super1 @end
22 +new { return class_createInstance(self, 0); }
23 +(int)classMethod { return [super classMethod] + 100; }
24 -(int)instanceMethod { return [super instanceMethod] + 1000000; }
32 testassert(101 == [[Sub class] classMethod]);
33 testassert(1010000 == [obj instanceMethod]);
35 cls = class_setSuperclass([Sub class], [Super2 class]);
37 testassert(cls == [Super1 class]);
38 testassert(cls->isa == [Super1 class]->isa);
40 testassert(102 == [[Sub class] classMethod]);
41 testassert(1020000 == [obj instanceMethod]);