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" } { "" } } */
7 // { dg-additional-options "-Wno-objc-root-class" }
9 /* To get the modern GNU Objective-C Runtime API, you include
11 #include <objc/runtime.h>
16 @interface MyRootClass
23 @implementation MyRootClass
24 + alloc { return class_createInstance (self, 0); }
25 - init { return self; }
26 + initialize { return self; }
29 @interface MySubClass : MyRootClass
34 @property (assign, getter=getP, setter=setP:) id propertyA;
35 @property (assign, nonatomic) id propertyB;
38 @implementation MySubClass
39 @synthesize propertyA;
40 @synthesize propertyB;
46 /* Functions are tested in alphabetical order. */
48 std::cout << "Testing property_getAttributes () ...\n";
50 /* The Apple/NeXT runtime seems to crash on the following. */
51 #ifdef __GNU_LIBOBJC__
52 if (property_getAttributes (NULL) != NULL)
56 /* The GNU runtime doesn't support looking up properties at
60 objc_property_t property;
62 property = class_getProperty (objc_getClass ("MySubClass"), "propertyA");
63 if (std::strcmp (property_getAttributes (property),
64 "T@,GgetP,SsetP:,VpropertyA") != 0)
67 property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
68 if (std::strcmp (property_getAttributes (property),
69 "T@,N,VpropertyB") != 0)
75 std::cout << "Testing property_getName () ...\n";
77 /* The Apple/NeXT runtime seems to crash on the following. */
78 #ifdef __GNU_LIBOBJC__
80 if (property_getName (NULL) != NULL)
84 /* The GNU runtime doesn't support looking up properties at
88 objc_property_t property;
90 property = class_getProperty (objc_getClass ("MySubClass"), "propertyA");
91 if (std::strcmp (property_getName (property), "propertyA") != 0)
94 property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
95 if (std::strcmp (property_getName (property), "propertyB") != 0)