OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc / execute / load-3.m
1 /*
2     load-3.m
3
4     Author: Ovidiu Predescu <ovidiu@cup.hp.com>
5     Date: June  3, 2001
6
7     Test if the +load methods are invoked, and are invoked in the
8     proper order.
9  */
10
11 #include <stdlib.h>
12 #import "../../objc-obj-c++-shared/Object1.h"
13 #include <objc/objc.h>
14
15 @interface A : Object
16 @end
17
18 @interface B : A
19 @end
20
21 static a_load = 0;
22 static b_load = 0;
23 static a_category_load = 0;
24 static b_category_load = 0;
25
26 @implementation A (Category)
27 + (void)load
28 {
29   a_category_load = 1;
30   printf("+[A(Category) load]\n");
31
32   if (a_load != 1)
33     {
34       printf("+load for A(Category) invoked before A's!\n");
35       abort();
36     }
37 }
38 @end
39
40 @implementation B(Category)
41 + (void)load
42 {
43   b_category_load = 1;
44   printf("+[B(Category) load]\n");
45
46   if (b_load != 1)
47     {
48       printf ("+load for B(Category) invoked before B!\n");
49       abort();
50     }
51 }
52 @end
53
54 @implementation B
55 + (void)load
56 {
57   b_load = 1;
58   printf("+[B load]\n");
59
60   if (a_load != 1)
61     {
62       printf("+load for B invoked before A's!\n");
63       abort();
64     }
65
66   if (b_category_load != 0)
67     {
68       printf("+load for B invoked after B(Category)!\n");
69       abort();
70     }
71 }
72 @end
73
74 @implementation A
75 + (void)load
76 {
77   a_load = 1;
78   printf("+[A load]\n");
79
80   if (a_category_load != 0)
81     {
82       printf("+load for A(Category) invoked before A!\n");
83       abort();
84     }
85
86   if (b_load != 0)
87     {
88       printf("+load for A invoked after B!\n");
89       abort();
90     }
91
92   if (b_category_load != 0)
93     {
94       printf("+load for B(Category) invoked before A and B!\n");
95       abort();
96     }
97 }
98 @end
99
100 int main (void)
101 {
102   if (a_load + b_load + a_category_load + b_category_load != 4)
103     {
104       printf("Not all +load methods invoked!\n");
105       abort();
106     }
107
108   return 0;
109 }