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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc/] [execute/] [class-14.m] - Blame information for rev 702

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 702 jeremybenn
/* Contributed by Nicola Pero - Tue Mar  6 23:05:53 CET 2001 */
2
 
3
#include <objc/objc.h>
4
 
5
/* Tests creating a root class and a subclass with a class accessor
6
   methods and a subclass overriding the superclass' implementation,
7
   and using self to call another method of itself */
8
 
9
@interface RootClass
10
{
11
  Class isa;
12
}
13
@end
14
 
15
@implementation RootClass
16
+ initialize { return self; }
17
@end
18
 
19
static int class_variable = 0;
20
 
21
@interface SubClass : RootClass
22
+ (void) setState: (int)number;
23
+ (int) state;
24
@end
25
 
26
@implementation SubClass
27
+ (void) setState: (int)number
28
{
29
  class_variable = number;
30
}
31
+ (int) state
32
{
33
  return class_variable;
34
}
35
@end
36
 
37
@interface SubSubClass : SubClass
38
+ (int) shift;
39
@end
40
 
41
@implementation SubSubClass
42
+ (int) state
43
{
44
  return class_variable + [self shift];
45
}
46
+ (int) shift
47
{
48
  return 1;
49
}
50
@end
51
 
52
#include "class-tests-1.h"
53
#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
54
#include "class-tests-2.h"
55
 
56
int main (void)
57
{
58
  Class class, sub_class;
59
 
60
  test_class_with_superclass ("SubClass", "RootClass");
61
  test_that_class_has_class_method ("SubClass", @selector (setState:));
62
  test_that_class_has_class_method ("SubClass", @selector (state));
63
 
64
  test_class_with_superclass ("SubSubClass", "SubClass");
65
  test_that_class_has_class_method ("SubSubClass", @selector (setState:));
66
  test_that_class_has_class_method ("SubSubClass", @selector (state));
67
  test_that_class_has_class_method ("SubSubClass", @selector (shift));
68
 
69
  class = objc_getClass ("SubClass");
70
  test_accessor_method (class, 0, -1, -1, 1, 1);
71
 
72
  sub_class = objc_getClass ("SubSubClass");
73
  class_variable = 0;
74
  test_accessor_method (sub_class, 1, -1, 0, 1, 2);
75
 
76
  return 0;
77
}

powered by: WebSVN 2.1.0

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