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 | |
| parent | ca01e1ae0e07999f145a96363dbaf2cf5416a84a (diff) | |
Allow test cases to require failure with "! % test"
Diffstat (limited to 'test')
| -rwxr-xr-x | test/dz_comp | 10 | ||||
| -rwxr-xr-x | test/js | 9 |
2 files changed, 14 insertions, 5 deletions
diff --git a/test/dz_comp b/test/dz_comp index f8d69c57..49847fef 100755 --- a/test/dz_comp +++ b/test/dz_comp @@ -30,8 +30,14 @@ Cases ← (0<≠)◶0‿('#'≠⊑)¨⊸/ · •FLines "cases/"∾∾⟜".bqn" c ← ∾ Cases¨ files Trim ← ((∨`∧∨`⌾⌽)' '⊸≠)⊸/ M ← {e‿b: - Msg ← {(@+10)∾˜""""∾b∾""": expected "∾e∾" but "∾0⊸≢◶⟨"evaluation failed","received "∾·⍕⊑⟩𝕩} - (<Native e) ≢◶""‿Msg <∘Exec⎊0 b + Msg ← {∾⟨ + """",b,""": expected " + "to fail"⍟("!"⊸≡)e + " but " + 0⊸≡◶⟨"received "∾·⍕⊑,"evaluation failed"⟩𝕩 + ⥊@+10 + ⟩} + ("!"⊸≡◶⟨<Native,0˙⟩ e) ≢◶""‿Msg <∘Exec⎊0 b } r ← (M '%'⊸= (∨´⊣)◶⟨"1"≍○<⊢, Trim¨(+`-2⊸×)⊸⊔⟩ ⊢)¨ c •Out ("All "∾(⍕≠c)∾" passed!")⍟(0=≠) ∾r @@ -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 { |
