diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-01-30 20:22:47 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-01-30 20:22:47 -0500 |
| commit | 99f37de695119fd643b36f373771bcdcc4a626af (patch) | |
| tree | d30db1ea6cfe1dda0685b271f124f968d5accae5 /test | |
| parent | 5ecf5494573e7c4f554329646edf072e2bd6cb7c (diff) | |
Move direct command-line execution from test/js to docs/bqn.js
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!" +); |
