In gcc/: 2010-10-17 Nicola Pero <nicola.pero@meta-innovation.com>
[gcc.git] / gcc / testsuite / obj-c++.dg / gnu-api-2-property.mm
1 /* Test the Modern GNU Objective-C Runtime API.
2
3 This is test 'property', covering all functions starting with 'property'. */
4
5 /* { dg-do run } */
6 /* { dg-skip-if "" { *-*-* } { "-fnext-runtime" } { "" } } */
7
8 /* To get the modern GNU Objective-C Runtime API, you include
9 objc/runtime.h. */
10 #include <objc/runtime.h>
11 #include <stdlib.h>
12 #include <iostream>
13 #include <cstring>
14
15 @interface MyRootClass
16 { Class isa; }
17 + alloc;
18 - init;
19 @end
20
21 @implementation MyRootClass
22 + alloc { return class_createInstance (self, 0); }
23 - init { return self; }
24 @end
25
26 @protocol MyProtocol
27 - (id) variable;
28 @end
29
30 @protocol MySecondProtocol
31 - (id) setVariable: (id)value;
32 @end
33
34 @interface MySubClass : MyRootClass <MyProtocol>
35 { id variable_ivar; }
36 - (void) setVariable: (id)value;
37 - (id) variable;
38 @end
39
40 @implementation MySubClass
41 - (void) setVariable: (id)value { variable_ivar = value; }
42 - (id) variable { return variable_ivar; }
43 @end
44
45
46 int main ()
47 {
48 /* Functions are tested in alphabetical order. */
49
50 /* TODO: Test new ABI (when available). */
51 std::cout << "Testing property_getAttributes () ...\n";
52 {
53 if (property_getAttributes (NULL) != NULL)
54 abort ();
55 }
56
57 /* TODO: Test new ABI (when available). */
58 std::cout << "Testing property_getName () ...\n";
59 {
60 if (property_getName (NULL) != NULL)
61 abort ();
62 }
63
64 return (0);
65 }