Debian Codegraph @

gcc/testsuite/objc/execute/class-12.m

raw
1 /* Contributed by Nicola Pero - Tue Mar 6 23:05:53 CET 2001 */
2
3 #include <objc/objc.h>
4
5 /* Tests creating a root class and a subclass with a class methods */
6
7 @interface RootClass
8 {
9 Class isa;
10 }
11 @end
12
13 @implementation RootClass
14 + initialize { return self; }
15 @end
16
17 static int class_variable = 0;
18
19 @interface SubClass : RootClass
20 + (void) setState: (int)number;
21 + (int) state;
22 @end
23
24 @implementation SubClass
25 + (void) setState: (int)number
26 {
27 class_variable = number;
28 }
29 + (int) state
30 {
31 return class_variable;
32 }
33 @end
34
35 #include "class-tests-1.h"
36 #define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
37 #include "class-tests-2.h"
38
39 int main (void)
40 {
41 Class class;
42
43 test_class_with_superclass ("SubClass", "RootClass");
44 test_that_class_has_class_method ("SubClass", @selector (setState:));
45 test_that_class_has_class_method ("SubClass", @selector (state));
46
47 class = objc_getClass ("SubClass");
48 test_accessor_method (class, 0, -1, -1, 1, 1);
49
50 return 0;
51 }