ObjFW  Check-in [2ee3da6551]

Overview
Comment:Migrate RuntimeARCTests to ObjFWTest
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | objfwtest
Files: files | file ages | folders
SHA3-256: 2ee3da6551b76536c144cd46937a56b29e7d7e2007d6d3dc67bc7d65161c9294
User & Date: js on 2024-02-17 19:18:47
Other Links: branch diff | manifest | tags
Context
2024-02-17
19:35
Migrate RuntimeTests to ObjFWTest check-in: 2ffd3b79f9 user: js tags: objfwtest
19:18
Migrate RuntimeARCTests to ObjFWTest check-in: 2ee3da6551 user: js tags: objfwtest
18:19
ObjFWTest: Improve format for redirected output check-in: 5e89084e60 user: js tags: objfwtest
Changes

Modified configure.ac from [6a93c0743b] to [42a640d48b].

735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
735
736
737
738
739
740
741

742
743
744
745
746
747
748







-







		@end
	], [[
		__weak id foo = [Foo alloc];
		(void)foo;
	]])
], [
	AC_MSG_RESULT(yes)
	AC_DEFINE(COMPILER_SUPPORTS_ARC, 1, [Whether the compiler supports ARC])
	AC_SUBST(RUNTIME_ARC_TESTS_M, RuntimeARCTests.m)
], [
	AC_MSG_RESULT(no)
])
OBJCFLAGS="$old_OBJCFLAGS"

