1 // TEST_CFLAGS -Wno-deprecated-declarations
4 #include <objc/runtime.h>
6 @interface Super1 { id isa; } @end
8 +class { return self; }
10 +(int)classMethod { return 1; }
11 -(int)instanceMethod { return 10000; }
14 @interface Super2 { id isa; } @end
15 @implementation Super2
16 +class { return self; }
18 +(int)classMethod { return 2; }
19 -(int)instanceMethod { return 20000; }
22 @interface Sub : Super1 @end
24 +new { return class_createInstance(self, 0); }
25 +(int)classMethod { return [super classMethod] + 100; }
26 -(int)instanceMethod {
27 return [super instanceMethod] + 1000000;
36 testassert(101 == [[Sub class] classMethod]);
37 testassert(1010000 == [obj instanceMethod]);
39 cls = class_setSuperclass([Sub class], [Super2 class]);
41 testassert(cls == [Super1 class]);
42 testassert(cls->isa == [Super1 class]->isa);
44 testassert(102 == [[Sub class] classMethod]);
45 testassert(1020000 == [obj instanceMethod]);