Added CPObject's performSelector:withObject: and tests

This commit is contained in:
Randall Luecke committed 2012-01-31 16:35:49 -05:00
1 parent 66fcbe7871
commit 7dc213995c
2 files changed
+34

No files matched your search

+12
View File
@@ -329,6 +329,18 @@ CPLog(@"Got some class: %@", inst);
return objj_msgSend(self, aSelector, anObject, anotherObject);
}
/*!
Sends the specified message to the reciever, with any number of arguments.
@param aSelector the message to send
@param anObject... comma seperated objects to pass to the selector
@return the return value of the message
*/
- (id)performSelector:(SEL)aSelector withObjects:(id)anObject, ...
{
var params = [self, aSelector].concat(Array.prototype.slice.apply(arguments, [3]));
return objj_msgSend.apply(this, params);
}
- (id)forwardingTargetForSelector:(SEL)aSelector
{
return nil;
+22
View File
@@ -33,6 +33,23 @@
[self assert:[CPObject version] equals:newVersion];
}
- (void)testMultipleArgumentPerformSelector
{
var receiver = [[Receiver alloc] init];
var value1 = "a",
value2 = "b",
value3 = "c",
value4 = "d",
selector = @selector(implements:multiple:argument:selector:);
var returnValue = [receiver performSelector:selector withObjects:value1, value2, value3, value4];
var expectedReturnValue = value1 + value2 + value3 + value4;
[self assertTrue:expectedReturnValue === returnValue];
}
@end
@implementation SuperReceiver : CPObject
@@ -59,4 +76,9 @@
- (void)implementedInReceiverOnly
{
}
- (id)implements:(id)a multiple:(id)b argument:(id)c selector:(id)d
{
return a + b + c + d;
}
@end