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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc/] [execute/] [class-10.m] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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