diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-07-02 20:52:25 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-07-02 20:52:25 -0400 |
| commit | 704b8bb41436243a92427c94a3c3f112fab42195 (patch) | |
| tree | 50f963d06fc0f5ece2d71ebab6b41f82e6de0753 | |
| parent | 2f61ee644fe9c465f351307cdee805b46c864648 (diff) | |
Add automated testing for dzaima+reference-based compiler
| -rwxr-xr-x | test/dt.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/dt.js b/test/dt.js new file mode 100755 index 00000000..142bb421 --- /dev/null +++ b/test/dt.js @@ -0,0 +1,24 @@ +//usr/bin/env node "$0" $@;exit $? +const exec = require('child_process').exec + , 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]) + +var compiler = exec('../spec/dzref', function (error, stdout, stderr) { + const rslt=stdout.split('\n').filter(a=>a.length) + .map(a=>runWasm(a.split("‿").map(n=>+n))) + , 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)) +}); +compiler.stdin.write(load('../dc.bqn').concat('{•←Compile𝕩}¨⟨'+test+'⟩')) +compiler.stdin.end() |
