diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-07-17 07:28:21 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-07-17 08:06:17 -0400 |
| commit | 357a9ab4e25a0101121761c503e14ba38d32093c (patch) | |
| tree | 0cdaedd3eca6f3854a82f86ea50bb231e68ad2dc /test/nt.js | |
| parent | 5c4a7106dc47e2e1849eddf4d87fb0e107461d74 (diff) | |
Move some files around
Diffstat (limited to 'test/nt.js')
| -rwxr-xr-x | test/nt.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/nt.js b/test/nt.js new file mode 100755 index 00000000..5cd38556 --- /dev/null +++ b/test/nt.js @@ -0,0 +1,19 @@ +//usr/bin/env node "$0" $@;exit $? +const bqn=require(require('os').homedir+'/bin/bqn') + , load=f=>require('fs').readFileSync(__dirname+'/'+f,'utf8') + , runWasm=w=>new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.from(w))) + .exports.fn() + +const t=load('cases.bqn').split('\n').filter(x=>x).map(x=>x.split(' % ')) + , test=t.map(e=>'"'+e[1]+'"').join('\n') + , expt=t.map(e=>+e[0]) + , rslt=bqn(load('../nc.bqn','utf8').concat('Compile¨⟨'+test+'⟩')) + .a.map((a,i)=>runWasm(a.a)) + , pass=rslt.map((r,i)=>r===expt[i]) + , fail=pass.map((p,i)=>p?-1:i).filter(i=>i>=0) +console.log( + fail.length + ? fail.map(i=>'"'+t[i][1]+'": expected '+expt[i]+' but received '+rslt[i]) + : "All passed!" +) +process.exit(+(fail.length>0)) |
