From 2ff502e46f9d7e6929059479da2e160d0cbbf5de Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 8 Sep 2020 21:14:26 -0400 Subject: Organize tests scripts a little better and add README --- test/README.txt | 20 ++++ test/bt | 8 -- test/cmpref.bqn | 60 ----------- test/dz_comp | 8 ++ test/dz_rt | 60 +++++++++++ test/dz_wasm.js | 27 +++++ test/js | 34 ++++++ test/prim.bqn | 311 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/testref.bqn | 311 ------------------------------------------------------- test/tj.js | 34 ------ test/tw.js | 27 ----- 11 files changed, 460 insertions(+), 440 deletions(-) create mode 100644 test/README.txt delete mode 100755 test/bt delete mode 100755 test/cmpref.bqn create mode 100755 test/dz_comp create mode 100755 test/dz_rt create mode 100755 test/dz_wasm.js create mode 100755 test/js create mode 100644 test/prim.bqn delete mode 100644 test/testref.bqn delete mode 100755 test/tj.js delete mode 100755 test/tw.js (limited to 'test') diff --git a/test/README.txt b/test/README.txt new file mode 100644 index 00000000..12eb9bf1 --- /dev/null +++ b/test/README.txt @@ -0,0 +1,20 @@ +Test scripts: + + Script Compiler host Output host +- js [-prim] Self-host BQN on Javascript +- dz_comp [-prim] dzaima/BQN dzaima/BQN +- dz_rt dzaima/BQN BQN on dzaima/BQN +- dz_wasm.js dzaima/BQN WebAssembly + +Test cases: + js dz_comp dz_rt dz_wasm.js +- cases.bqn * * * +- bcases.bqn * * +- prim.bqn -prim -prim * + +Contents of bin/dbqn follow (3 lines). Replace "/path/to/dzaima/" with +your path. To work on dz_rt, add "-e •compstart↩¯1" before "-f". + +#! /bin/bash + +java -jar /path/to/dzaima/BQN/BQN.jar -f "$@" diff --git a/test/bt b/test/bt deleted file mode 100755 index 8fdabfe3..00000000 --- a/test/bt +++ /dev/null @@ -1,8 +0,0 @@ -#! /usr/bin/env dbqn - -dRun ← •EX •path∾"../dc.bqn" -c ← ∾(•LNS •path∾∾⟜"cases.bqn")¨""‿"b" -{𝕩: c ∾↩ (¬":"⊑∘∊⊢)¨⊸/ "1 %"⊸∾¨ (3≤≠)◶0‿(('#'≠2⊸⊑)∧" "≡2⊸↑)¨⊸/ •LNS •path∾"testref.bqn" }⍟⊢⊑(<"-ref")∊•args -M ← {e‿b: (⍎e)⊸≢◶""‿{(@+10)∾˜""""∾b∾""": expected "∾e∾" but received "∾⍕𝕩} DRun b} -r ← '%' M∘((+`-2⊸×)∘=⊔⊢)¨ c -• ← ("All "∾(⍕≠c)∾" passed!")⍟(0=≠) ∾r diff --git a/test/cmpref.bqn b/test/cmpref.bqn deleted file mode 100755 index 23bccd17..00000000 --- a/test/cmpref.bqn +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env dbqn - -# Compile and run the primitive implementations, and testref.bqn - -impl ← •LNS •path∾"../src/r.bqn" - -drun ← ((<•path∾"../dc.bqn")∾<"DRun") •EX •path∾"../dzref" - -chrs←⟨ - "!+-×÷⋆√⌊⌈∧∨¬|=≠≤<>≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔" - "˙˜˘¨⌜⁼´˝`" - "∘⊸⟜○⌾⎉⚇⍟◶⊘" -⟩ -nc ← ≠¨chrs -chr ← ∾chrs -itr ← 0⥊˜≠chr - -init ← " "⊸∾¨(/⟜"_"¨nc/0‿1‿1)∾¨(nc/"FMD")∾¨(nc+´⊸↑⥊"ABC"∾⌜•a) -post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 -names ← init∾¨'0'∾¨post - -Inc ← { - i←⊑chr⊐𝕩 - n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr - names↩((i⊑init)∾('0'+n)∾i⊑post)⌾(i⊑⊢)names -} - -# built-in assumptions -Mod ← {((⊑chr⊐𝕨)⊑names) ∾ " ← " ∾ 𝕩} - -pre ← ⟨ - "IsArray ← 0≠≡" - "Type ← ⟨⟩⥊0⊸⥊" - "Log ← ⋆⁼" - "GroupLen← ≠¨⊔" - "GroupOrd← ∾⊔∘⊢" - '!' Mod "{𝕩 ⋄ ≤1}⍟(1≢⊢)" -⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘" - - -# checks if line is a builtin redefinition -E_isdef ← (3≤≠)◶⟨0,∧´⟨chr," ","←↩"⟩∊˜¨3⊸↑⟩ - -# removes comments and replaces built-ins with names -E_proc ← { - l←≠chr - q←≠`𝕩='"' ⋄ q∨↩≠`q<𝕩=''' ⋄ f←¬∨`q<𝕩='#' - ∾ (((l×f/q)+chr⊸⊐) (≥⟜l)◶⟨⊑⟜names,⥊∘⊢⟩¨ ⊢) f/𝕩 -} - -E_redef ← { # handles [fmd] [←↩] - tail ← E_proc 3↓𝕩 # must use old def - Inc ⊑𝕩 - (E_proc 1↑𝕩) ∾ "←" ∾ tail -} - -pre ∾↩ E_isdef◶E_proc‿E_redef¨ impl -t ← (¬∘⊑':'∊⊢)¨⊸/ 3⊸↓⌾(3⊸⊑) •LNS •path∾"testref.bqn" -res ← DRun ∾ ∾⟜(@+10)¨ pre ∾ E_proc¨ t -• ← ("All "∾(⍕≠res)∾" passed!")⍟(0=≠) /res diff --git a/test/dz_comp b/test/dz_comp new file mode 100755 index 00000000..52dbcc51 --- /dev/null +++ b/test/dz_comp @@ -0,0 +1,8 @@ +#! /usr/bin/env dbqn + +dRun ← •EX •path∾"../dc.bqn" +c ← ∾(•LNS •path∾∾⟜"cases.bqn")¨""‿"b" +{𝕩: c ∾↩ (¬":"⊑∘∊⊢)¨⊸/ "1 %"⊸∾¨ (3≤≠)◶0‿(('#'≠2⊸⊑)∧" "≡2⊸↑)¨⊸/ •LNS •path∾"prim.bqn" }⍟⊢⊑(<"-prim")∊•args +M ← {e‿b: (⍎e)⊸≢◶""‿{(@+10)∾˜""""∾b∾""": expected "∾e∾" but received "∾⍕𝕩} DRun b} +r ← '%' M∘((+`-2⊸×)∘=⊔⊢)¨ c +• ← ("All "∾(⍕≠c)∾" passed!")⍟(0=≠) ∾r diff --git a/test/dz_rt b/test/dz_rt new file mode 100755 index 00000000..f83a787d --- /dev/null +++ b/test/dz_rt @@ -0,0 +1,60 @@ +#!/usr/bin/env dbqn + +# Compile and run the primitive implementations, and prim.bqn + +impl ← •LNS •path∾"../src/r.bqn" + +drun ← •EX •path∾"../dc.bqn" + +chrs←⟨ + "!+-×÷⋆√⌊⌈∧∨¬|=≠≤<>≥≡≢⊣⊢⥊∾≍↑↓↕⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔" + "˙˜˘¨⌜⁼´˝`" + "∘⊸⟜○⌾⎉⚇⍟◶⊘" +⟩ +nc ← ≠¨chrs +chr ← ∾chrs +itr ← 0⥊˜≠chr + +init ← " "⊸∾¨(/⟜"_"¨nc/0‿1‿1)∾¨(nc/"FMD")∾¨(nc+´⊸↑⥊"ABC"∾⌜•a) +post ← ∾⟜" "¨/⟜"_"¨nc/0‿0‿1 +names ← init∾¨'0'∾¨post + +Inc ← { + i←⊑chr⊐𝕩 + n←0 ⋄ itr↩{n↩1+𝕩}⌾(i⊑⊢)itr + names↩((i⊑init)∾('0'+n)∾i⊑post)⌾(i⊑⊢)names +} + +# built-in assumptions +Mod ← {((⊑chr⊐𝕨)⊑names) ∾ " ← " ∾ 𝕩} + +pre ← ⟨ + "IsArray ← 0≠≡" + "Type ← ⟨⟩⥊0⊸⥊" + "Log ← ⋆⁼" + "GroupLen← ≠¨⊔" + "GroupOrd← ∾⊔∘⊢" + '!' Mod "{𝕩 ⋄ ≤1}⍟(1≢⊢)" +⟩∾Mod⟜⥊¨ "+-×÷⋆⌊=≤≢⥊⊑↕⌜`⊘" + + +# checks if line is a builtin redefinition +E_isdef ← (3≤≠)◶⟨0,∧´⟨chr," ","←↩"⟩∊˜¨3⊸↑⟩ + +# removes comments and replaces built-ins with names +E_proc ← { + l←≠chr + q←≠`𝕩='"' ⋄ q∨↩≠`q<𝕩=''' ⋄ f←¬∨`q<𝕩='#' + ∾ (((l×f/q)+chr⊸⊐) (≥⟜l)◶⟨⊑⟜names,⥊∘⊢⟩¨ ⊢) f/𝕩 +} + +E_redef ← { # handles [fmd] [←↩] + tail ← E_proc 3↓𝕩 # must use old def + Inc ⊑𝕩 + (E_proc 1↑𝕩) ∾ "←" ∾ tail +} + +pre ∾↩ E_isdef◶E_proc‿E_redef¨ impl +t ← (¬∘⊑':'∊⊢)¨⊸/ 3⊸↓⌾(3⊸⊑) •LNS •path∾"prim.bqn" +res ← DRun ∾ ∾⟜(@+10)¨ pre ∾ E_proc¨ t +• ← ("All "∾(⍕≠res)∾" passed!")⍟(0=≠) /res diff --git a/test/dz_wasm.js b/test/dz_wasm.js new file mode 100755 index 00000000..b8faa668 --- /dev/null +++ b/test/dz_wasm.js @@ -0,0 +1,27 @@ +#! /usr/bin/env node + +const execFile = require('child_process').execFile + , 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 = execFile( + __dirname+'/../wcshim.bqn', + [ '{•←WCompile𝕩}¨⟨'+test+'⟩' ], + 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)) + } +); diff --git a/test/js b/test/js new file mode 100755 index 00000000..da099417 --- /dev/null +++ b/test/js @@ -0,0 +1,34 @@ +#! /usr/bin/env node + +let bqn = require(__dirname+'/../docs/bqn.js'); +let load = f=>require('fs').readFileSync(__dirname+'/'+f,'utf8'); +let args = process.argv.slice(2); +let prim = args[0]==="-prim"; + +if (prim || args.length==0) { + let t = (load('cases.bqn')+load('bcases.bqn')) + .split('\n').filter(x=>x).map(x=>x.split(' % ')); + let test = t.map(e=>e[1]); + let expt = t.map(e=>+e[0]); + if (prim) { + let r = load('prim.bqn').split('\n') + .filter(x=>x.charAt(0)===' ' + &&x.charAt(1)===' ' + &&x.charAt(2)!=='#' + &&x.indexOf(':')===-1) + .map(x=>x.slice(2)); + test = test.concat(r); + expt = expt.concat(r.map(e=>1)); + } + + let rslt = test.map(bqn); + 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]) + : "All "+test.length+" passed!" + ); +} else { + console.log(args.map(bqn)); +} diff --git a/test/prim.bqn b/test/prim.bqn new file mode 100644 index 00000000..bf455944 --- /dev/null +++ b/test/prim.bqn @@ -0,0 +1,311 @@ +# Tests of primitive functionality +# Ordering matches the reference implementations + +•←/¬⟨ + # LAYER 0 + # [0,34) + 0≡¯2+2 + 1e4≡5e3+5e3 + ¯∞≡1e6-∞ + 4≡-¯4 + ¯∞≡-∞ + ∞≡-¯∞ + 4≡9-5 + 1.5≡3×0.5 + 4≡÷0.25 + ∞≡÷0 + 0≡÷∞ + 1≡⋆0 + ¯1≡¯1⋆5 + 1≡¯1⋆¯6 + 3≡⌊3.9 + ¯4≡⌊¯3.9 + ∞≡⌊∞ + ¯∞≡⌊¯∞ + ¯1e30≡⌊¯1e30 + 1≡1=1 + 0≡¯1=∞ + 1≡1≤1 + 1≡¯∞≤¯1e3 + 0≡∞≤¯∞ + ⟨⟩≡≢<2 + ⟨3⟩≡≢"abc" + ⟨2,3⟩≡≢>"abc"‿"fed" + ⟨2,3,4,5⟩≡≢2‿3‿4‿5⥊↕120 + ⟨6⟩≡≢⥊>"abc"‿"fed" + "abc"≡0⊑"abc"‿"de" + "de"≡1⊑"abc"‿"de" + ⟨⟩≡↕0 + ⟨0⟩≡↕1 + ⟨0,1,2,3,4,5,6⟩≡↕7 + + # LAYER 1 + # [34,56) + 3≡4>◶+‿-1 + 3≡4⊢◶+‿-1 + 3≡4 1◶+‿-1 + 5≡4<◶+‿-1 + 5≡4 0◶+‿-1 + 1≡-⊘0 ¯1 + 1≡¯1-⊘+2 + "abc"≡⊢"abc" + ""≡3⊢"" + ⟨⟩≡⊣⟨⟩ + "ab"≡"ab"⊣⟨⟩ + 4≡+˜2 + 3≡1-˜4 + 1≡-∘ׯ6 + ¯6≡2-∘×3 + 1≡-○ׯ7 + 2≡5-○ׯ7 + ¯20≡1⊸-⊸×5 + (0‿2+⌜0‿1)≡(>⟨"ab","cd"⟩)≢⊸⥊↕4 + 20≡×⟜(-⟜1)5 + 4≡5+⟜ׯ3 + 7≡5+⟜2 ¯3 + # [56,95) + 2≡√4 + 3≡3√27 + 6≡2∧3 + 0≡¯2∧0 + 0.75≡∨˜0.5 + 1.75≡2∨0.25 + 0≡¬1 + 1≡¬0 + 2≡¬¯1 + 0≡3¬4 + 2≡4¬3 + 4≡5¬2 + 0≡|0 + 5≡|¯5 + 6≡|6 + ∞≡|¯∞ + 2≡3|8 + 2≡3|¯7 + ¯1≡¯3|8 + "a"≡⥊<'a' + "abcd"≡⊑<"abcd" + ⟨⟩≡≢<⟨2,⟨3,4⟩⟩ + 0≡4<2 + 0≡5>5 + 0≡3≥4 + 0≡≠"" + 1≡≠"a" + 1≡≠'a' + 2≡≠"ab" + 25≡≠↕25 + 1≡×5 + ¯1≡ׯ2.5 + 3≡3⌊4 + ¯3≡¯3⌊∞ + 4≡3⌈4 + 1≡1⌈¯1 + 5≡⌈4.01 + ⟨⟩≡≢'a' + ⟨⟩≡≢0 + # [95,104) + ⟨0⟩‿⟨1⟩‿⟨2⟩≡⥊¨↕3 + (↕6)≡⟜(≠¨)○(2‿3⊸⥊)⟨⟩‿"a"‿"ab"‿"abc"‿"abcd"‿"abcde"‿"abcdef" + ≡⟜(≠¨)4‿0‿2⥊↕0 + 6≡+´↕4 + (⊑≡⊣´)"a"‿2‿(3‿"d") + 0(⊑≡⊣´)"a"‿2‿(3‿"d") + (2⊸⊑≡⊢´)"a"‿2‿(3‿"d") + 2(⊣≡⊢´)"a"‿2‿(3‿"d") + 7‿10≡+¨´⟨⟨2,3⟩,⟨5,7⟩⟩ + + # LAYER 2 + # [104,117) + ⟨⟩≡⟨⟩∾"" + "a"≡⟨⟩∾"a" + "a"≡"a"∾⟨⟩ + "aBCD"≡"a"∾"BCD" + ((+⌜˜≠¨)≡(≠¨∾⌜˜))""‿⟨2,3⟩‿"abcde" + (⥊⟜(↕×´)≡(×⟜4)⊸(+⌜)○↕´)3‿4 + (⥊⟜(↕×´)≡(×⟜4)⊸(+⌜)○↕´)0‿4 + (3‿2‿0⥊"")≡(3‿2⥊↕6)+⌜"" + (<<2)≡<¨2 + ⟨1,⟨3,2,2‿2⥊⟨1,0,2,0⟩⟩,⟨5,4⟩⟩≡-⟨-1,⟨-3,-2,-¨2‿2⥊⟨1,0,2,0⟩⟩,⟨-5,-4⟩⟩ + 3(+¨≡+⌜)↕6 + 3‿4‿5‿6‿6≡{F:F⍟(×≡)⊸∾⟜⥊´𝕩}⟨2,1⟩+⟨⟨⟨⟨1,2⟩,3⟩,4⟩,5⟩ + (=¨⟜(⥊⟜(↕×´)3‿4)≡(↕4)=⌜˜4|⊢)1‿6‿8 + + # LAYER 3 + # [117,152) + 2≡⊑⟨2⟩ + "ab"≡⊑⟨"ab"⟩ + 0≡⊑↕20 + 4≡⊑3‿2‿1⥊4⥊⊸∾5⥊0 + 'c'≡2⊑"abcd" + 'c'≡¯2⊑"abcd" + 7≡7⊑↕10 + 21≡2‿¯3⊑(10×↕3)+⌜↕4 + 21‿12‿03≡⟨2‿¯3,1‿2,0‿¯1⟩⊑(10×↕3)+⌜↕4 + "dfeb"≡(⥊¨-⟨3,1,2,5⟩)⊑"abcdef" + "abc"≡⟨⟩⊑<"abc" + ⟨7,7‿7,7⟩≡⟨⟨⟩,⟨⟨⟩,⟨⟩⟩,⟨⟩⟩⊑<7 + ⟨7,⟨7,<7⟩⟩≡⟨⟨⟩,⟨⟨⟩,<⟨⟩⟩⟩⊑7 + "abcfab"≡⥊(↕2‿3)⊑5‿5⥊"abcdef" + "aedcaf"≡⥊(-↕2‿3)⊑5‿5⥊"abcdef" + (<6⥊0)(⊑≡<∘⊑∘⊢)(6⥊1)⥊5 + ¯6≡1‿0◶(2‿2⥊0‿0‿-‿0)6 + ⟨3⟩≡⥊3 + ⟨3,3,3⟩≡3⥊3 + 6(⊢⌜≡∾○≢⥊⊢)○↕3 + (<≡↕)⟨⟩ + (↕∘⥊≡⥊¨∘↕)9 + ¬'a'≡<'a' + ¬"a"≡≍"a" + ¬⟨1,2,⟨4,4⟩,5⟩≡○(2‿2⊸⥊)⟨1,2,⟨3,4⟩,5⟩ + ¬2‿3‿4≡2‿3 + ¬1.001≡1.002 + 'a'≢2 + 0≡≡'a' + 1≡≡↕6 + 2≡≡↕2‿4 + 3≡≡<<<4 + (1¨≡-○≡˜⟜↕¨)⟨0,⟨⟩,⟨1⟩,2,⟨3,4⟩⟩ + 2≡≡⟨5,⟨'c',+,2⟩⟩ + 0≡≡⊑⟨-⟩ + + # LAYER 4 + # [152,183) + ≡⟜><'a' + ≡⟜><∞ + ≡⟜>↕5 + ≡⟜>5‿3⥊2 + 2‿3‿2≡≢>↕2‿3 + ((4⥊2)⊸⥊≡(>2‿2⥊·<2‿2⥊⊢))"abcd" + (⊢≡>∘<)5‿3⥊↕15 + (⊢≡(><¨))5‿3⥊↕15 + (⥊≡≍)'a' + (⥊≡≍)<'a' + (1‿2⊸⥊≡≍)"ab" + 1‿2≡1≍2 + 2‿1(≍≡2‿2⥊∾)4‿3 + (≍⟜<≡≍˜)'a' + (≍˘˜⥊˘1‿5‿9)≡⌽⎉2⊸+⥊⟜(↕×´)3‿2‿1 + (↕4)(×⌜≡×⎉0‿2)↕5 + (↕4)(⋆˜⌜˜≡⋆⎉∞‿¯4)↕5 + (⟨2⟩⊸∾⍟(2‿2⥊0‿1‿1‿1)2‿3)≡≢¨≍⎉(⌊○=)⌜˜⟨↕3,2‿3⥊↕6⟩ + (2=⌜○↕3)≡(2‿4⥊"abc")≡⎉1(2‿3‿4⥊"abc") + ⟨0,0⟩≡(2‿4⥊"abc")≡⎉¯1(2‿3‿4⥊"abc") + ⟨5,⟨15,1⟩⟩≡+´⚇1⟨⟨3,2⟩,⟨⟨4,5,6⟩,⟨1⟩⟩⟩ + 5‿6‿15≡∾´+´⚇1⟨⟨0,1⟩,⟨⟨⟩⟩⟩⥊⊸∾⚇¯2‿1⟨⟨2,3⟩,⟨4,5,6⟩⟩ + 4≡2+⍟¯1 6 + (2×↕7)≡2+⍟(¯3+↕7)6 + (3⌊↕5)≡{i←0⋄r←{i+↩1⋄1+𝕩}⍟(↕4)𝕩⋄r∾i}0 + (+⌜˜≡·>1+⍟⊢⊢)↕5 + 0‿1‿3‿6‿10≡+`↕5 + (-0‿1‿3‿6‿10)≡-`↕5 + ((0∾¨↕3)≍3⥊0)≡≡`↕2‿3 + ⟨⟩≡×`⟨⟩ + ≡⟜(!∘0`)3‿0‿2⥊"" + + # LAYER 5 + # [183,230) + (<'a')≡⊏"abc" + "a"≡⊏⥊˘"abc" + (<'c')≡2⊏"abc" + (<'c')≡¯1⊏"abc" + "ccc"≡2‿¯1‿2⊏"abc" + ((3-˜↕5)⊸⊏≡2⊸⌽)↕5‿2 + (0‿3⥊0)≡⟨⟩⊏2‿3⥊↕6 + ⟨3‿0,2‿1‿2⟩(×⟜5⊸+⌜´∘⊣≡⊏)⥊⟜(↕×´)6‿5 + (2‿0⥊0)≡⟨3‿¯1,⟨⟩⟩⊏4‿3⥊0 + 5‿1(<⊸⊏≡⊏)↕6‿2 + ⟨4‿0,1‿2‿3‿2‿1‿0⟩(+⌜´⊸(×⌜)≡⊏⟜(×⌜˜))+⌜˜↕5 + "abc"≡3↑"abce" + "e"≡¯1↑"abce" + ""≡0↑"ab" + (<⟜3⊸×↕5)≡5↑↕3 + (6⥊0)≡¯6↑↕0 + (≍↕3)≡1↑2‿3⥊↕6 + (↑⟜4≡⥊⟜0)↕3 + (≍"abc")≡1↑2‿3↑"abcd" + (6⥊1)(↑≡⥊⟜⊑)2‿3⥊↕6 + (↕¨∘↕∘(1⊸+)≡↑∘↕)5 + (↑≡((↕4)≍¨2)⥊¨<)3‿2⥊"abcdef" + "d"≡3↓"abcd" + 1‿2≡⟜(¯3⊸↓)○↕4‿2 + 1‿1‿3‿2‿1≡≢(5⥊0)↓↕3‿2‿1 + (↓∘↕≡↕∘(1⊸+)+⟜⌽↑∘↕)5 + (↕3‿4)≡1↓¨⊏↕2‿3‿4 + (4+⌜○↕2)≡2↕↕5 + ⟨⟩(↕≡⊢)4‿3⥊"abcd" + (0⊸↕≡(0≍˜1+≠)⊸⥊)↕6 + (7↕6‿0⥊"")≡0‿7‿0⥊"" + ≡⟜⌽⟨⟩ + ≡⟜⌽"a" + "ba"≡⟜⌽"ab" + (⌽≡(1-˜≠)(-○⊑∾1↓⊢)⚇1⊢)↕3‿2‿4 + ≡⟜⌽↕↕3 + ∧´5(⌽≡⊢)¨⟨"",⥊∞,↕5,↕0‿4,2‿0‿3⥊""⟩ + ∧´("bcdea"≡⌽⟜"abcde")¨1+5ׯ10‿¯2‿¯1‿0‿1‿6‿61 + ∧´⟨1,0‿2,¯1‿1‿3⟩(⊑∘⌽≡(3⊸↑)⊸⊑)⚇¯1‿∞ 2‿3‿5⥊"abcdef" + ⟨⟩(⌽≡⊢)'a' + 0‿4≡/1‿0‿0‿0‿1‿0 + 1‿1‿2≡/0‿2‿1 + ≡⟜/⟨⟩ + "aabbcc"≡2/"abc" + 3‿3‿3‿2‿2‿1≡/˜3‿2‿1 + (≍1∾¨1‿2‿2)≡(↕¨/↕)2‿3 + ⟨⟩(/≡⊢)≍"ab" + + # LAYER 6 + # [230,270) + ≡⟜(∾⥊¨)"abc" + (∾´≡∾)"ab"‿"cde"‿"" + 1‿2‿3‿4‿6‿9≡∾(⊢×≠↑↓)1+↕3 + ≡⟜∾⟨⟩ + ⟨1‿4,⥊2⟩((∾⋆⌜⌜)≡⋆⌜○∾)⟨2‿3‿4,⟨⟩,⥊5⟩ + "abcd"≡"abc"∾'d' + "abcd"≡"abc"∾<'d' + (↕4‿3)≡(↕3‿3)∾3∾¨↕3 + (∾˜≡·¯1⊸(×´∘↓∾↑)∘≢⊸⥊≍˜)2‿3⥊"abcdef" + (∾´≡∾)⟨3‿2‿1,0‿2‿1⟩⥊¨<↕6 + ⟨1‿2,⥊0,⥊3⟩≡⊔1‿0‿0‿2 + 4‿3‿2(≍○<≡·(≠¨≍○<∾)/⊸⊔)"abcdefghi" + ⟨⟩≡(3⥊¯1)⊔"abc" + (≍˘1‿1‿4<∘⥊⎉1 16‿4+⌜↕4)≡2↓⟨3‿2,¯1‿0‿¯1⟩⊔2‿3‿4⥊↕24 + ⥊⚇0⊸≡○⊔⟜(⥊<)1‿2‿2‿¯1‿0 + (⊔≡·≍⍟2∘<·∾⌜´/∘(0⊸=)¨)⟨0‿¯1‿0‿0,¯1‿0‿0⟩ + 2‿0‿4≡"abcd"⊐"cae" + ⟨1⟩≡"abcd"⊐"b" + (<3)≡⊐⟜(3⊸⊏)"abcd" + (5⌊3+↕5)≡⊐⟜(3‿0‿0+⚇1⊢)↕5‿2‿1 + 1‿0‿0‿1≡"acef"∊"adf" + (∊⟜(↕2)≡<⟜2)3⋆⌜○↕5 + (<1)≡3‿4‿5∊4+⌜○↕3 + ('0'≠"11010001")≡∊"abacbacd" + (↑⟜1≡⟜∊⥊⟜∞)9 + (⥊⟜1≡∊∘↕)6 + ≡⟜∊⟨⟩ + ≡○∊⟜(≍˜˘)"abcadbba" + ≡⟜⍷⟨⟩ + "ba"≡⍷"baa" + 0‿1‿0‿0≡"abc"⍷"aabcba" + (0‿1≍0‿0)≡(1‿2≍4‿5)⍷3‿3⥊↕9 + (⌽¨≡⍉)↕2⥊3 + ∧´⍉⊸≡¨⟨'a',<'a',"a","abc",""⟩ + (↕4)(-˜⌜˜≡·⍉-⌜)↕3‿2 + (2×↕3)≡0‿0⍉6+⌜○↕3 + ⟨⟩(⍉≡⊢)<4 + (2‿0‿1⥊⟨⟩)≡1‿2‿0‿1⍉↕↕4 + 2‿0‿3‿1‿4≡⍋"bdace" + 5‿2‿4‿3‿0‿1≡⍋↓"deabb" + (⍋≡⍒)⟨"",↕0,0↑<"abc"⟩ + (⍒≡⌽∘↕∘≠)⟨¯∞,¯1.5,π,∞,'A','a','b'⟩ + (⍒≡⌽∘↕∘≠)⟨↕0,¯1.1,¯1,¯1‿¯∞,¯1‿0,¯1‿0‿0,¯1‿∞,0,6⥊0,1e¯20,1,1+1e¯15⟩ + (⍒≡⌽∘↕∘≠)(<∾⟨↕0,1,1‿1,2‿1‿1,2‿1,2,1‿2,2‿2,3⟩⥊¨<)'a' + (⍋≡↕∘≠)⥊⍉(↕5)⥊⟜1⊸⥊⌜1‿'b' + (⊢≡○⍋(0‿1+≠)⥊⊢)⟨¯2,'a',1,'f'⟩ + ⟨1,2,3,1‿2,2‿1,1‿3,2‿2,3‿1⟩(⥊⊸(≠∘⊣∾˜¯1⊸⊑⊸(⌊∾⊣)∾×´⊸⌊)⌜≡○(⍋⥊)⥊⌜⟜(+`∘≠⟜(↕6)¨))↕4 + ((⥊˜-⥊⟜2‿0)∘≠≡⍋+⍒)2/↕5 + "edcba"≡∨"bdace" + (↕7)≡∧⍋|⟜⌽1+↕7 + ⟨1,3,∞,'e','i'⟩ (⍋≡≠∘⊣(⊣↓⊢⍋⊸⊏+`∘>)⍋∘∾) (2÷˜↕8)∾"aegz" + ⟨'z','d',1‿0,0⟩ (⍒≡≠∘⊣(⊣↓⊢⍋⊸⊏+`∘>)⍒∘∾) (2÷˜↕8)∾"aegz" + (<1)≡(↕2‿3)⍋1+↕3 + (<0)≡"abc"⥊⊸⍒○<≍"acc" +⟩ diff --git a/test/testref.bqn b/test/testref.bqn deleted file mode 100644 index bf455944..00000000 --- a/test/testref.bqn +++ /dev/null @@ -1,311 +0,0 @@ -# Tests of primitive functionality -# Ordering matches the reference implementations - -•←/¬⟨ - # LAYER 0 - # [0,34) - 0≡¯2+2 - 1e4≡5e3+5e3 - ¯∞≡1e6-∞ - 4≡-¯4 - ¯∞≡-∞ - ∞≡-¯∞ - 4≡9-5 - 1.5≡3×0.5 - 4≡÷0.25 - ∞≡÷0 - 0≡÷∞ - 1≡⋆0 - ¯1≡¯1⋆5 - 1≡¯1⋆¯6 - 3≡⌊3.9 - ¯4≡⌊¯3.9 - ∞≡⌊∞ - ¯∞≡⌊¯∞ - ¯1e30≡⌊¯1e30 - 1≡1=1 - 0≡¯1=∞ - 1≡1≤1 - 1≡¯∞≤¯1e3 - 0≡∞≤¯∞ - ⟨⟩≡≢<2 - ⟨3⟩≡≢"abc" - ⟨2,3⟩≡≢>"abc"‿"fed" - ⟨2,3,4,5⟩≡≢2‿3‿4‿5⥊↕120 - ⟨6⟩≡≢⥊>"abc"‿"fed" - "abc"≡0⊑"abc"‿"de" - "de"≡1⊑"abc"‿"de" - ⟨⟩≡↕0 - ⟨0⟩≡↕1 - ⟨0,1,2,3,4,5,6⟩≡↕7 - - # LAYER 1 - # [34,56) - 3≡4>◶+‿-1 - 3≡4⊢◶+‿-1 - 3≡4 1◶+‿-1 - 5≡4<◶+‿-1 - 5≡4 0◶+‿-1 - 1≡-⊘0 ¯1 - 1≡¯1-⊘+2 - "abc"≡⊢"abc" - ""≡3⊢"" - ⟨⟩≡⊣⟨⟩ - "ab"≡"ab"⊣⟨⟩ - 4≡+˜2 - 3≡1-˜4 - 1≡-∘ׯ6 - ¯6≡2-∘×3 - 1≡-○ׯ7 - 2≡5-○ׯ7 - ¯20≡1⊸-⊸×5 - (0‿2+⌜0‿1)≡(>⟨"ab","cd"⟩)≢⊸⥊↕4 - 20≡×⟜(-⟜1)5 - 4≡5+⟜ׯ3 - 7≡5+⟜2 ¯3 - # [56,95) - 2≡√4 - 3≡3√27 - 6≡2∧3 - 0≡¯2∧0 - 0.75≡∨˜0.5 - 1.75≡2∨0.25 - 0≡¬1 - 1≡¬0 - 2≡¬¯1 - 0≡3¬4 - 2≡4¬3 - 4≡5¬2 - 0≡|0 - 5≡|¯5 - 6≡|6 - ∞≡|¯∞ - 2≡3|8 - 2≡3|¯7 - ¯1≡¯3|8 - "a"≡⥊<'a' - "abcd"≡⊑<"abcd" - ⟨⟩≡≢<⟨2,⟨3,4⟩⟩ - 0≡4<2 - 0≡5>5 - 0≡3≥4 - 0≡≠"" - 1≡≠"a" - 1≡≠'a' - 2≡≠"ab" - 25≡≠↕25 - 1≡×5 - ¯1≡ׯ2.5 - 3≡3⌊4 - ¯3≡¯3⌊∞ - 4≡3⌈4 - 1≡1⌈¯1 - 5≡⌈4.01 - ⟨⟩≡≢'a' - ⟨⟩≡≢0 - # [95,104) - ⟨0⟩‿⟨1⟩‿⟨2⟩≡⥊¨↕3 - (↕6)≡⟜(≠¨)○(2‿3⊸⥊)⟨⟩‿"a"‿"ab"‿"abc"‿"abcd"‿"abcde"‿"abcdef" - ≡⟜(≠¨)4‿0‿2⥊↕0 - 6≡+´↕4 - (⊑≡⊣´)"a"‿2‿(3‿"d") - 0(⊑≡⊣´)"a"‿2‿(3‿"d") - (2⊸⊑≡⊢´)"a"‿2‿(3‿"d") - 2(⊣≡⊢´)"a"‿2‿(3‿"d") - 7‿10≡+¨´⟨⟨2,3⟩,⟨5,7⟩⟩ - - # LAYER 2 - # [104,117) - ⟨⟩≡⟨⟩∾"" - "a"≡⟨⟩∾"a" - "a"≡"a"∾⟨⟩ - "aBCD"≡"a"∾"BCD" - ((+⌜˜≠¨)≡(≠¨∾⌜˜))""‿⟨2,3⟩‿"abcde" - (⥊⟜(↕×´)≡(×⟜4)⊸(+⌜)○↕´)3‿4 - (⥊⟜(↕×´)≡(×⟜4)⊸(+⌜)○↕´)0‿4 - (3‿2‿0⥊"")≡(3‿2⥊↕6)+⌜"" - (<<2)≡<¨2 - ⟨1,⟨3,2,2‿2⥊⟨1,0,2,0⟩⟩,⟨5,4⟩⟩≡-⟨-1,⟨-3,-2,-¨2‿2⥊⟨1,0,2,0⟩⟩,⟨-5,-4⟩⟩ - 3(+¨≡+⌜)↕6 - 3‿4‿5‿6‿6≡{F:F⍟(×≡)⊸∾⟜⥊´𝕩}⟨2,1⟩+⟨⟨⟨⟨1,2⟩,3⟩,4⟩,5⟩ - (=¨⟜(⥊⟜(↕×´)3‿4)≡(↕4)=⌜˜4|⊢)1‿6‿8 - - # LAYER 3 - # [117,152) - 2≡⊑⟨2⟩ - "ab"≡⊑⟨"ab"⟩ - 0≡⊑↕20 - 4≡⊑3‿2‿1⥊4⥊⊸∾5⥊0 - 'c'≡2⊑"abcd" - 'c'≡¯2⊑"abcd" - 7≡7⊑↕10 - 21≡2‿¯3⊑(10×↕3)+⌜↕4 - 21‿12‿03≡⟨2‿¯3,1‿2,0‿¯1⟩⊑(10×↕3)+⌜↕4 - "dfeb"≡(⥊¨-⟨3,1,2,5⟩)⊑"abcdef" - "abc"≡⟨⟩⊑<"abc" - ⟨7,7‿7,7⟩≡⟨⟨⟩,⟨⟨⟩,⟨⟩⟩,⟨⟩⟩⊑<7 - ⟨7,⟨7,<7⟩⟩≡⟨⟨⟩,⟨⟨⟩,<⟨⟩⟩⟩⊑7 - "abcfab"≡⥊(↕2‿3)⊑5‿5⥊"abcdef" - "aedcaf"≡⥊(-↕2‿3)⊑5‿5⥊"abcdef" - (<6⥊0)(⊑≡<∘⊑∘⊢)(6⥊1)⥊5 - ¯6≡1‿0◶(2‿2⥊0‿0‿-‿0)6 - ⟨3⟩≡⥊3 - ⟨3,3,3⟩≡3⥊3 - 6(⊢⌜≡∾○≢⥊⊢)○↕3 - (<≡↕)⟨⟩ - (↕∘⥊≡⥊¨∘↕)9 - ¬'a'≡<'a' - ¬"a"≡≍"a" - ¬⟨1,2,⟨4,4⟩,5⟩≡○(2‿2⊸⥊)⟨1,2,⟨3,4⟩,5⟩ - ¬2‿3‿4≡2‿3 - ¬1.001≡1.002 - 'a'≢2 - 0≡≡'a' - 1≡≡↕6 - 2≡≡↕2‿4 - 3≡≡<<<4 - (1¨≡-○≡˜⟜↕¨)⟨0,⟨⟩,⟨1⟩,2,⟨3,4⟩⟩ - 2≡≡⟨5,⟨'c',+,2⟩⟩ - 0≡≡⊑⟨-⟩ - - # LAYER 4 - # [152,183) - ≡⟜><'a' - ≡⟜><∞ - ≡⟜>↕5 - ≡⟜>5‿3⥊2 - 2‿3‿2≡≢>↕2‿3 - ((4⥊2)⊸⥊≡(>2‿2⥊·<2‿2⥊⊢))"abcd" - (⊢≡>∘<)5‿3⥊↕15 - (⊢≡(><¨))5‿3⥊↕15 - (⥊≡≍)'a' - (⥊≡≍)<'a' - (1‿2⊸⥊≡≍)"ab" - 1‿2≡1≍2 - 2‿1(≍≡2‿2⥊∾)4‿3 - (≍⟜<≡≍˜)'a' - (≍˘˜⥊˘1‿5‿9)≡⌽⎉2⊸+⥊⟜(↕×´)3‿2‿1 - (↕4)(×⌜≡×⎉0‿2)↕5 - (↕4)(⋆˜⌜˜≡⋆⎉∞‿¯4)↕5 - (⟨2⟩⊸∾⍟(2‿2⥊0‿1‿1‿1)2‿3)≡≢¨≍⎉(⌊○=)⌜˜⟨↕3,2‿3⥊↕6⟩ - (2=⌜○↕3)≡(2‿4⥊"abc")≡⎉1(2‿3‿4⥊"abc") - ⟨0,0⟩≡(2‿4⥊"abc")≡⎉¯1(2‿3‿4⥊"abc") - ⟨5,⟨15,1⟩⟩≡+´⚇1⟨⟨3,2⟩,⟨⟨4,5,6⟩,⟨1⟩⟩⟩ - 5‿6‿15≡∾´+´⚇1⟨⟨0,1⟩,⟨⟨⟩⟩⟩⥊⊸∾⚇¯2‿1⟨⟨2,3⟩,⟨4,5,6⟩⟩ - 4≡2+⍟¯1 6 - (2×↕7)≡2+⍟(¯3+↕7)6 - (3⌊↕5)≡{i←0⋄r←{i+↩1⋄1+𝕩}⍟(↕4)𝕩⋄r∾i}0 - (+⌜˜≡·>1+⍟⊢⊢)↕5 - 0‿1‿3‿6‿10≡+`↕5 - (-0‿1‿3‿6‿10)≡-`↕5 - ((0∾¨↕3)≍3⥊0)≡≡`↕2‿3 - ⟨⟩≡×`⟨⟩ - ≡⟜(!∘0`)3‿0‿2⥊"" - - # LAYER 5 - # [183,230) - (<'a')≡⊏"abc" - "a"≡⊏⥊˘"abc" - (<'c')≡2⊏"abc" - (<'c')≡¯1⊏"abc" - "ccc"≡2‿¯1‿2⊏"abc" - ((3-˜↕5)⊸⊏≡2⊸⌽)↕5‿2 - (0‿3⥊0)≡⟨⟩⊏2‿3⥊↕6 - ⟨3‿0,2‿1‿2⟩(×⟜5⊸+⌜´∘⊣≡⊏)⥊⟜(↕×´)6‿5 - (2‿0⥊0)≡⟨3‿¯1,⟨⟩⟩⊏4‿3⥊0 - 5‿1(<⊸⊏≡⊏)↕6‿2 - ⟨4‿0,1‿2‿3‿2‿1‿0⟩(+⌜´⊸(×⌜)≡⊏⟜(×⌜˜))+⌜˜↕5 - "abc"≡3↑"abce" - "e"≡¯1↑"abce" - ""≡0↑"ab" - (<⟜3⊸×↕5)≡5↑↕3 - (6⥊0)≡¯6↑↕0 - (≍↕3)≡1↑2‿3⥊↕6 - (↑⟜4≡⥊⟜0)↕3 - (≍"abc")≡1↑2‿3↑"abcd" - (6⥊1)(↑≡⥊⟜⊑)2‿3⥊↕6 - (↕¨∘↕∘(1⊸+)≡↑∘↕)5 - (↑≡((↕4)≍¨2)⥊¨<)3‿2⥊"abcdef" - "d"≡3↓"abcd" - 1‿2≡⟜(¯3⊸↓)○↕4‿2 - 1‿1‿3‿2‿1≡≢(5⥊0)↓↕3‿2‿1 - (↓∘↕≡↕∘(1⊸+)+⟜⌽↑∘↕)5 - (↕3‿4)≡1↓¨⊏↕2‿3‿4 - (4+⌜○↕2)≡2↕↕5 - ⟨⟩(↕≡⊢)4‿3⥊"abcd" - (0⊸↕≡(0≍˜1+≠)⊸⥊)↕6 - (7↕6‿0⥊"")≡0‿7‿0⥊"" - ≡⟜⌽⟨⟩ - ≡⟜⌽"a" - "ba"≡⟜⌽"ab" - (⌽≡(1-˜≠)(-○⊑∾1↓⊢)⚇1⊢)↕3‿2‿4 - ≡⟜⌽↕↕3 - ∧´5(⌽≡⊢)¨⟨"",⥊∞,↕5,↕0‿4,2‿0‿3⥊""⟩ - ∧´("bcdea"≡⌽⟜"abcde")¨1+5ׯ10‿¯2‿¯1‿0‿1‿6‿61 - ∧´⟨1,0‿2,¯1‿1‿3⟩(⊑∘⌽≡(3⊸↑)⊸⊑)⚇¯1‿∞ 2‿3‿5⥊"abcdef" - ⟨⟩(⌽≡⊢)'a' - 0‿4≡/1‿0‿0‿0‿1‿0 - 1‿1‿2≡/0‿2‿1 - ≡⟜/⟨⟩ - "aabbcc"≡2/"abc" - 3‿3‿3‿2‿2‿1≡/˜3‿2‿1 - (≍1∾¨1‿2‿2)≡(↕¨/↕)2‿3 - ⟨⟩(/≡⊢)≍"ab" - - # LAYER 6 - # [230,270) - ≡⟜(∾⥊¨)"abc" - (∾´≡∾)"ab"‿"cde"‿"" - 1‿2‿3‿4‿6‿9≡∾(⊢×≠↑↓)1+↕3 - ≡⟜∾⟨⟩ - ⟨1‿4,⥊2⟩((∾⋆⌜⌜)≡⋆⌜○∾)⟨2‿3‿4,⟨⟩,⥊5⟩ - "abcd"≡"abc"∾'d' - "abcd"≡"abc"∾<'d' - (↕4‿3)≡(↕3‿3)∾3∾¨↕3 - (∾˜≡·¯1⊸(×´∘↓∾↑)∘≢⊸⥊≍˜)2‿3⥊"abcdef" - (∾´≡∾)⟨3‿2‿1,0‿2‿1⟩⥊¨<↕6 - ⟨1‿2,⥊0,⥊3⟩≡⊔1‿0‿0‿2 - 4‿3‿2(≍○<≡·(≠¨≍○<∾)/⊸⊔)"abcdefghi" - ⟨⟩≡(3⥊¯1)⊔"abc" - (≍˘1‿1‿4<∘⥊⎉1 16‿4+⌜↕4)≡2↓⟨3‿2,¯1‿0‿¯1⟩⊔2‿3‿4⥊↕24 - ⥊⚇0⊸≡○⊔⟜(⥊<)1‿2‿2‿¯1‿0 - (⊔≡·≍⍟2∘<·∾⌜´/∘(0⊸=)¨)⟨0‿¯1‿0‿0,¯1‿0‿0⟩ - 2‿0‿4≡"abcd"⊐"cae" - ⟨1⟩≡"abcd"⊐"b" - (<3)≡⊐⟜(3⊸⊏)"abcd" - (5⌊3+↕5)≡⊐⟜(3‿0‿0+⚇1⊢)↕5‿2‿1 - 1‿0‿0‿1≡"acef"∊"adf" - (∊⟜(↕2)≡<⟜2)3⋆⌜○↕5 - (<1)≡3‿4‿5∊4+⌜○↕3 - ('0'≠"11010001")≡∊"abacbacd" - (↑⟜1≡⟜∊⥊⟜∞)9 - (⥊⟜1≡∊∘↕)6 - ≡⟜∊⟨⟩ - ≡○∊⟜(≍˜˘)"abcadbba" - ≡⟜⍷⟨⟩ - "ba"≡⍷"baa" - 0‿1‿0‿0≡"abc"⍷"aabcba" - (0‿1≍0‿0)≡(1‿2≍4‿5)⍷3‿3⥊↕9 - (⌽¨≡⍉)↕2⥊3 - ∧´⍉⊸≡¨⟨'a',<'a',"a","abc",""⟩ - (↕4)(-˜⌜˜≡·⍉-⌜)↕3‿2 - (2×↕3)≡0‿0⍉6+⌜○↕3 - ⟨⟩(⍉≡⊢)<4 - (2‿0‿1⥊⟨⟩)≡1‿2‿0‿1⍉↕↕4 - 2‿0‿3‿1‿4≡⍋"bdace" - 5‿2‿4‿3‿0‿1≡⍋↓"deabb" - (⍋≡⍒)⟨"",↕0,0↑<"abc"⟩ - (⍒≡⌽∘↕∘≠)⟨¯∞,¯1.5,π,∞,'A','a','b'⟩ - (⍒≡⌽∘↕∘≠)⟨↕0,¯1.1,¯1,¯1‿¯∞,¯1‿0,¯1‿0‿0,¯1‿∞,0,6⥊0,1e¯20,1,1+1e¯15⟩ - (⍒≡⌽∘↕∘≠)(<∾⟨↕0,1,1‿1,2‿1‿1,2‿1,2,1‿2,2‿2,3⟩⥊¨<)'a' - (⍋≡↕∘≠)⥊⍉(↕5)⥊⟜1⊸⥊⌜1‿'b' - (⊢≡○⍋(0‿1+≠)⥊⊢)⟨¯2,'a',1,'f'⟩ - ⟨1,2,3,1‿2,2‿1,1‿3,2‿2,3‿1⟩(⥊⊸(≠∘⊣∾˜¯1⊸⊑⊸(⌊∾⊣)∾×´⊸⌊)⌜≡○(⍋⥊)⥊⌜⟜(+`∘≠⟜(↕6)¨))↕4 - ((⥊˜-⥊⟜2‿0)∘≠≡⍋+⍒)2/↕5 - "edcba"≡∨"bdace" - (↕7)≡∧⍋|⟜⌽1+↕7 - ⟨1,3,∞,'e','i'⟩ (⍋≡≠∘⊣(⊣↓⊢⍋⊸⊏+`∘>)⍋∘∾) (2÷˜↕8)∾"aegz" - ⟨'z','d',1‿0,0⟩ (⍒≡≠∘⊣(⊣↓⊢⍋⊸⊏+`∘>)⍒∘∾) (2÷˜↕8)∾"aegz" - (<1)≡(↕2‿3)⍋1+↕3 - (<0)≡"abc"⥊⊸⍒○<≍"acc" -⟩ diff --git a/test/tj.js b/test/tj.js deleted file mode 100755 index 92645037..00000000 --- a/test/tj.js +++ /dev/null @@ -1,34 +0,0 @@ -#! /usr/bin/env node - -let bqn = require(__dirname+'/../docs/bqn.js'); -let load = f=>require('fs').readFileSync(__dirname+'/'+f,'utf8'); -let args = process.argv.slice(2); -let ref = args[0]==="-ref"; - -if (ref || args.length==0) { - let t = (load('cases.bqn')+load('bcases.bqn')) - .split('\n').filter(x=>x).map(x=>x.split(' % ')); - let test = t.map(e=>e[1]); - let expt = t.map(e=>+e[0]); - if (ref) { - let r = load('testref.bqn').split('\n') - .filter(x=>x.charAt(0)===' ' - &&x.charAt(1)===' ' - &&x.charAt(2)!=='#' - &&x.indexOf(':')===-1) - .map(x=>x.slice(2)); - test = test.concat(r); - expt = expt.concat(r.map(e=>1)); - } - - let rslt = test.map(bqn); - 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]) - : "All "+test.length+" passed!" - ); -} else { - console.log(args.map(bqn)); -} diff --git a/test/tw.js b/test/tw.js deleted file mode 100755 index b8faa668..00000000 --- a/test/tw.js +++ /dev/null @@ -1,27 +0,0 @@ -#! /usr/bin/env node - -const execFile = require('child_process').execFile - , 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 = execFile( - __dirname+'/../wcshim.bqn', - [ '{•←WCompile𝕩}¨⟨'+test+'⟩' ], - 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)) - } -); -- cgit v1.2.3