OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [load-3.m] - Blame information for rev 154

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/*
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 <objc/objc.h>
12
#include <objc/Object.h>
13
 
14
@interface A : Object
15
@end
16
 
17
@interface B : A
18
@end
19
 
20
static a_load = 0;
21
static b_load = 0;
22
static a_category_load = 0;
23
static b_category_load = 0;
24
 
25
@implementation A (Category)
26
+ (void)load
27
{
28
  a_category_load = 1;
29
  printf("+[A(Category) load]\n");
30
 
31
  if (a_load != 1)
32
    {
33
      printf("+load for A(Category) invoked before A's!\n");
34
      abort();
35
    }
36
}
37
@end
38
 
39
@implementation B(Category)
40
+ (void)load
41
{
42
  b_category_load = 1;
43
  printf("+[B(Category) load]\n");
44
 
45
  if (b_load != 1)
46
    {
47
      printf ("+load for B(Category) invoked before B!\n");
48
      abort();
49
    }
50
}
51
@end
52
 
53
@implementation B
54
+ (void)load
55
{
56
  b_load = 1;
57
  printf("+[B load]\n");
58
 
59
  if (a_load != 1)
60
    {
61
      printf("+load for B invoked before A's!\n");
62
      abort();
63
    }
64
 
65
  if (b_category_load != 0)
66
    {
67
      printf("+load for B invoked after B(Category)!\n");
68
      abort();
69
    }
70
}
71
@end
72
 
73
@implementation A
74
+ (void)load
75
{
76
  a_load = 1;
77
  printf("+[A load]\n");
78
 
79
  if (a_category_load != 0)
80
    {
81
      printf("+load for A(Category) invoked before A!\n");
82
      abort();
83
    }
84
 
85
  if (b_load != 0)
86
    {
87
      printf("+load for A invoked after B!\n");
88
      abort();
89
    }
90
 
91
  if (b_category_load != 0)
92
    {
93
      printf("+load for B(Category) invoked before A and B!\n");
94
      abort();
95
    }
96
}
97
@end
98
 
99
int main (void)
100
{
101
  if (a_load + b_load + a_category_load + b_category_load != 4)
102
    {
103
      printf("Not all +load methods invoked!\n");
104
      abort();
105
    }
106
 
107
  return 0;
108
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.