1
0
Fork 0

Transferred method __super() invocation test to MethodWrappersTest (#25)

closure/master
Mike Gerwitz 2011-09-02 22:55:10 -04:00
parent 40d555ee3f
commit 5937f7b0be
2 changed files with 49 additions and 45 deletions

View File

@ -29,6 +29,55 @@ var common = require( './common' ),
;
/**
* The __super property is defined for method overrides and permits invoking the
* overridden method (method of the supertype).
*
* In this test, we are not looking to assert that __super matches the super
* method. Rather, we want to ensure it /invokes/ it. This is because the super
* method may be wrapped to provide additional functionality. We don't know, we
* don't care. We just want to make sure it's functioning properly.
*/
( function testOverridenMethodShouldContainReferenceToSuperMethod()
{
var orig_called = false,
getInst = function() {},
// "super" method
method = sut.standard.wrapNew(
function()
{
orig_called = true;
},
null, 0, getInst
),
// override method
override = sut.standard.wrapOverride(
function()
{
assert.notEqual(
this.__super,
undefined,
"__super is defined for overridden method"
);
this.__super();
assert.equal(
orig_called,
true,
"Invoking __super calls super method"
);
},
method, 0, getInst
)
;
// invoke the method to run the above assertions
override();
} )();
/**
* If the method is called when bound to a different context (e.g. for
* protected/private members), __super may not be properly bound.

View File

@ -238,51 +238,6 @@ mb_common.assertCommon();
} )();
/**
* The __super property is defined for method overrides and permits invoking the
* overridden method (method of the supertype).
*
* In this test, we are not looking to assert that __super matches the super
* method. Rather, we want to ensure it /invokes/ it. This is because the super
* method may be wrapped to provide additional functionality. We don't know, we
* don't care. We just want to make sure it's functioning properly.
*/
( function testOverridenMethodShouldContainReferenceToSuperMethod()
{
var orig_called = false;
// "super" method
mb_common.value = function()
{
orig_called = true;
};
mb_common.buildMemberQuick( { 'virtual': true } );
// override method
mb_common.value = function()
{
assert.notEqual(
this.__super,
undefined,
"__super is defined for overridden method"
);
this.__super();
assert.equal(
orig_called,
true,
"Invoking __super calls super method"
);
};
mb_common.buildMemberQuick( { 'override': true }, true );
// invoke the method
mb_common.members[ 'public' ][ mb_common.name ]();
} )();
/**
* Once a concrete implementation has been defined for a method, a subtype
* cannot make it abstract.