OSDN Git Service

8b8af5ed3073408825beb28398d19014f6478097
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / special / unclaimed-category-1.m
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>
6
7 /* Test loading unclaimed categories - categories of a class defined
8    separately from the class itself.  */
9
10
11 /* unclaimed-category-1.m contains only the class definition but not
12    the categories.  unclaimed-category-1a.m contains only the
13    categories of the class, but not the class itself.  We want to
14    check that the runtime can load the class from one module (file)
15    and the categories from another module (file).  */
16
17 #include "unclaimed-category-1.h"
18
19 @implementation TestClass
20 - (int)D
21 {
22   return 4;
23 }
24 #ifdef __NEXT_RUNTIME__                                   
25 + initialize { return self; }
26 #endif
27 @end
28
29
30 int main (void)
31 {
32   TestClass *test;
33   Class testClass;
34
35   testClass = objc_get_class ("TestClass");
36   if (testClass == Nil)
37     {
38       abort ();
39     }
40   
41   test = (TestClass *)(class_create_instance (testClass));
42   if (test == nil)
43     {
44       abort ();
45     }
46   
47   if ([test A] != 1)
48     {
49       abort ();
50     }
51   
52   if ([test B] != 2)
53     {
54       abort ();
55     }
56
57   if ([test C] != 3)
58     {
59       abort ();
60     }
61   
62
63   if ([test D] != 4)
64     {
65       abort ();
66     }
67
68   return 0;
69 }