Differences From Artifact [60799e33cc]:
- File tests/RuntimeTests.m — part of check-in [374e1a1bfa] at 2021-01-02 22:04:26 on branch trunk — Update copyright (user: js, size: 2575) [annotate] [blame] [check-ins using] [more...]
To Artifact [20a13fa2e0]:
- File
tests/RuntimeTests.m
— part of check-in
[14f1e22d79]
at
2021-05-08 23:22:59
on branch trunk
— tests: Align more with ObjFW style
ObjFW's style changed over the years, but the tests were never adjusted
to it. (user: js, size: 2635) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
13 14 15 16 17 18 19 | * file. */ #include "config.h" #import "TestsAppDelegate.h" | | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | * file. */ #include "config.h" #import "TestsAppDelegate.h" static OFString *const module = @"Runtime"; @interface OFObject (SuperTest) - (id)superTest; @end @interface RuntimeTest: OFObject { |
︙ | ︙ | |||
59 60 61 62 63 64 65 | } @end @implementation TestsAppDelegate (RuntimeTests) - (void)runtimeTests { void *pool = objc_autoreleasePoolPush(); | | | | | | | | | | | | > | | > | | | | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | } @end @implementation TestsAppDelegate (RuntimeTests) - (void)runtimeTests { void *pool = objc_autoreleasePoolPush(); RuntimeTest *test = [[[RuntimeTest alloc] init] autorelease]; OFString *string, *foo; #ifdef OF_OBJFW_RUNTIME int classID; uintmax_t value; id object; #endif EXPECT_EXCEPTION(@"Calling a non-existent method via super", OFNotImplementedException, [test superTest]) TEST(@"Calling a method via a super with self == nil", [test nilSuperTest] == nil) string = [OFMutableString stringWithString: @"foo"]; foo = @"foo"; test.foo = string; TEST(@"copy, nonatomic properties", [test.foo isEqual: foo] && test.foo != foo && test.foo.retainCount == 1) test.bar = string; TEST(@"retain, atomic properties", test.bar == string && string.retainCount == 3) #ifdef OF_OBJFW_RUNTIME if (sizeof(uintptr_t) == 8) value = 0xDEADBEEFDEADBEF; else if (sizeof(uintptr_t) == 4) value = 0xDEADBEF; else abort(); TEST(@"Tagged pointers", objc_registerTaggedPointerClass([OFString class]) != -1 && (classID = objc_registerTaggedPointerClass([OFNumber class])) != -1 && (object = objc_createTaggedPointer(classID, (uintptr_t)value)) && object_getClass(object) == [OFNumber class] && [object class] == [OFNumber class] && object_getTaggedPointerValue(object) == value && objc_createTaggedPointer(classID, UINTPTR_MAX >> 4) != nil && objc_createTaggedPointer(classID, (UINTPTR_MAX >> 4) + 1) == nil) #endif objc_autoreleasePoolPop(pool); } @end |