Moved test runner to RandomGroupedSet and began offering option for different set randomization algorithms
parent
65f42c6ac4
commit
9923388cce
|
@ -24,9 +24,11 @@ rectest.RecTest = Class( 'RecTest',
|
|||
|
||||
__construct: function( jquery, cases )
|
||||
{
|
||||
this._jQuery = jquery;
|
||||
this._cases = cases;
|
||||
this._runner = rectest.TestRunner( jquery, rectest.TestRun );
|
||||
this._jQuery = jquery;
|
||||
this._cases = cases;
|
||||
this._runner = rectest.TestRunner(
|
||||
jquery, rectest.set.SetFactory()
|
||||
);
|
||||
},
|
||||
|
||||
|
||||
|
@ -98,7 +100,7 @@ rectest.RecTest = Class( 'RecTest',
|
|||
{
|
||||
var options = {},
|
||||
values = [
|
||||
'case', 'set', 'interval', 'blank', 'samples', 'delay'
|
||||
'case', 'set', 'ralgo', 'interval', 'blank', 'samples', 'delay'
|
||||
],
|
||||
i = values.length;
|
||||
|
||||
|
|
|
@ -15,6 +15,12 @@ rectest.TestRunner = Class( 'TestRunner',
|
|||
*/
|
||||
'private _TestRun': null,
|
||||
|
||||
/**
|
||||
* Produces sets from the given id
|
||||
* @var {set.SetFactory}
|
||||
*/
|
||||
'private _setFactory': null,
|
||||
|
||||
/**
|
||||
* Render destination element
|
||||
* @var {jQuery}
|
||||
|
@ -37,14 +43,14 @@ rectest.TestRunner = Class( 'TestRunner',
|
|||
/**
|
||||
* Initialize with jQuery instance
|
||||
*
|
||||
* @param {jQuery} jquery jQuery instance
|
||||
* @param {Function} TestRun TestRun constructor
|
||||
* @param {jQuery} jquery jQuery instance
|
||||
* @param {set.SetFactory} set_factory factory to create sets
|
||||
*/
|
||||
__construct: function( jquery, TestRun )
|
||||
__construct: function( jquery, set_factory )
|
||||
{
|
||||
this._jQuery = jquery;
|
||||
this._TestRun = TestRun;
|
||||
this._$dest = this._createDestElement();
|
||||
this._jQuery = jquery;
|
||||
this._setFactory = set_factory;
|
||||
this._$dest = this._createDestElement();
|
||||
},
|
||||
|
||||
|
||||
|
@ -86,7 +92,9 @@ rectest.TestRunner = Class( 'TestRunner',
|
|||
this._$dest.html( '' );
|
||||
|
||||
var _self = this,
|
||||
run = _self._TestRun( test_case, options );
|
||||
run = this._setFactory.fromId( options.ralgo,
|
||||
test_case, options
|
||||
);
|
||||
|
||||
// allow test case to initialize its display
|
||||
test_case.initRender( this._$dest );
|
||||
|
|
|
@ -3,7 +3,7 @@ window.Class = easejs.Class;
|
|||
window.Interface = easejs.Interface;
|
||||
|
||||
// namespace
|
||||
window.rectest = { cases: {} };
|
||||
window.rectest = { set: {}, cases: {} };
|
||||
|
||||
$( document ).ready( function()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,11 @@
|
|||
rectest.TestRun = Class( 'TestRun',
|
||||
/**
|
||||
* Represents a set that is randomized each time the first element is reached.
|
||||
* The set will loop back to the first element until the required number of
|
||||
* samples are satisfied.
|
||||
*/
|
||||
rectest.set.RandomGroupedSet = Class( 'RandomGroupedSet' )
|
||||
.implement( rectest.set.Set )
|
||||
.extend(
|
||||
{
|
||||
/**
|
||||
* Test case being executed
|
||||
|
@ -89,6 +96,11 @@ rectest.TestRun = Class( 'TestRun',
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the next element in the set
|
||||
*
|
||||
* @return {string} next element in set
|
||||
*/
|
||||
'public getNextElement': function()
|
||||
{
|
||||
// reset once we're at the end
|
|
@ -0,0 +1,15 @@
|
|||
/**
|
||||
* Represents a set from which samples should be gathered
|
||||
*/
|
||||
rectest.set.Set = Interface( 'Set',
|
||||
{
|
||||
__construct: [ 'test_case', 'options' ],
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the next element in the set
|
||||
*
|
||||
* @return {string} next element in set
|
||||
*/
|
||||
'public getNextElement': []
|
||||
} );
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Returns the requesetd type of set
|
||||
*/
|
||||
rectest.set.SetFactory = Class( 'SetFactory',
|
||||
{
|
||||
'public fromId': function( id, test_case, 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 );
|
||||
}
|
||||
} );
|
16
test.html
16
test.html
|
@ -56,7 +56,15 @@
|
|||
<dd><input type="number" id="blank" value="5.0" /> seconds</dd>
|
||||
|
||||
<dt>Sample Size</dt>
|
||||
<dd><input type="number" id="samples" value="10" /> (0 for infinite)</dd>
|
||||
<dd>
|
||||
<input type="number" id="samples" value="10" />
|
||||
<select id="ralgo">
|
||||
<option value="0">Random, All Inclusive</option>
|
||||
<option value="1">Random, Grouped</option>
|
||||
<option value="2">Random</option>
|
||||
<option value="3">Ordered</option>
|
||||
</select>
|
||||
</dd>
|
||||
|
||||
<dt>Begin Delay</dt>
|
||||
<dd><input type="number" id="delay" value="5.0" /> seconds</dd>
|
||||
|
@ -92,6 +100,12 @@
|
|||
<script type="text/javascript" src="scripts/jquery-1.7.1.min.js"></script>
|
||||
<script type="text/javascript" src="scripts/ease.min.js"></script>
|
||||
<script type="text/javascript" src="scripts/main.js"></script>
|
||||
|
||||
<!-- we will have the option to minify these in the future; this is for
|
||||
development purposes -->
|
||||
<script type="text/javascript" src="scripts/set/Set.js"></script>
|
||||
<script type="text/javascript" src="scripts/set/RandomGroupedSet.js"></script>
|
||||
<script type="text/javascript" src="scripts/set/SetFactory.js"></script>
|
||||
<script type="text/javascript" src="scripts/TestCase.js"></script>
|
||||
<script type="text/javascript" src="scripts/TestRun.js"></script>
|
||||
<script type="text/javascript" src="scripts/TestRunner.js"></script>
|
||||
|
|
Loading…
Reference in New Issue