now testing works... still experimental.

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-05-28 14:20:47 +03:00
parent 6d22ea3689
commit 428c9180bf
2 changed files with 37 additions and 22 deletions

View File

@ -4,7 +4,7 @@
"description": "", "description": "",
"main": "object.js", "main": "object.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "node ./test.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

29
test.js
View File

@ -108,11 +108,9 @@ var setups = {
return { return {
} }, } },
instances: function(assert){
// XXX generate using tests.instance* // placeholder -- this is written by tests.instance...
// XXX need to be able to use different input setups... instances: null,
return {}
},
} }
var modifiers = { var modifiers = {
@ -163,6 +161,9 @@ var tests = {
callables: function(assert, setup){ callables: function(assert, setup){
return instances(setup) return instances(setup)
.map(function([k, o]){ .map(function([k, o]){
// NOTE: not all callables are instances of Function...
//assert(typeof(o) == 'function'
// && o instanceof Function, 'instanceof Function')
return typeof(o) == 'function' return typeof(o) == 'function'
&& assert(o(), 'call', k) }) }, && assert(o(), 'call', k) }) },
} }
@ -196,6 +197,8 @@ var runner = function(){
// setups... // setups...
Object.keys(setups) Object.keys(setups)
.forEach(function(s){ .forEach(function(s){
if(typeof(setups[s]) != 'function'){
return }
// run the test... // run the test...
stats.tests += 1 stats.tests += 1
var _assert = assert(`test:${t}.${s}.${m}`, stats) var _assert = assert(`test:${t}.${s}.${m}`, stats)
@ -211,10 +214,22 @@ var runner = function(){
// stats... // stats...
console.log('Tests:', stats.tests, console.log('Tests:', stats.tests,
'Assertions:', stats.assertions, 'Assertions:', stats.assertions,
'Failures:', stats.failures) } 'Failures:', stats.failures)
return stats }
//---------------------------------------------------------------------
var stats = runner()
// report error status to the OS...
process
&& process.exit(stats.failures)
runner()
/********************************************************************** /**********************************************************************