mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Fixed: objj_msgSend_reset not resetting with fast objj_msgSend.
Refs #2103.
This commit is contained in:
@@ -58,6 +58,17 @@ GLOBAL(objj_msgSend_reset) = function()
|
||||
objj_msgSendFast1 = objj_msgSendFast1_original;
|
||||
objj_msgSendFast2 = objj_msgSendFast2_original;
|
||||
objj_msgSendFast3 = objj_msgSendFast3_original;
|
||||
|
||||
objj_enumerateClassesUsingBlock(function(aClass) {
|
||||
if (aClass.hasOwnProperty("objj_msgSend"))
|
||||
{
|
||||
aClass.objj_msgSend = objj_msgSendFast;
|
||||
aClass.objj_msgSend0 = objj_msgSendFast0;
|
||||
aClass.objj_msgSend1 = objj_msgSendFast1;
|
||||
aClass.objj_msgSend2 = objj_msgSendFast2;
|
||||
aClass.objj_msgSend3 = objj_msgSendFast3;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// decorate both objj_msgSend and objj_msgSendSuper
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
var SEEN_MESSAGES = [];
|
||||
|
||||
objj_test_decorator = function(msgSend)
|
||||
{
|
||||
return function(aReceiverOrSuper, aSelector)
|
||||
{
|
||||
if (aSelector === @selector(intify:))
|
||||
SEEN_MESSAGES.push([aReceiverOrSuper, aSelector]);
|
||||
return msgSend.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
@implementation TestClass0 : CPObject
|
||||
|
||||
- (CPInteger)intify:(CPInteger)anInput
|
||||
{
|
||||
return anInput * 2; // now twice as int
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation TestClass1 : CPObject
|
||||
|
||||
- (CPInteger)intify:(CPInteger)anInput
|
||||
{
|
||||
return anInput * 2; // now twice as int
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation DebugTest : OJTestCase
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
SEEN_MESSAGES = [];
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
objj_msgSend_reset();
|
||||
}
|
||||
|
||||
- (void)test_objj_msgSend_decorate_should_replace_fast_msgSend_for_unitialised_class
|
||||
{
|
||||
objj_msgSend_decorate(objj_test_decorator);
|
||||
var a = [TestClass0 new];
|
||||
[self assert:[a intify:3] equals:6];
|
||||
[self assert:SEEN_MESSAGES equals:[[a, @selector(intify:)]]];
|
||||
}
|
||||
|
||||
- (void)test_objj_msgSend_decorate_should_replace_fast_msgSend_for_initialised_class
|
||||
{
|
||||
var a = [TestClass1 new];
|
||||
[a intify:5];
|
||||
|
||||
objj_msgSend_decorate(objj_test_decorator);
|
||||
[self assert:[a intify:3] equals:6];
|
||||
[self assert:SEEN_MESSAGES equals:[[a, @selector(intify:)]]];
|
||||
}
|
||||
|
||||
- (void)test_objj_msgSend_reset_should_reset
|
||||
{
|
||||
objj_msgSend_decorate(objj_test_decorator);
|
||||
var a = [TestClass1 new];
|
||||
[self assert:[a intify:3] equals:6];
|
||||
objj_msgSend_reset();
|
||||
[self assert:[a intify:3] equals:6];
|
||||
[self assert:SEEN_MESSAGES equals:[[a, @selector(intify:)]]];
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user