diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-11-27 16:02:34 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-11-27 16:05:28 -0500 |
| commit | 021fb5911afe12e8f0085a1c1ce6ad397719fe11 (patch) | |
| tree | 5a7b18cc303efb1473b20c014ebdbf13eb027f3f | |
| parent | b9a41bf4639343573dbd3b9a25ca3a6e3930cd6b (diff) | |
Allow testing the runtime in dz_comp, making dzref_full and dz_rt unnecessary
| -rwxr-xr-x | dzref_full | 67 | ||||
| -rw-r--r-- | test/README.txt | 15 | ||||
| -rwxr-xr-x | test/dz_comp | 29 | ||||
| -rwxr-xr-x | test/dz_rt | 21 |
4 files changed, 35 insertions, 97 deletions
diff --git a/dzref_full b/dzref_full deleted file mode 100755 index ab1c9886..00000000 --- a/dzref_full +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env dbqn - -# This version of dzref defines every primitive that spec/reference.bqn -# does. It's intended to test out these implementations for use in the -# BQN runtime; use plain dzref if you just want to run BQN as it's much -# faster and supports inverses better. - -impl ← •LNS "src/r.bqn" - -X←Raw←{F:≤4} -{v: - 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) ∾ " ← " ∾ 𝕩} - - ⍎¨ ⟨ - "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 - } - - lf ← @+10 - pre ← E_isdef◶E_proc‿E_redef¨ impl - Raw↩⍎ - ExecFile←{Raw ∾ ∾⟜lf¨ E_proc¨ •LNS 𝕩} - X↩Raw∘E_proc - ⍎ ∾ ∾⟜lf¨ pre - ≠◶X‿{ExecFile ⊑𝕩}‿{ExecFile ⊑𝕩 ⋄ X 1⊑𝕩} •args -} diff --git a/test/README.txt b/test/README.txt index 4a000dbc..26f2d4e6 100644 --- a/test/README.txt +++ b/test/README.txt @@ -1,16 +1,19 @@ Test scripts: - Script Compiler host Output host -- js [-prim] Self-host BQN on Javascript + Script Compiler host Output host/VM +- js [-prim] Self-host Javascript - dz_comp [-prim] dzaima/BQN dzaima/BQN -- dz_rt dzaima/BQN BQN on dzaima/BQN - dz_wasm.js dzaima/BQN WebAssembly +dz_comp uses the self-hosted compiler ../src/c.bqn by default but not +the runtime ../src/r.bqn. Pass -rt to test with the runtime, and -comp +to test dzaima/BQN only (this doesn't pass as of the time of writing). + Test cases: - js dz_comp dz_rt dz_wasm.js -- cases.bqn * * * + js dz_comp dz_wasm.js +- cases.bqn * * * - bcases.bqn * * -- prim.bqn -prim -prim * +- prim.bqn -prim -prim Contents of bin/dbqn follow (3 lines). Replace "/path/to/dzaima/" with your path. diff --git a/test/dz_comp b/test/dz_comp index dfa4bd6b..9f336b07 100755 --- a/test/dz_comp +++ b/test/dz_comp @@ -1,8 +1,31 @@ #! /usr/bin/env dbqn -⟨DRun⟩ ← •Import "../dc.bqn" +nc‿rt‿prim ← "-nocomp"‿"-rt"‿"-prim" ∊ •args +"Can't test runtime without the compiler!" ! ¬nc∧rt + +⟨DRun,DCompile⟩ ← •Import "../dc.bqn" + +GetRT ← {𝕤: + ⟨ref⟩ ← •Import "../src/pr.bqn" + provide ← ⟨ + 0≠≡ # IsArray + ⊑⟨⟩⥊0⊸⥊ # Type + ⋆⁼ # Log + ≠¨⊔ # GroupLen + ∾⊔∘⊢ # GroupOrd + !,+,-,×,÷,⋆,⌊,=,≤,≢,⥊,⊑,↕,⌜,`,⊘ + ⟩ + •COMP provide⊸(⊣»«)⌾(1⊸⊑) DCompile ref +} + +Native ← {⍎𝕩} +exec ← (rt¬nc)◶⟨Native˙, DRun˙, {𝕩⊸DRun}∘GetRT⟩ @ + c ← ∾(•LNS ∾⟜"cases.bqn")¨""‿"b" -{𝕩: c ∾↩ (¬":"⊑∘∊⊢)¨⊸/ "1 %"⊸∾¨ (0<≠)◶0‿('#'≠⊑)¨⊸/ •LNS "prim.bqn" }⍟⊢⊑(<"-prim")∊•args -M ← {e‿b: (⍎e)⊸≢◶""‿{(@+10)∾˜""""∾b∾""": expected "∾e∾" but received "∾⍕𝕩} DRun b} +{𝕩: c ∾↩ "1 %"⊸∾¨ (0<≠)◶0‿((¬":"⊑∘∊⊢)∧'#'≠⊑)¨⊸/ •LNS "prim.bqn" }⍟⊢ prim +M ← {e‿b: + Err ← {(@+10)∾˜""""∾b∾""": expected "∾e∾" but received "∾⍕𝕩} + (Native e) ≢◶""‿Err Exec b +} r ← '%' M∘((+`-2⊸×)∘=⊔⊢)¨ c •Out ("All "∾(⍕≠c)∾" passed!")⍟(0=≠) ∾r diff --git a/test/dz_rt b/test/dz_rt deleted file mode 100755 index 9d2f2aa9..00000000 --- a/test/dz_rt +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env dbqn - -# Compile and run the primitive implementations, and prim.bqn - -⟨ref⟩ ← •Import "../src/pr.bqn" -⟨DRun,DCompile⟩ ← •Import "../dc.bqn" - -provide ← ⟨ - 0≠≡ # IsArray - ⊑⟨⟩⥊0⊸⥊ # Type - ⋆⁼ # Log - ≠¨⊔ # GroupLen - ∾⊔∘⊢ # GroupOrd - !,+,-,×,÷,⋆,⌊,=,≤,≢,⥊,⊑,↕,⌜,`,⊘ -⟩ -rt ← •COMP provide⊸(⊣»«)⌾(1⊸⊑) DCompile ref - -t ← "¬⟨"‿"⟩" (1⌽⌽⊸∾) (¬∘⊑':'∊⊢)¨⊸/ •LNS "prim.bqn" -res ← rt DRun ∾ ∾⟜(@+10)¨ t - -•Out ("All "∾(⍕≠res)∾" passed!")⍟(0=≠) /res |
