diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-15 10:47:23 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-12-15 10:47:30 -0500 |
| commit | 9bc63c92daccacf9580207b0766350e99186bad9 (patch) | |
| tree | 7a1abaf9a96f82e2b69dfdca7797a67f6ec773fa /test/js | |
| parent | ca01e1ae0e07999f145a96363dbaf2cf5416a84a (diff) | |
Allow test cases to require failure with "! % test"
Diffstat (limited to 'test/js')
| -rwxr-xr-x | test/js | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -12,14 +12,17 @@ let files = onfiles ? args.slice(1) : ['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]); + let expt = t.map(e=>e[0]==='!'?null:+e[0]); - let rslt = test.map(bqn); + 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 '+expt[i]+' but received '+rslt[i]) + ? 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 { |
