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