Differences From Artifact [f57b713faf]:
- File tests/ForwardingTests.m — part of check-in [813c00ccf0] at 2013-01-09 22:24:47 on branch trunk — Update copyright. (user: js, size: 2015) [annotate] [blame] [check-ins using]
To Artifact [d9a0d74b25]:
- File
tests/ForwardingTests.m
— part of check-in
[c5ef582958]
at
2013-03-04 17:20:15
on branch trunk
— Replace BOOL with bool.
The only places where BOOL is left are those where they are required by
the ABI. (user: js, size: 2030) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
19 20 21 22 23 24 25 | #import "OFString.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" static OFString *module = @"Forwarding"; static size_t forwardings = 0; | | | | | | | | | | | 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 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 | #import "OFString.h" #import "OFAutoreleasePool.h" #import "TestsAppDelegate.h" static OFString *module = @"Forwarding"; static size_t forwardings = 0; static bool success = false; @interface ForwardingTest: OFObject @end @interface ForwardingTest (Test) + (void)test; - (void)test; @end static void test(id self, SEL _cmd) { success = true; } @implementation ForwardingTest + (bool)resolveClassMethod: (SEL)selector { forwardings++; if (sel_isEqual(selector, @selector(test))) { [self replaceClassMethod: @selector(test) withImplementation: (IMP)test typeEncoding: "v#:"]; return true; } return false; } + (bool)resolveInstanceMethod: (SEL)selector { forwardings++; if (sel_isEqual(selector, @selector(test))) { [self replaceInstanceMethod: @selector(test) withImplementation: (IMP)test typeEncoding: "v@:"]; return true; } return false; } @end @implementation TestsAppDelegate (ForwardingTests) - (void)forwardingTests { OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init]; TEST(@"Forwarding a message and adding a class method", R([ForwardingTest test]) && success && R([ForwardingTest test]) && forwardings == 1); ForwardingTest *t = [[[ForwardingTest alloc] init] autorelease]; success = false; forwardings = 0; TEST(@"Forwarding a message and adding an instance method", R([t test]) && success && R([t test]) && forwardings == 1); [pool drain]; } @end |