Merge to HEAD at tree-cleanup-merge-20041024 .
[official-gcc.git] / gcc / testsuite / objc.dg / special / unclaimed-category-1.m
blobb3a8c28b5e68a168df0cffa6d322278bb055cc9d
1 /* Contributed by Nicola Pero - Fri Dec 14 08:36:00 GMT 2001 */
2 /* { dg-do run } */
3 #include <objc/objc.h>
4 #include <objc/objc-api.h>
5 #include <objc/Object.h>
7 extern void abort (void);
9 /* Test loading unclaimed categories - categories of a class defined
10    separately from the class itself.  */
13 /* unclaimed-category-1.m contains only the class definition but not
14    the categories.  unclaimed-category-1a.m contains only the
15    categories of the class, but not the class itself.  We want to
16    check that the runtime can load the class from one module (file)
17    and the categories from another module (file).  */
19 #include "unclaimed-category-1.h"
21 @implementation TestClass
22 - (int)D
24   return 4;
26 #ifdef __NEXT_RUNTIME__                                   
27 + initialize { return self; }
28 #endif
29 @end
32 int main (void)
34   TestClass *test;
35   Class testClass;
37   testClass = objc_get_class ("TestClass");
38   if (testClass == Nil)
39     {
40       abort ();
41     }
42   
43   test = (TestClass *)(class_create_instance (testClass));
44   if (test == nil)
45     {
46       abort ();
47     }
48   
49   if ([test A] != 1)
50     {
51       abort ();
52     }
53   
54   if ([test B] != 2)
55     {
56       abort ();
57     }
59   if ([test C] != 3)
60     {
61       abort ();
62     }
63   
65   if ([test D] != 4)
66     {
67       abort ();
68     }
70   return 0;