Differences From Artifact [9b26ed0393]:
- File
tests/OFBlockTests.m
— part of check-in
[2a27cf3000]
at
2016-01-03 00:41:26
on branch trunk
— Update copyright
While at it, also update the mail address. (user: js, size: 2089) [annotate] [blame] [check-ins using] [more...]
To Artifact [854568a763]:
- File
tests/OFBlockTests.m
— part of check-in
[dbb706d21e]
at
2016-10-15 13:49:18
on branch trunk
— OFBlock: Set (*dst)->forwarding after memcpy()
Setting it before the memcpy() meant it was effectively a nop.
This also improves on the tests to catch this in the future. (user: js, size: 2349) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
31 32 33 34 35 36 37 38 39 40 41 42 43 | static OFString *module = @"OFBlock"; extern void *_NSConcreteStackBlock; extern void *_NSConcreteGlobalBlock; extern void *_NSConcreteMallocBlock; static void (^g)() = ^ {}; @implementation TestsAppDelegate (OFBlockTests) - (void)blockTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; __block int x; | > > > > > > > > | | > > > > | 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | static OFString *module = @"OFBlock"; extern void *_NSConcreteStackBlock; extern void *_NSConcreteGlobalBlock; extern void *_NSConcreteMallocBlock; static void (^g)() = ^ {}; static int (^returnStackBlock(void))(void) { __block int i = 0; return Block_copy(^ int { return ++i; }); } @implementation TestsAppDelegate (OFBlockTests) - (void)blockTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; __block int x; void (^s)(void) = ^ { x = 0; }; void (^m)(void); int (^v)(void); TEST(@"Class of stack block", (Class)&_NSConcreteStackBlock == objc_getClass("OFStackBlock") && [s isKindOfClass: [OFBlock class]]) TEST(@"Class of global block", (Class)&_NSConcreteGlobalBlock == objc_getClass("OFGlobalBlock") && [g isKindOfClass: [OFBlock class]]) TEST(@"Class of a malloc block", (Class)&_NSConcreteMallocBlock == objc_getClass("OFMallocBlock")) TEST(@"Copying a stack block", (m = [[s copy] autorelease]) && [m class] == objc_getClass("OFMallocBlock") && [m isKindOfClass: [OFBlock class]]) TEST(@"Copying a stack block and using its variable", (v = returnStackBlock()) && v() == 1 && v() == 2 && v() == 3) TEST(@"Copying a global block", (id)g == [[g copy] autorelease]) TEST(@"Copying a malloc block", (id)m == [m copy] && [m retainCount] == 2) TEST(@"Autorelease a stack block", R([s autorelease])) |
︙ | ︙ |