diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/README.txt | 10 | ||||
| -rwxr-xr-x | test/js | 41 |
2 files changed, 20 insertions, 31 deletions
diff --git a/test/README.txt b/test/README.txt index 22a601b4..b61cf09d 100644 --- a/test/README.txt +++ b/test/README.txt @@ -1,12 +1,12 @@ Test scripts: Script Compiler host Output host/VM -- js [-prim] Self-host Javascript -- dz_comp [-prim] dzaima/BQN dzaima/BQN +- js Self-host Javascript +- dz_comp dzaima/BQN dzaima/BQN - dz_wasm.js dzaima/BQN WebAssembly dz_comp uses the self-hosted compiler ../src/c.bqn by default but not -the runtime ../src/r.bqn. Pass -rt to test with the runtime, and -comp +the runtime ../src/r.bqn. Pass -rt to test with the runtime, and -nocomp to test dzaima/BQN only (this doesn't pass as of the time of writing). Test cases (cases/): @@ -15,8 +15,8 @@ Test cases (cases/): - syntax.bqn * * - prim.bqn * -dz_comp can be run on a different set of tests by passing their names -as arguments; for js the argument "--" is needed, then the names. +js or dz_comp can be run on a specified set of tests by passing the test +names as arguments. Contents of bin/dbqn follow (3 lines). Replace "/path/to/dzaima/" with your path. @@ -6,31 +6,20 @@ let cases = f=>read(__dirname+'/cases/'+f+'.bqn','utf8').split('\n') .filter(x=>x.length>0 && x.charAt(0)!=='#') .map(x=>x.indexOf('%')===-1?[1,x]:x.split(' % ')); let args = process.argv.slice(2); -let onfiles = args[0]==='--'; -let files = onfiles ? args.slice(1) : ['simple','syntax']; +let files = args.length ? args : ['simple','syntax']; -if (onfiles || args.length==0) { - let t = [].concat.apply([],files.map(cases)); - let test = t.map(e=>e[1]); - let expt = t.map(e=>e[0]==='!'?null:+e[0]); +let t = [].concat.apply([],files.map(cases)); +let test = t.map(e=>e[1]); +let expt = t.map(e=>e[0]==='!'?null:+e[0]); - let rslt = test.map(t => {try{return bqn(t);}catch(e){return null;}}); - let pass = rslt.map((r,i)=>r===expt[i]); - let fail = pass.map((p,i)=>p?-1:i).filter(i=>i>=0); - console.log( - fail.length - ? fail.map(i=>'"'+test[i]+'": expected ' - +(e=>e===null?'to fail':e)(expt[i]) - +' but ' - +(r=>r===null?'evaluation failed':'received '+r)(rslt[i])) - : "All "+test.length+" passed!" - ); -} else { - args.map(a=>{ - try { - console.log(bqn.fmt(bqn(a))) - } catch(e) { - console.error('[31m'+bqn.fmtErr(Array.from(a),e)+'[39m'); - } - }); -} +let rslt = test.map(t => {try{return bqn(t);}catch(e){return null;}}); +let pass = rslt.map((r,i)=>r===expt[i]); +let fail = pass.map((p,i)=>p?-1:i).filter(i=>i>=0); +console.log( + fail.length + ? fail.map(i=>'"'+test[i]+'": expected ' + +(e=>e===null?'to fail':e)(expt[i]) + +' but ' + +(r=>r===null?'evaluation failed':'received '+r)(rslt[i])) + : "All "+test.length+" passed!" +); |
