aboutsummaryrefslogtreecommitdiff
path: root/test/dzaima
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-01 16:51:04 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-11-01 16:51:04 -0400
commit93217d7cce249854248ce68d455705253cf63a65 (patch)
treeaad94c9b71d94247c6c31c171a044895b3171701 /test/dzaima
parentd827ec77a2a53f4b99455b0512c7b2fd237d353c (diff)
Clean up test directory structure
Diffstat (limited to 'test/dzaima')
-rwxr-xr-xtest/dzaima34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/dzaima b/test/dzaima
new file mode 100755
index 00000000..e9bf1c06
--- /dev/null
+++ b/test/dzaima
@@ -0,0 +1,34 @@
+#! /usr/bin/env dbqn
+
+nc‿rt‿ref ← "-nocomp"‿"-rt"‿"-ref" ∊ •args
+files ← "simple"‿"syntax"‿"prim"⍟(0=≠) ('-'≠⊑)¨⊸/ •args
+"Can't test runtime without the compiler!" ! ¬nc∧rt∨ref
+
+Native ← •BQN
+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
+Trim ← ((∨`∧∨`⌾⌽)' '⊸≠)⊸/
+M ← {e‿b:
+ Msg ← {∾⟨
+ """",b,""": expected "
+ "to fail"⍟("!"⊸≡)e
+ " but "
+ 0⊸≡◶⟨"received "∾2•Fmt⊑,"evaluation failed"⟩𝕩
+ ⥊@+10
+ ⟩}
+ ("!"⊸≡◶⟨<Native,0˙⟩ e) ≢◶""‿Msg <∘Exec⎊0 b
+}
+r ← (M '%'⊸= (∨´⊣)◶⟨"1"≍○<⊢, Trim¨(+`-2⊸×)⊸⊔⟩ ⊢)¨ c
+•Out ("All "∾(•Repr≠c)∾" passed!")⍟(0=≠) ¯1↓∾r