* btest-gcc.sh (TESTLOGS): Examine regressions in libstdc++,
[official-gcc.git] / gcc / testsuite / objc / execute / class-8.m
blob806db03687c1a21faa0332e2ebd06a95b6ad175d
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 an ivar and
8    accessor methods and a subclass overriding the superclass'
9    implementation - in a category */
11 @interface RootClass
13   Class isa;
15 @end
17 @implementation RootClass
18 #ifdef __NEXT_RUNTIME__                                   
19 + initialize { return self; }
20 #endif
21 @end
23 @interface SubClass : RootClass
25   int state;
27 - (void) setState: (int)number;
28 - (int) state;
29 @end
31 @implementation SubClass
32 - (void) setState: (int)number
34   state = number;
36 - (int) state
38   return state;
40 @end
42 @interface SubSubClass : SubClass
43 @end
45 @implementation SubSubClass
46 @end
48 @implementation SubSubClass (Additions)
49 - (int) state
51   return state + 1;
53 @end
55 #include "class-tests-1.h"
56 #define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
57 #include "class-tests-2.h"
59 int main (void)
61   SubClass *object;
62   SubSubClass *sub_object;
64   test_class_with_superclass ("SubClass", "RootClass");
65   test_that_class_has_instance_method ("SubClass", @selector (setState:));
66   test_that_class_has_instance_method ("SubClass", @selector (state));
68   test_class_with_superclass ("SubSubClass", "SubClass");
69   test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
70   test_that_class_has_instance_method ("SubSubClass", @selector (state));
71   
72   object = class_create_instance (objc_lookup_class ("SubClass"));
73   test_accessor_method (object, 0, -1, -1, 1, 1);
75   sub_object = class_create_instance (objc_lookup_class ("SubSubClass"));
76   test_accessor_method (sub_object, 1, -1, 0, 1, 2);
78   return 0;