aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-01 16:22:09 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-01 16:30:33 -0400
commit10b72d3a9a74cda526219bdc149dac8feb3f25e4 (patch)
treef6cd814796e5396677e5626f1beae2925fb02a1a /test
parent0a5ec5b2c31eccda5e00239df80ae3675a51b0a2 (diff)
Move all dzaima/BQN-specific tools into test/
Diffstat (limited to 'test')
-rwxr-xr-xtest/dc.bqn18
-rwxr-xr-xtest/dz_comp17
-rw-r--r--test/dzrt.bqn23
3 files changed, 52 insertions, 6 deletions
diff --git a/test/dc.bqn b/test/dc.bqn
new file mode 100755
index 00000000..5a0ccae8
--- /dev/null
+++ b/test/dc.bqn
@@ -0,0 +1,18 @@
+#! /usr/bin/env dbqn
+
+# dzaima/BQN block headers have a different format to account for
+# multiple bodies, and use variable names instead of counts.
+# Rearrange and make up some names so the bytecode can be run.
+
+glyphs ← •Import∘"../src/glyphs.bqn"⍟(0=≠) •args
+compile ← glyphs •Import "../src/c.bqn"
+
+special←<˘∘‿2⥊"𝕤𝕩𝕨𝕣𝕗𝕘"
+DCompile⇐{
+ ⟨bc,o,fblk,fbdy,ind,tok⟩ ← 6 ↑ (𝕨 •BQN∘⥊¨∘∾⊘⊣ glyphs) Compile 𝕩
+ name ← ⊑2⊑tok
+ blk ← 2(↑∾≍˜∘⊑)¨fblk
+ bdy ← {⟨l,n,d,e⟩←𝕩 ⋄ ⟨l,((<"")⥊˜n-≠d)∾d⊏name,n-⊸↑e⟩}¨fbdy
+ ⟨bc,o,blk,⊑blk,bdy,name,⊑ind,1⊑ind,𝕩⟩
+}
+DRun⇐•COMP∘DCompile
diff --git a/test/dz_comp b/test/dz_comp
index 9815bb40..e9bf1c06 100755
--- a/test/dz_comp
+++ b/test/dz_comp
@@ -5,12 +5,17 @@ files ← "simple"‿"syntax"‿"prim"⍟(0=≠) ('-'≠⊑)¨⊸/ •args
"Can't test runtime without the compiler!" ! ¬nc∧rt∨ref
Native ← •BQN
-exec ← ((rt⌈2×ref)¬nc)◶⟨
- Native˙ # Native
- {𝕤⋄ ⟨DRun⟩←•Import "../dc.bqn" ⋄ DRun} # Compiled; native runtime
- {𝕤⋄ •Import "../bqn.bqn"} # Self-hosted
- {𝕤⋄ ⟨DRun⟩←•Import "../dc.bqn" ⋄ (•Import"ref.bqn")⊸DRun} # Reference implementations
-⟩ @
+exec ← {
+ nc ? Native ;
+ # Otherwise compiled
+ ⟨DRun⟩ ← •Import "dc.bqn"
+ r ← {
+ ref ? •Import "ref.bqn" ; # Reference implementations
+ rt ? •Import "dzrt.bqn" ; # Self-hosted
+ •BQN∘⥊¨ ∾ •Import "../src/glyphs.bqn" # Native runtime
+ }
+ r⊸DRun
+}
Cases ← (0<≠)◶0‿('#'≠⊑)¨⊸/ · •FLines "cases/"∾∾⟜".bqn"
c ← ∾ Cases¨ files
diff --git a/test/dzrt.bqn b/test/dzrt.bqn
new file mode 100644
index 00000000..ae217e07
--- /dev/null
+++ b/test/dzrt.bqn
@@ -0,0 +1,23 @@
+# Runtime hosted in dzaima/BQN
+
+⟨src,need⟩ ← •Import "../src/pr.bqn"
+⟨DRun⟩ ← •Import "dc.bqn"
+⟨DCompile⟩ ← need •Import "dc.bqn"
+glyphs ← ∾ gl ← •Import "../src/glyphs.bqn"
+
+GroupLen ← {(𝕨⌈≠)⊸↑0•FillFn≠¨⊔𝕩}
+extra ← ⟨ •Type, •FillFn, ⋆⁼, GroupLen, ∾⊔∘⊢, •_fillBy_ ⟩
+provide ← { g←𝕩∊glyphs ⋄ (⍋⍋g)⊏extra∾•BQN¨g/𝕩 } ∾need
+
+rt‿SetPrims ← •COMP ⟨provide,(•BQN"•"⊸∾)¨⟩ DCompile src
+PrimInd ← rt⊸⊐⌾<
+Decompose ← ((≠glyphs)>PrimInd)◶⟨•Decompose,0⊸≍⟩
+SetPrims ⟨ Decompose, PrimInd ⟩
+
+sys ← {𝕩⊏˜𝕨⊸⊐}˝⍉>⟨
+ "bqn"‿{BQN𝕩}
+ "type"‿•Type
+ "glyph"‿(glyphs⊑˜PrimInd)
+ "decompose"‿Decompose
+⟩
+⟨rt,Sys⟩