1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LLVM_LICENSE_HEADER@ 5 */ 6 7// TEST_CONFIG 8 9#import <stdio.h> 10#import <Block.h> 11#import "test.h" 12 13int global; 14 15void (^gblock)(int) = ^(int x){ global = x; }; 16 17int main() { 18 gblock(1); 19 if (global != 1) { 20 fail("did not set global to 1"); 21 } 22 void (^gblockcopy)(int) = Block_copy(gblock); 23 if (gblockcopy != gblock) { 24 fail("global copy %p not a no-op %p", (void *)gblockcopy, (void *)gblock); 25 } 26 Block_release(gblockcopy); 27 gblock(3); 28 if (global != 3) { 29 fail("did not set global to 3"); 30 } 31 gblockcopy = Block_copy(gblock); 32 gblockcopy(5); 33 if (global != 5) { 34 fail("did not set global to 5"); 35 } 36 37 succeed(__FILE__); 38} 39 40