AC_C_BIGENDIAN([

Modified new_tests/Makefile from [6cd451cc4e] to [586e99b48d].

40
41
42
43
44
45
46

47
48
49
50
51
52
53
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54







+







       OFPBKDF2Tests.m			\
       OFPropertyListTests.m		\
       OFScryptTests.m			\
       OFSetTests.m			\
       OFStringTests.m			\
       OFSystemInfoTests.m		\
       OFUTF8StringTests.m		\
       ${RUNTIME_ARC_TESTS_M}		\
       ${USE_SRCS_PLUGINS}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_SUBPROCESSES}		\
       ${USE_SRCS_THREADS}		\
       testfile_bin.m			\
       testfile_ini.m
SRCS_PLUGINS = OFPluginTests.m
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203
204
205
206
207
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209







+












CPPFLAGS += -I../src				\
	    -I../src/exceptions			\
	    -I../src/runtime			\
	    -I../src/test			\
	    -I..				\
	    -DOBJFWTEST_LOCAL_INCLUDES		\
	    -DPROG_SUFFIX=\"${PROG_SUFFIX}\"
OBJCFLAGS_RuntimeARCTests.m = -fobjc-arc -fobjc-arc-exceptions
# Repetition is required for Wii U, as otherwise it cannot find main. Just
# moving -lobjfwtest later doesn't work either, as then the linker cannot find
# ObjFW symbols. So the only solution is to list everything twice.
LIBS := -L../src/test	\
	-lobjfwtest	\
	${TESTS_LIBS}	\
	${LIBS}		\
	-lobjfwtest	\
	${TESTS_LIBS}	\
	${LIBS}
LDFLAGS += ${MAP_LDFLAGS}
LD = ${OBJC}

Renamed and modified tests/RuntimeARCTests.m [464cdbc085] to new_tests/RuntimeARCTests.m [685be12c90].

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
60
61
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
60
61
62
63

























-
+
+

-
+
+

-
+


-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


















-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "TestsAppDelegate.h"
#import "ObjFW.h"
#import "ObjFWTest.h"

static OFString *const module = @"Runtime (ARC)";
@interface RuntimeARCTests: OTTestCase
@end

@interface RuntimeARCTest: OFObject
@interface RuntimeARCTestClass: OFObject
@end

@implementation RuntimeARCTest
@implementation RuntimeARCTests
- (void)testExceptionsDuringInit
{
	OTAssertThrows((void)[[RuntimeARCTestClass alloc] init]);
}

- (void)testWeakReferences
{
	id object = [[OFObject alloc] init];
	__weak id weak = object;

	OTAssertEqual(weak, object);

	object = nil;
	OTAssertNil(weak);
}
@end

@implementation RuntimeARCTestClass
- (instancetype)init
{
	self = [super init];

#if defined(OF_WINDOWS) && defined(OF_AMD64)
	/*
	 * Clang has a bug on Windows where it creates an invalid call into
	 * objc_retainAutoreleasedReturnValue(). Work around it by not using an
	 * autoreleased exception.
	 */
	@throw [[OFException alloc] init];
#else
	@throw [OFException exception];
#endif

	return self;
}
@end

@implementation TestsAppDelegate (RuntimeARCTests)
- (void)runtimeARCTests
{
	id object;
	__weak id weak;

	EXPECT_EXCEPTION(@"Exceptions in init", OFException,
	    object = [[RuntimeARCTest alloc] init])

	object = [[OFObject alloc] init];
	weak = object;
	TEST(@"weakly referencing an object", weak == object)

	object = nil;
	TEST(@"weak references becoming nil", weak == nil)
}
@end

Modified tests/Makefile from [532ecb85cc] to [cda538f73b].

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
20
21
22
23
24
25
26

27
28
29
30
31
32
33







-







       OFNotificationCenterTests.m	\
       OFStreamTests.m			\
       OFValueTests.m			\
       OFXMLElementBuilderTests.m	\
       OFXMLNodeTests.m			\
       OFXMLParserTests.m		\
       RuntimeTests.m			\
       ${RUNTIME_ARC_TESTS_M}		\
       TestsAppDelegate.m		\
       ${USE_SRCS_FILES}		\
       ${USE_SRCS_SOCKETS}		\
       ${USE_SRCS_WINDOWS}
SRCS_SOCKETS = ${OF_HTTP_CLIENT_TESTS_M}	\
	       OFHTTPCookieTests.m		\
	       OFHTTPCookieManagerTests.m	\
149
150
151
152
153
154
155
156
157
158
159
148
149
150
151
152
153
154

155
156
157







-



	elf2rpl $< $@

CPPFLAGS += -I../src				\
	    -I../src/exceptions			\
	    -I../src/runtime			\
	    -I..				\
	    -DSTDOUT
OBJCFLAGS_RuntimeARCTests.m = -fobjc-arc -fobjc-arc-exceptions
LIBS := ${TESTS_LIBS} ${LIBS}
LDFLAGS += ${MAP_LDFLAGS}
LD = ${OBJC}

Modified tests/TestsAppDelegate.h from [6f8ca2ade5] to [745c6672fb].

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
95
96
97
98
99
100
101




102
103
104
105
106
107
108







-
-
-
-







- (void)notificationCenterTests;
@end

@interface TestsAppDelegate (RuntimeTests)
- (void)runtimeTests;
@end

@interface TestsAppDelegate (RuntimeARCTests)
- (void)runtimeARCTests;
@end

@interface TestsAppDelegate (OFStreamTests)
- (void)streamTests;
@end

@interface TestsAppDelegate (OFValueTests)
- (void)valueTests;
@end

Modified tests/TestsAppDelegate.m from [2f2d348e00] to [457f56b26a].

367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
367
368
369
370
371
372
373



374
375
376
377
378
379
380







-
-
-







#endif
#if defined(OF_WII) && defined(OF_HAVE_FILES)
	[[OFFileManager defaultManager]
	    changeCurrentDirectoryPath: @"/apps/objfw-tests"];
#endif

	[self runtimeTests];
#ifdef COMPILER_SUPPORTS_ARC
	[self runtimeARCTests];
#endif
	[self dataTests];
	[self dictionaryTests];
	[self listTests];
	[self valueTests];
	[self streamTests];
	[self memoryStreamTests];
	[self notificationCenterTests];