1 /* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
3 #include <objc/objc-api.h>
5 #include "next_mapping.h"
7 /* Tests creating a root class and a subclass with a class accessor
8 methods and a subclass overriding the superclass' implementation,
9 and using self to call another method of itself */
17 @implementation RootClass
18 #ifdef __NEXT_RUNTIME__
19 + initialize { return self; }
23 static int class_variable = 0;
25 @interface SubClass : RootClass
26 + (void) setState: (int)number;
30 @implementation SubClass
31 + (void) setState: (int)number
33 class_variable = number;
37 return class_variable;
41 @interface SubSubClass : SubClass
45 @implementation SubSubClass
48 return class_variable + [self shift];
56 #include "class-tests-1.h"
57 #define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
58 #include "class-tests-2.h"
62 Class class, sub_class;
64 test_class_with_superclass ("SubClass", "RootClass");
65 test_that_class_has_class_method ("SubClass", @selector (setState:));
66 test_that_class_has_class_method ("SubClass", @selector (state));
68 test_class_with_superclass ("SubSubClass", "SubClass");
69 test_that_class_has_class_method ("SubSubClass", @selector (setState:));
70 test_that_class_has_class_method ("SubSubClass", @selector (state));
71 test_that_class_has_class_method ("SubSubClass", @selector (shift));
73 class = objc_lookup_class ("SubClass");
74 test_accessor_method (class, 0, -1, -1, 1, 1);
76 sub_class = objc_lookup_class ("SubSubClass");
78 test_accessor_method (sub_class, 1, -1, 0, 1, 2);