tweaking and notes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-10-13 05:04:23 +03:00
parent 153167065a
commit 58c3654789
2 changed files with 31 additions and 5 deletions

View File

@ -41,6 +41,14 @@ tests.Test('dummy',
assert(true, 'dummy: assert') }) assert(true, 'dummy: assert') })
// a nested test set...
tests.Case('nested',
tests.TestSet(function(){
this.Case('moo', function(assert){
assert(true, 'nested dummy: assert') })
}))
//--------------------------------------------------------------------- //---------------------------------------------------------------------
typeof(__filename) != 'undefined' typeof(__filename) != 'undefined'

28
test.js
View File

@ -381,7 +381,15 @@ object.Constructor('TestSet', {
// XXX need to be able to use external assert... // XXX need to be able to use external assert...
// - from context... // - from context...
// - from arg... // - from arg...
// XXX nested assert(..) need to report nestedness correctly...
__call__: function(context, chain, stats){ __call__: function(context, chain, stats){
var assert
// running nested...
if(typeof(chain) == 'function'){
assert = chain
chain = null
stats = stats
|| assert.stats }
// parse chain... // parse chain...
chain = (chain == '*' || chain == null) ? chain = (chain == '*' || chain == null) ?
[] []
@ -417,7 +425,9 @@ object.Constructor('TestSet', {
var started = Date.now() var started = Date.now()
// tests... // tests...
var assert = this.__assert__('[TEST]', stats, module.VERBOSE) // XXX revise nested assert...
var assert = assert
|| this.__assert__('[TEST]', stats, module.VERBOSE)
chain_length != 1 chain_length != 1
&& object.deepKeys(tests) && object.deepKeys(tests)
.filter(function(t, i, l){ .filter(function(t, i, l){
@ -454,7 +464,9 @@ object.Constructor('TestSet', {
modifiers[m](_assert, modifiers[m](_assert,
setups[s](_assert))) }) }) }) setups[s](_assert))) }) }) })
// cases... // cases...
var assert = this.__assert__('[CASE]', stats, module.VERBOSE) // XXX revise nested assert...
assert = assert
|| this.__assert__('[CASE]', stats, module.VERBOSE)
chain_length <= 1 chain_length <= 1
&& Object.keys(cases) && Object.keys(cases)
.filter(function(s){ .filter(function(s){
@ -467,8 +479,8 @@ object.Constructor('TestSet', {
stats.time += Date.now() - started stats.time += Date.now() - started
return stats }, return stats },
// XXX add assert arg... __init__: function(func){
__init__: function(){ // test collections...
this.Setup = this.Setup =
this.setups = this.setups =
Merged.create('Setups') Merged.create('Setups')
@ -488,7 +500,10 @@ object.Constructor('TestSet', {
.add({ '-': function(_, s){ return s }}) .add({ '-': function(_, s){ return s }})
this.Case = this.Case =
this.cases = this.cases =
Merged.create('Cases') }, Merged.create('Cases')
// init...
func
&& func.call(this) },
}) })
@ -542,6 +557,8 @@ module.Cases =
// XXX chain N modifiers... // XXX chain N modifiers...
// XXX make Assert optional... // XXX make Assert optional...
// XXX is this a good name??? // XXX is this a good name???
//* XXX do we need a root runner???
// ...if not then need to cleanup run(..) to use TestSet / BASE_TEST_SET...
var runner = var runner =
module.runner = module.runner =
function(spec, chain, stats){ function(spec, chain, stats){
@ -629,6 +646,7 @@ function(spec, chain, stats){
// runtime... // runtime...
stats.time += Date.now() - started stats.time += Date.now() - started
return stats } return stats }
//*/