diff --git a/test/MemberBuilderValidator/MethodTest.js b/test/MemberBuilderValidator/MethodTest.js index ab9558c..bd3473e 100644 --- a/test/MemberBuilderValidator/MethodTest.js +++ b/test/MemberBuilderValidator/MethodTest.js @@ -287,20 +287,11 @@ require( 'common' ).testCase( */ 'Methods support visibility escalation or equality': function() { - var tests = [ - [ 'private', 'protected' ], - [ 'protected', 'public' ], - - [ 'public', 'public' ], - [ 'protected', 'protected' ], - [ 'private', 'private' ] - ]; - - for ( var i = 0, len = tests.length; i < len; i++ ) + var _self = this; + shared.visEscalationTest( function( cur ) { - var cur = tests[ i ]; - this.quickVisChangeTest( cur[ 0 ], cur[ 1 ], false ); - } + _self.quickVisChangeTest( cur[ 0 ], cur[ 1 ], false ); + } ); }, diff --git a/test/MemberBuilderValidator/inc-common.js b/test/MemberBuilderValidator/inc-common.js index 6128d1d..27adc0c 100644 --- a/test/MemberBuilderValidator/inc-common.js +++ b/test/MemberBuilderValidator/inc-common.js @@ -120,3 +120,30 @@ exports.quickKeywordTest = function( type, keywords, identifier, prev ) } }; + +/** + * Passes test visibility levels [ x1, x2 ] to test method T to ensure that test + * T will pass when x2 is used to override a member declared using x1 + * + * @param {function(function())} test test function + * + * @return {undefined} + */ +exports.visEscalationTest = function( test ) +{ + var tests = [ + [ 'private', 'protected' ], + [ 'protected', 'public' ], + + [ 'public', 'public' ], + [ 'protected', 'protected' ], + [ 'private', 'private' ] + ]; + + for ( var i = 0, len = tests.length; i < len; i++ ) + { + var cur = tests[ i ]; + test( cur ); + } +}; +