Passing base set instead of TestCase instance to Set subtypes

master
Mike Gerwitz 2012-03-04 08:05:12 -05:00
parent 9923388cce
commit 216231b888
4 changed files with 12 additions and 18 deletions

View File

@ -93,7 +93,7 @@ rectest.TestRunner = Class( 'TestRunner',
var _self = this,
run = this._setFactory.fromId( options.ralgo,
test_case, options
test_case.getSet( options.set ), options
);
// allow test case to initialize its display

View File

@ -7,12 +7,6 @@ rectest.set.RandomGroupedSet = Class( 'RandomGroupedSet' )
.implement( rectest.set.Set )
.extend(
{
/**
* Test case being executed
* @var {TestCase}
*/
'private _case': null,
/**
* Number of samples remaining
* @var {number}
@ -38,10 +32,9 @@ rectest.set.RandomGroupedSet = Class( 'RandomGroupedSet' )
'private _setPos': 0,
__construct: function( test_case, options )
__construct: function( base_set, options )
{
this._case = test_case;
this._set = test_case.getSet( options.set );
this._set = base_set;
this._setLength = this._set.length;
this._samplesRemain = +options.samples || -1;

View File

@ -3,7 +3,13 @@
*/
rectest.set.Set = Interface( 'Set',
{
__construct: [ 'test_case', 'options' ],
/**
* Create a new set from a base set and the given options
*
* @param {Array.<string>} base_set base set
* @param {Object} options configuration options
*/
__construct: [ 'base_set', 'options' ],
/**

View File

@ -3,20 +3,15 @@
*/
rectest.set.SetFactory = Class( 'SetFactory',
{
'public fromId': function( id, test_case, options )
'public fromId': function( id, base_set, options )
{
var sets = rectest.set;
if ( !( Class.isA( rectest.TestCase, test_case ) ) )
{
throw TypeError( "Invalid test case: " + test_case );
}
return [
null,
sets.RandomGroupedSet,
null,
null
][ id ]( test_case, options );
][ id ]( base_set, options );
}
} );