1
0
Fork 0

[#25] Refactored quickVisChangeTest to share code between each of the member test cases

closure/master
Mike Gerwitz 2011-10-29 10:08:08 -04:00
parent 3c676de55d
commit 08cb663833
3 changed files with 67 additions and 54 deletions

View File

@ -44,34 +44,21 @@ require( 'common' ).testCase(
this.quickVisChangeTest = function( start, override, failtest ) this.quickVisChangeTest = function( start, override, failtest )
{ {
var name = 'foo', shared.quickVisChangeTest.call( _self, start, override, failtest,
function( name, startobj, overrideobj )
{
startobj.virtual = true;
overrideobj.override = true;
startobj = { 'virtual': true }, _self.sut.validateMethod(
overrideobj = { 'override': true } name,
; function() {},
overrideobj,
startobj[ start ] = true; { member: function() {} },
overrideobj[ override ] = true; startobj
);
var testfun = function() }
{ );
_self.sut.validateMethod(
name,
function() {},
overrideobj,
{ member: function() {} },
startobj
);
};
if ( failtest )
{
this.quickFailureTest( name, 'de-escalate', testfun );
}
else
{
_self.assertDoesNotThrow( testfun, Error );
}
}; };
}, },

View File

@ -29,6 +29,8 @@ require( 'common' ).testCase(
{ {
caseSetUp: function() caseSetUp: function()
{ {
var _self = this;
this.quickFailureTest = shared.quickFailureTest; this.quickFailureTest = shared.quickFailureTest;
this.quickKeywordPropTest = function( keywords, identifier, prev ) this.quickKeywordPropTest = function( keywords, identifier, prev )
@ -40,33 +42,16 @@ require( 'common' ).testCase(
this.quickVisChangeTest = function( start, override, failtest ) this.quickVisChangeTest = function( start, override, failtest )
{ {
var _self = this, shared.quickVisChangeTest.call( _self, start, override, failtest,
name = 'foo', function( name, startobj, overrideobj )
{
startobj = {}, _self.sut.validateProperty(
overrideobj = {} name, 'bar', overrideobj,
; { member: 'foo' },
startobj
startobj[ start ] = true; );
overrideobj[ override ] = true; }
);
var testfun = function()
{
_self.sut.validateProperty(
name, 'bar', overrideobj,
{ member: 'foo' },
startobj
);
};
if ( failtest )
{
this.quickFailureTest( name, 'de-escalate', testfun );
}
else
{
_self.assertDoesNotThrow( testfun, Error );
}
}; };
}, },

View File

@ -147,3 +147,44 @@ exports.visEscalationTest = function( test )
} }
}; };
/**
* Performs a simple visibility change test using access modifiers
*
* Important: invoke within the context of the test case.
*
* @param {string} start start keyword
* @param {string} override overriding keyword
* @param {bool} failtest whether the assertion should test for failure
*
* @param {function()} func test function
*
* @return {undefined}
*/
exports.quickVisChangeTest = function( start, override, failtest, func )
{
var _self = this,
name = 'foo',
startobj = {},
overrideobj = {}
;
startobj[ start ] = true;
overrideobj[ override ] = true;
var testfun = function()
{
func( name, startobj, overrideobj );
};
if ( failtest )
{
this.quickFailureTest( name, 'de-escalate', testfun );
}
else
{
_self.assertDoesNotThrow( testfun, Error );
}
};