2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / objc / execute / class-4.m
blob34d414b12295164c035fd42d6d46c0f94e7013ef
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 */
10 @interface RootClass
12   Class isa;
14 @end
16 @implementation RootClass
17 #ifdef __NEXT_RUNTIME__                                   
18 + initialize { return self; }
19 #endif
20 @end
22 @interface SubClass : RootClass
24   int state;
26 - (void) setState: (int)number;
27 - (int) state;
28 @end
30 @implementation SubClass
31 - (void) setState: (int)number
33   state = number;
35 - (int) state
37   return state;
39 @end
41 #include "class-tests-1.h"
42 #define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
43 #include "class-tests-2.h"
45 int main (void)
47   SubClass *object;
49   test_class_with_superclass ("SubClass", "RootClass");
50   test_that_class_has_instance_method ("SubClass", @selector (setState:));
51   test_that_class_has_instance_method ("SubClass", @selector (state));
53   object = class_create_instance (objc_lookup_class ("SubClass"));
54   test_accessor_method (object, 0, 1, 1, -3, -3);
56   return 0;