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;
45 /* Functions are tested in alphabetical order. */
47 std::cout << "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 (std::strcmp (property_getAttributes (property),
63 "T@,GgetP,SsetP:,VpropertyA") != 0)
66 property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
67 if (std::strcmp (property_getAttributes (property),
68 "T@,N,VpropertyB") != 0)
74 std::cout << "Testing property_getName () ...\n";
76 /* The Apple/NeXT runtime seems to crash on the following. */
77 #ifdef __GNU_LIBOBJC__
79 if (property_getName (NULL) != NULL)
83 /* The GNU runtime doesn't support looking up properties at
87 objc_property_t property;
89 property = class_getProperty (objc_getClass ("MySubClass"), "propertyA");
90 if (std::strcmp (property_getName (property), "propertyA") != 0)
93 property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
94 if (std::strcmp (property_getName (property), "propertyB") != 0)