1 /* Test for handling of struct-returning methods. */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
5 #include <objc/Object.h>
7 extern void abort(void);
8 #define CHECK_IF(expr) if(!(expr)) abort()
12 } globa = { 1.0, 2.0 };
15 float a, b, c, d, e, f;
16 } globb = { 1, 2, 3, 4, 5, 6 };
18 @interface foo : Object
19 - (struct astruct) stret;
20 - (struct bstruct) stretb;
23 @implementation foo : Object
24 - (struct astruct) stret { return globa; }
25 - (struct bstruct) stretb { return globb; }
29 - (struct astruct) stret;
30 - (struct bstruct) stretb;
34 - (struct astruct) stret { struct astruct a = [super stret]; a.b = 77; return a; }
35 - (struct bstruct) stretb { struct bstruct b = [super stretb]; b.e = 99; return b; }
41 bar *obj2 = [bar new];
42 struct astruct loc, loc2;
43 struct bstruct locb, locb2;
46 CHECK_IF(loc.a == 1.0 && loc.b == 2.0);
49 CHECK_IF(locb.f == 6 && locb.c == 3);
50 CHECK_IF(locb.e == 5 && locb.b == 2);
51 CHECK_IF(locb.d == 4 && locb.a == 1);
54 CHECK_IF(loc2.a == 1.0 && loc2.b == 77);
56 locb2 = [obj2 stretb];
57 CHECK_IF(locb2.f == 6 && locb2.c == 3);
58 CHECK_IF(locb2.e == 99 && locb2.b == 2);
59 CHECK_IF(locb2.d == 4 && locb2.a == 1);