1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LLVM_LICENSE_HEADER@ 5 */ 6 7// 8// copyproperty.m 9// bocktest 10// 11// Created by Blaine Garst on 3/21/08. 12// Copyright 2008 __MyCompanyName__. All rights reserved. 13// 14// TEST_CFLAGS -framework Foundation 15 16#import <Foundation/Foundation.h> 17#import <stdio.h> 18#import "test.h" 19 20@interface TestObject : NSObject { 21 long (^getInt)(void); 22} 23@property(copy) long (^getInt)(void); 24@end 25 26@implementation TestObject 27@synthesize getInt; 28@end 29 30@interface CountingObject : NSObject 31@end 32 33int Retained = 0; 34 35@implementation CountingObject 36- (id) retain { 37 Retained = 1; 38 return [super retain]; 39} 40@end 41 42int main() { 43 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 44 TestObject *to = [[TestObject alloc] init]; 45 CountingObject *co = [[CountingObject alloc] init]; 46 long (^localBlock)(void) = ^{ return 10L + (long)[co self]; }; 47 to.getInt = localBlock; 48 if (localBlock == to.getInt) { 49 fail("block property not copied!!"); 50 } 51 if (!objc_collectingEnabled() && Retained == 0) { 52 fail("didn't copy block import"); 53 } 54 55 [pool drain]; 56 57 succeed(__FILE__); 58} 59