Overview
Comment: | Test if compiler supports properties and if so run property tests. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
df5b90cf6aa5bd0f6878a6a2ca14169e |
User & Date: | js on 2010-01-16 13:37:43 |
Other Links: | manifest | tags |
Context
2010-01-16
| ||
13:38 | Add missing file to Xcode project. check-in: 632e991fba user: js tags: trunk | |
13:37 | Test if compiler supports properties and if so run property tests. check-in: df5b90cf6a user: js tags: trunk | |
13:20 | Make properties behave like with the Apple runtime. check-in: aac3aaf9cc user: js tags: trunk | |
Changes
Modified configure.ac from [ebbb31ec3b] to [37277c7aeb].
︙ | ︙ | |||
26 27 28 29 30 31 32 | AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration) AC_TRY_COMPILE([ #import <objc/objc.h> ], [ id n = nil; for (id i in n); ], [ | | > > > > > > > > > > > > > > > > > > > > > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | AC_MSG_CHECKING(whether Objective C compiler supports fast enumeration) AC_TRY_COMPILE([ #import <objc/objc.h> ], [ id n = nil; for (id i in n); ], [ 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 <objc/objc.h> @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) dnl TODO: This is ugly. Let's think of a better check. AC_EGREP_CPP(gnu, [ |
︙ | ︙ |
Modified extra.mk.in from [5cf2a3c0d7] to [8ecacc23d3].
1 2 3 4 5 6 7 8 9 | ASPRINTF_M = @ASPRINTF_M@ OBJC_PROPERTIES_M = @OBJC_PROPERTIES_M@ OBJC_SYNC_M = @OBJC_SYNC_M@ OFPLUGIN_M = @OFPLUGIN_M@ OFTHREAD_M = @OFTHREAD_M@ TESTPLUGIN = @TESTPLUGIN@ TESTS = @TESTS@ TEST_LAUNCHER = @TEST_LAUNCHER@ THREADING_H = @THREADING_H@ | > | 1 2 3 4 5 6 7 8 9 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@ |
Modified tests/Makefile from [e320f93bcd] to [115dc5e677].
︙ | ︙ | |||
11 12 13 14 15 16 17 | OFObject.m \ ${OFPLUGIN_M} \ OFString.m \ OFTCPSocket.m \ ${OFTHREAD_M} \ OFXMLElement.m \ OFXMLParser.m \ | | > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | OFObject.m \ ${OFPLUGIN_M} \ OFString.m \ OFTCPSocket.m \ ${OFTHREAD_M} \ OFXMLElement.m \ OFXMLParser.m \ main.m \ ${PROPERTIES_M} IPHONE_USER = mobile IPHONE_TMP = /tmp/objfw-test .PHONY: run run-tests run-on-iphone run: all if [ -z "${DONT_RUN_TESTS}" ]; then ${MAKE} ${MFLAGS} run-tests; fi |
︙ | ︙ |
Modified tests/main.m from [7efaf05c3f] to [6d0cbb749a].
︙ | ︙ | |||
24 25 26 27 28 29 30 31 32 33 34 35 36 37 | extern void dictionary_tests(); extern void hashes_tests(); extern void list_tests(); extern void object_tests(); #ifdef OF_PLUGINS extern void plugin_tests(); #endif extern void string_tests(); extern void tcpsocket_tests(); #ifdef OF_THREADS extern void thread_tests(); #endif extern void xmlelement_tests(); extern void xmlparser_tests(); | > > > | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | extern void dictionary_tests(); extern void hashes_tests(); 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 extern void xmlelement_tests(); extern void xmlparser_tests(); |
︙ | ︙ | |||
110 111 112 113 114 115 116 117 118 119 120 | #ifdef OF_THREADS thread_tests(); #endif xmlelement_tests(); xmlparser_tests(); #ifdef OF_PLUGINS plugin_tests(); #endif return fails; } | > > > | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | #ifdef OF_THREADS thread_tests(); #endif xmlelement_tests(); xmlparser_tests(); #ifdef OF_PLUGINS plugin_tests(); #endif #ifdef OF_HAVE_PROPERTIES properties_tests(); #endif return fails; } |
Added tests/properties.m version [42cc65144e].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | /* * Copyright (c) 2008 - 2009 * Jonathan Schleifer <js@webkeks.org> * * 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]; } |