]> git.saurik.com Git - apple/objc4.git/blob - test/definitions.c
objc4-756.2.tar.gz
[apple/objc4.git] / test / definitions.c
1 // TEST_CONFIG
2
3 // DO NOT include anything else here
4 #include <objc/objc.h>
5 // DO NOT include anything else here
6 Class c = Nil;
7 SEL s;
8 IMP i;
9 id o = nil;
10 BOOL b = YES;
11 BOOL b2 = NO;
12 #if !__has_feature(objc_arc)
13 __strong void *p;
14 #endif
15 id __unsafe_unretained u;
16 #if __has_feature(objc_arc_weak)
17 id __weak w;
18 #endif
19
20 void fn(void) __unused;
21 void fn(void) {
22 id __autoreleasing a __unused;
23 }
24
25 // check type inference for blocks returning YES and NO (rdar://10118972)
26 BOOL (^block1)(void) = ^{ return YES; };
27 BOOL (^block2)(void) = ^{ return NO; };
28
29 #include "test.h"
30
31 int main()
32 {
33 testassert(YES);
34 testassert(!NO);
35 #if __cplusplus
36 testwarn("rdar://12371870 -Wnull-conversion");
37 testassert(!(bool)nil);
38 testassert(!(bool)Nil);
39 #else
40 testassert(!nil);
41 testassert(!Nil);
42 #endif
43
44 #if __has_feature(objc_bool)
45 // YES[array] is disallowed for objc just as true[array] is for C++
46 #else
47 // this will fail if YES and NO do not have enough parentheses
48 int array[2] = { 888, 999 };
49 testassert(NO[array] == 888);
50 testassert(YES[array] == 999);
51 #endif
52
53 succeed(__FILE__);
54 }