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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [special/] [load-category-2.m] - Blame information for rev 704

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 704 jeremybenn
/* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 2010.  */
2
/* { dg-do run } */
3
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
 
5
#include <stdio.h>
6
#include <stdlib.h>
7
#include <objc/objc.h>
8
 
9
#include "load-category-2.h"
10
 
11
/* This test tests that +load is called in the correct order for
12
   classes and categories.  +load needs to be called in superclasses
13
   before subclasses, and in the main class before categories.  */
14
 
15
/* Compile the classes in random order to prevent the runtime from
16
   sending +load in the correct order just because the classes happen
17
   to have been compiled in that order.  */
18
@implementation TestClass2
19
+ load
20
{
21
  printf ("[TestClass2 +load]\n");
22
  /* Check superclasses/subclasses +load order.  */
23
  check_that_load_step_was_completed (0);
24
  check_that_load_step_was_not_completed (1);
25
  check_that_load_step_was_not_completed (2);
26
 
27
  /* Check that the corresponding category's +load was not done.  */
28
  check_that_load_step_was_not_completed (4);
29
 
30
  complete_load_step (1);
31
}
32
@end
33
 
34
@implementation TestClass3
35
+ load
36
{
37
  printf ("[TestClass3 +load]\n");
38
 
39
  /* Check superclasses/subclasses +load order.  */
40
  check_that_load_step_was_completed (0);
41
  check_that_load_step_was_completed (1);
42
  check_that_load_step_was_not_completed (2);
43
 
44
  /* Check that the corresponding category's +load was not done.  */
45
  check_that_load_step_was_not_completed (5);
46
 
47
  complete_load_step (2);
48
}
49
@end
50
 
51
@implementation TestClass1
52
+ initialize { return self; }
53
+ load
54
{
55
  printf ("[TestClass1 +load]\n");
56
 
57
  /* Check superclasses/subclasses +load order.  */
58
  check_that_load_step_was_not_completed (0);
59
  check_that_load_step_was_not_completed (1);
60
  check_that_load_step_was_not_completed (2);
61
 
62
  /* Check that the corresponding category's +load was not done.  */
63
  check_that_load_step_was_not_completed (3);
64
 
65
  complete_load_step (0);
66
}
67
@end
68
 
69
 
70
static BOOL load_step_completed[6] = { NO, NO, NO, NO, NO, NO };
71
 
72
void complete_load_step (int load_step)
73
{
74
  load_step_completed[load_step] = YES;
75
}
76
 
77
void check_that_load_step_was_completed (int load_step)
78
{
79
  if (load_step_completed[load_step] == NO)
80
    {
81
      printf ("Load step %d was not completed but should have been\n", load_step);
82
      abort ();
83
    }
84
}
85
 
86
void check_that_load_step_was_not_completed (int load_step)
87
{
88
  if (load_step_completed[load_step] == YES)
89
    {
90
      printf ("Load step %d was completed but shouldn't have been\n", load_step);
91
      abort ();
92
    }
93
}
94
 
95
int main (void)
96
{
97
  check_that_load_step_was_completed (0);
98
  check_that_load_step_was_completed (1);
99
  check_that_load_step_was_completed (2);
100
  check_that_load_step_was_completed (3);
101
  check_that_load_step_was_completed (4);
102
  check_that_load_step_was_completed (5);
103
 
104
  return 0;
105
}

powered by: WebSVN 2.1.0

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