From 5937f7b0be5f6c71718071ea1d4fa8027d6e426b Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Fri, 2 Sep 2011 22:55:10 -0400 Subject: [PATCH] Transferred method __super() invocation test to MethodWrappersTest (#25) --- test/MethodWrappersTest.js | 49 ++++++++++++++++++++++++++++++ test/test-member_builder-method.js | 45 --------------------------- 2 files changed, 49 insertions(+), 45 deletions(-) diff --git a/test/MethodWrappersTest.js b/test/MethodWrappersTest.js index fba575c..a3d03bd 100644 --- a/test/MethodWrappersTest.js +++ b/test/MethodWrappersTest.js @@ -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. diff --git a/test/test-member_builder-method.js b/test/test-member_builder-method.js index 111b739..1e6f216 100644 --- a/test/test-member_builder-method.js +++ b/test/test-member_builder-method.js @@ -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.