1 // TEST_CONFIG MEM=arc,mrc CC=clang LANGUAGE=objc,objc++
2 // TEST_CFLAGS -framework Foundation
4 #import <Foundation/Foundation.h>
5 #import <Foundation/NSDictionary.h>
6 #import <objc/runtime.h>
7 #import <objc/objc-abi.h>
14 #if __has_feature(objc_bool) // placeholder until we get a more precise macro.
15 NSArray *array = @[ @1, @2, @YES, @NO, @"Hello", @"World" ];
16 testassert([array count] == 6);
17 NSDictionary *dict = @{ @"Name" : @"John Q. Public", @"Age" : @42 };
18 testassert([dict count] == 2);
19 NSDictionary *numbers = @{ @"π" : @M_PI, @"e" : @M_E };
20 testassert([[numbers objectForKey:@"π"] doubleValue] == M_PI);
21 testassert([[numbers objectForKey:@"e"] doubleValue] == M_E);
28 [NSNumber numberWithBool:YES],
35 [NSNumber numberWithBool:NO],
40 NSData * jsonData = [NSJSONSerialization dataWithJSONObject:array options:0 error:nil];
41 NSString * string = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
43 testassert([string isEqualToString:@"[true,true,true,true,true,true,false,false,false,false,false,false]"]);
45 // C99 @(true) and @(false) evaluate to @(1) and @(0).
46 testassert([string isEqualToString:@"[1,true,true,true,true,true,0,false,false,false,false,false]"]);