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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc/] [execute/] [class-10.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 an ivar and
6
   accessor methods and a subclass overriding the superclass'
7
   implementation, 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
@interface SubClass : RootClass
20
{
21
  int state;
22
}
23
- (void) setState: (int)number;
24
- (int) state;
25
@end
26
 
27
@implementation SubClass
28
- (void) setState: (int)number
29
{
30
  state = number;
31
}
32
- (int) state
33
{
34
  return state;
35
}
36
@end
37
 
38
@interface SubSubClass : SubClass
39
- (int) shift;
40
@end
41
 
42
@implementation SubSubClass
43
- (int) state
44
{
45
  return state + [self shift];
46
}
47
- (int) shift
48
{
49
  return 1;
50
}
51
@end
52
 
53
#include "class-tests-1.h"
54
#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
55
#include "class-tests-2.h"
56
 
57
int main (void)
58
{
59
  SubClass *object;
60
  SubSubClass *sub_object;
61
 
62
  test_class_with_superclass ("SubClass", "RootClass");
63
  test_that_class_has_instance_method ("SubClass", @selector (setState:));
64
  test_that_class_has_instance_method ("SubClass", @selector (state));
65
 
66
  test_class_with_superclass ("SubSubClass", "SubClass");
67
  test_that_class_has_instance_method ("SubSubClass", @selector (setState:));
68
  test_that_class_has_instance_method ("SubSubClass", @selector (state));
69
  test_that_class_has_instance_method ("SubSubClass", @selector (shift));
70
 
71
  object = class_createInstance (objc_getClass ("SubClass"), 0);
72
  test_accessor_method (object, 0, -1, -1, 1, 1);
73
 
74
  sub_object = class_createInstance (objc_getClass ("SubSubClass"), 0);
75
  test_accessor_method (sub_object, 1, -1, 0, 1, 2);
76
 
77
  return 0;
78
}

powered by: WebSVN 2.1.0

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