Clean up some minor white space issues in trans-decl.c and trans-expr.c
[official-gcc.git] / gcc / testsuite / objc / execute / class-11.m
blob2cd6017d4607bf3a3eae6709e6206d5a49890348
1 /* Contributed by Nicola Pero - Tue Mar  6 23:05:53 CET 2001 */
3 #include <objc/objc.h>
5 /* Tests creating a root class and a subclass with an ivar and
6    accessor methods and a subclass overriding the superclass'
7    implementation and using self to call another method of itself - in
8    a category */
10 @interface RootClass
12   Class isa;
14 @end
16 @implementation RootClass
17 + initialize { return self; }
18 @end
20 @interface SubClass : RootClass
22   int state;
24 - (void) setState: (int)number;
25 - (int) state;
26 @end
28 @implementation SubClass
29 - (void) setState: (int)number
31   state = number;
33 - (int) state
35   return state;
37 @end
39 @interface SubSubClass : SubClass
40 - (int) shift;
41 @end
43 @implementation SubSubClass
44 - (int) shift
46   return 1;
48 @end
50 @implementation SubSubClass (Additions)
51 - (int) state
53   return state + [self shift];
55 @end
57 #include "class-tests-1.h"
58 #define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
59 #include "class-tests-2.h"
61 int main (void)
63   SubClass *object;
64   SubSubClass *sub_object;
66   test_class_with_superclass ("SubClass", "RootClass");
67   test_that_class_has_instance_method ("SubClass", @selector (setState:));
68   test_that_class_has_instance_method ("SubClass", @selector (state));
70   test_class_with_superclass ("SubSubClass", "SubClass");
71   test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
72   test_that_class_has_instance_method ("SubSubClass", @selector (state));
73   test_that_class_has_instance_method ("SubSubClass", @selector (shift));
74   
75   object = class_createInstance (objc_getClass ("SubClass"), 0);
76   test_accessor_method (object, 0, -1, -1, 1, 1);
78   sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0);
79   test_accessor_method (sub_object, 1, -1, 0, 1, 2);
81   return 0;