2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / objc / execute / class-12.m
blobfcab65b2d369e34591e23f68cc76135a1398a3cd
1 /* Contributed by Nicola Pero - Tue Mar  6 23:05:53 CET 2001 */
2 #include <objc/objc.h>
3 #include <objc/objc-api.h>
5 #include "next_mapping.h"
7 /* Tests creating a root class and a subclass with a class methods */
9 @interface RootClass
11   Class isa;
13 @end
15 @implementation RootClass
16 #ifdef __NEXT_RUNTIME__                                   
17 + initialize { return self; }
18 #endif
19 @end
21 static int class_variable = 0;
23 @interface SubClass : RootClass
24 + (void) setState: (int)number;
25 + (int) state;
26 @end
28 @implementation SubClass
29 + (void) setState: (int)number
31   class_variable = number;
33 + (int) state
35   return class_variable;
37 @end
39 #include "class-tests-1.h"
40 #define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
41 #include "class-tests-2.h"
43 int main (void)
45   Class class;
47   test_class_with_superclass ("SubClass", "RootClass");
48   test_that_class_has_class_method ("SubClass", @selector (setState:));
49   test_that_class_has_class_method ("SubClass", @selector (state));
51   class = objc_lookup_class ("SubClass");
52   test_accessor_method (class, 0, -1, -1, 1, 1);
54   return 0;