1 /* Test the Modern GNU Objective-C Runtime API.
3 This is test 'property', covering all functions starting with 'property'. */
6 /* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
8 /* To get the modern GNU Objective-C Runtime API, you include
10 #include <objc/runtime.h>
15 @interface MyRootClass
22 @implementation MyRootClass
23 + alloc { return class_createInstance (self, 0); }
24 - init { return self; }
25 + initialize { return self; }
28 @interface MySubClass : MyRootClass
33 @property (assign, getter=getP, setter=setP:) id propertyA;
34 @property (assign, nonatomic) id propertyB;
37 @implementation MySubClass
38 @synthesize propertyA;
39 @synthesize propertyB;
43 int main(int argc, void **args)
45 /* Functions are tested in alphabetical order. */
47 printf ("Testing property_getAttributes () ...\n");
49 /* The Apple/NeXT runtime seems to crash on the following. */
50 #ifdef __GNU_LIBOBJC__
51 if (property_getAttributes (NULL) != NULL)
55 /* The GNU runtime doesn't support looking up properties at
59 objc_property_t property;
61 property = class_getProperty (objc_getClass ("MySubClass"), "propertyA");
62 if (strcmp (property_getAttributes (property),
63 "T@,GgetP,SsetP:,VpropertyA") != 0)
66 property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
67 if (strcmp (property_getAttributes (property),
68 "T@,N,VpropertyB") != 0)
74 printf ("Testing property_getName () ...\n");
76 /* The Apple/NeXT runtime seems to crash on the following. */
77 #ifdef __GNU_LIBOBJC__
78 if (property_getName (NULL) != NULL)
82 /* The GNU runtime doesn't support looking up properties at
86 objc_property_t property;
88 property = class_getProperty (objc_getClass ("MySubClass"), "propertyA");
89 if (strcmp (property_getName (property), "propertyA") != 0)
92 property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
93 if (strcmp (property_getName (property), "propertyB") != 0)