From 58c365478921c465fa379f52b8f4a56088f94916 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 13 Oct 2020 05:04:23 +0300 Subject: [PATCH] tweaking and notes... Signed-off-by: Alex A. Naanou --- test-test.js | 8 ++++++++ test.js | 28 +++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/test-test.js b/test-test.js index f1c7cda..2f7d999 100644 --- a/test-test.js +++ b/test-test.js @@ -41,6 +41,14 @@ tests.Test('dummy', 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' diff --git a/test.js b/test.js index bcc3af3..0677e1b 100644 --- a/test.js +++ b/test.js @@ -381,7 +381,15 @@ object.Constructor('TestSet', { // XXX need to be able to use external assert... // - from context... // - from arg... + // XXX nested assert(..) need to report nestedness correctly... __call__: function(context, chain, stats){ + var assert + // running nested... + if(typeof(chain) == 'function'){ + assert = chain + chain = null + stats = stats + || assert.stats } // parse chain... chain = (chain == '*' || chain == null) ? [] @@ -417,7 +425,9 @@ object.Constructor('TestSet', { var started = Date.now() // 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 && object.deepKeys(tests) .filter(function(t, i, l){ @@ -454,7 +464,9 @@ object.Constructor('TestSet', { modifiers[m](_assert, setups[s](_assert))) }) }) }) // cases... - var assert = this.__assert__('[CASE]', stats, module.VERBOSE) + // XXX revise nested assert... + assert = assert + || this.__assert__('[CASE]', stats, module.VERBOSE) chain_length <= 1 && Object.keys(cases) .filter(function(s){ @@ -467,8 +479,8 @@ object.Constructor('TestSet', { stats.time += Date.now() - started return stats }, - // XXX add assert arg... - __init__: function(){ + __init__: function(func){ + // test collections... this.Setup = this.setups = Merged.create('Setups') @@ -488,7 +500,10 @@ object.Constructor('TestSet', { .add({ '-': function(_, s){ return s }}) this.Case = this.cases = - Merged.create('Cases') }, + Merged.create('Cases') + // init... + func + && func.call(this) }, }) @@ -542,6 +557,8 @@ module.Cases = // XXX chain N modifiers... // XXX make Assert optional... // 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 = module.runner = function(spec, chain, stats){ @@ -629,6 +646,7 @@ function(spec, chain, stats){ // runtime... stats.time += Date.now() - started return stats } +//*/