Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -28,11 +28,34 @@ #import ], [ id n = nil; for (id i in n); ], [ - AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1, [Fast Enumeration support]) + AC_DEFINE(OF_HAVE_FAST_ENUMERATION, 1, + [Compiler support for Fast Enumeration]) + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no)]) + +AC_MSG_CHECKING(whether Objective C compiler supports properties) +AC_TRY_COMPILE([ + #import + + @interface Foo + { + id bar; + } + + @property (retain, nonatomic) id bar; + @end + ], [ + Foo *foo = nil; + [foo setBar: nil]; + [foo bar]; + ], [ + AC_DEFINE(OF_HAVE_PROPERTIES, 1, [Compiler support for properties]) + AC_SUBST(PROPERTIES_M, "properties.m") AC_MSG_RESULT(yes) ], [ AC_MSG_RESULT(no)]) AC_MSG_CHECKING(which Objective C runtime we use) Index: extra.mk.in ================================================================== --- extra.mk.in +++ extra.mk.in @@ -1,9 +1,10 @@ ASPRINTF_M = @ASPRINTF_M@ OBJC_PROPERTIES_M = @OBJC_PROPERTIES_M@ OBJC_SYNC_M = @OBJC_SYNC_M@ OFPLUGIN_M = @OFPLUGIN_M@ OFTHREAD_M = @OFTHREAD_M@ +PROPERTIES_M = @PROPERTIES_M@ TESTPLUGIN = @TESTPLUGIN@ TESTS = @TESTS@ TEST_LAUNCHER = @TEST_LAUNCHER@ THREADING_H = @THREADING_H@ Index: tests/Makefile ================================================================== --- tests/Makefile +++ tests/Makefile @@ -13,11 +13,12 @@ OFString.m \ OFTCPSocket.m \ ${OFTHREAD_M} \ OFXMLElement.m \ OFXMLParser.m \ - main.m + main.m \ + ${PROPERTIES_M} IPHONE_USER = mobile IPHONE_TMP = /tmp/objfw-test .PHONY: run run-tests run-on-iphone Index: tests/main.m ================================================================== --- tests/main.m +++ tests/main.m @@ -26,10 +26,13 @@ extern void list_tests(); extern void object_tests(); #ifdef OF_PLUGINS extern void plugin_tests(); #endif +#ifdef OF_HAVE_PROPERTIES +extern void properties_tests(); +#endif extern void string_tests(); extern void tcpsocket_tests(); #ifdef OF_THREADS extern void thread_tests(); #endif @@ -112,9 +115,12 @@ #endif xmlelement_tests(); xmlparser_tests(); #ifdef OF_PLUGINS plugin_tests(); +#endif +#ifdef OF_HAVE_PROPERTIES + properties_tests(); #endif return fails; } ADDED tests/properties.m Index: tests/properties.m ================================================================== --- tests/properties.m +++ tests/properties.m @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2008 - 2009 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE included in + * the packaging of this file. + */ + +#include "config.h" + +#import "OFString.h" +#import "OFAutoreleasePool.h" + +#import "main.h" + +static OFString *module = @"Properties"; + +@interface PropertiesTest: OFObject +{ + OFString *foo; + OFString *bar; +} + +@property (copy, nonatomic) OFString *foo; +@property (retain) OFString *bar; +@end + +@implementation PropertiesTest +@synthesize foo; +@synthesize bar; + +- (void)dealloc +{ + [foo release]; + [bar release]; + + [super dealloc]; +} +@end + +void +properties_tests() +{ + OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; + PropertiesTest *pt = [[[PropertiesTest alloc] init] autorelease]; + OFString *t = [OFMutableString stringWithString: @"foo"]; + + [pt setFoo: t]; + TEST(@"copy, nonatomic", [[pt foo] isEqual: @"foo"] && + [pt foo] != @"foo" && [[pt foo] retainCount] == 1) + + [pt setBar: t]; + TEST(@"retain, atomic", [pt bar] == t && [t retainCount] == 3) + + [pool drain]; +}