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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc/] [execute/] [class-13.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
   but reusing it with super */
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
@end
39
 
40
@implementation SubSubClass
41
+ (int) state
42
{
43
  return [super state] + 1;
44
}
45
@end
46
 
47
#include "class-tests-1.h"
48
#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
49
#include "class-tests-2.h"
50
 
51
int main (void)
52
{
53
  Class class;
54
  Class sub_class;
55
 
56
  test_class_with_superclass ("SubClass", "RootClass");
57
  test_that_class_has_class_method ("SubClass", @selector (setState:));
58
  test_that_class_has_class_method ("SubClass", @selector (state));
59
 
60
  test_class_with_superclass ("SubSubClass", "SubClass");
61
  test_that_class_has_class_method ("SubSubClass", @selector (setState:));
62
  test_that_class_has_class_method ("SubSubClass", @selector (state));
63
 
64
  class = objc_getClass ("SubClass");
65
  test_accessor_method (class, 0, -1, -1, 1, 1);
66
 
67
  sub_class = objc_getClass ("SubSubClass");
68
  class_variable = 0;
69
  test_accessor_method (sub_class, 1, -1, 0, 1, 2);
70
 
71
  return 0;
72
}

powered by: WebSVN 2.1.0

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