diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-17 14:14:00 -0500 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-02-17 14:14:00 -0500 |
| commit | 23f0e74e70c01f3850b94d56c7145b0bd9e63f61 (patch) | |
| tree | 794526e87ee9f3221ec1ffcfe222ee6590f1570a /test | |
| parent | 093d9e22e058bc516020d64ae23c42833e35d1ae (diff) | |
Add testing mode using reference implementations
Diffstat (limited to 'test')
| -rwxr-xr-x | test/dz_comp | 9 | ||||
| -rw-r--r-- | test/ref.bqn | 36 |
2 files changed, 41 insertions, 4 deletions
diff --git a/test/dz_comp b/test/dz_comp index 6bb8fb3c..a9cfd531 100755 --- a/test/dz_comp +++ b/test/dz_comp @@ -1,14 +1,15 @@ #! /usr/bin/env dbqn -nc‿rt ← "-nocomp"‿"-rt" ∊ •args +nc‿rt‿ref ← "-nocomp"‿"-rt"‿"-ref" ∊ •args files ← "simple"‿"syntax"‿"prim"⍟(0=≠) ('-'≠⊑)¨⊸/ •args -"Can't test runtime without the compiler!" ! ¬nc∧rt +"Can't test runtime without the compiler!" ! ¬nc∧rt∨ref Native ← {⍎𝕩} -exec ← (rt¬nc)◶⟨ +exec ← ((rt⌈2×ref)¬nc)◶⟨ Native˙ # Native {𝕤⋄ ⟨DRun⟩←•Import "../dc.bqn" ⋄ DRun} # Compiled; native runtime - {𝕤⋄ •Import"../bqn.bqn"} # Self-hosted + {𝕤⋄ •Import "../bqn.bqn"} # Self-hosted + {𝕤⋄ •Import "ref.bqn"} # Reference implementations ⟩ @ Cases ← (0<≠)◶0‿('#'≠⊑)¨⊸/ · •FLines "cases/"∾∾⟜".bqn" diff --git a/test/ref.bqn b/test/ref.bqn new file mode 100644 index 00000000..e6cb40a5 --- /dev/null +++ b/test/ref.bqn @@ -0,0 +1,36 @@ +src ← ""⊸≢¨⊸/ (∧`'#'⊸≠)⊸/¨ •FLines "../spec/reference.bqn" +lines ← (¯1↓∾)¨(src∾¨@+10)⊔˜+`»0=+`+´¨+˝-˝("{⟨"≍"}⟩")=⌜src +assume‿defs ← (∨´∊⟜"←↩")¨⊸⊔ lines +LC ← ⊢+('a'-'A')×1="A["⊸⍋ +anames‿names ← (LC' '⊸≠⊸/)¨¨ ⟨assume, (∧`·¬∊⟜"←↩")⊸/¨ defs⟩ + +nIsP←(1=≠)¨names +NextSame ← ≠(⊢⍋⊸⊏○∾«¨)⊔∘⊐ +range ← {(≠⌜˜ ∧ nIsP ≤⎉1 ≥⌜˜ ∧ (NextSame𝕩)>⌜⊢) ↕≠𝕩} names + +idChars ← "_¯.π∞𝕣"∾∾"0aA"+⟜↕¨10‿26‿26 +defTok ← (¯1+`·¬·»⊸∧∊⟜idChars)⊸⊔¨ defs +depend ← <∘/˘ range ∧ > (names∊LC¨)¨ (0=·+`·-˝"{"‿"}"≡⌜⊢)⊸/¨defTok +order ← {{𝕊⍟(𝕩<○≠⊢)⟜(𝕩∾·/𝕨⊸<)𝕨∨∧´∘⊏⟜𝕨¨l}⟜/0¨l←𝕩} depend + +chrs←⟨ + "+-×÷⋆√⌊⌈|¬∧∨<>≠=≤≥≡≢⊣⊢⥊∾≍↑↓↕«»⌽⍉/⍋⍒⊏⊑⊐⊒∊⍷⊔!" + "˙˜˘¨⌜⁼´˝`" + "∘○⊸⟜⌾⊘◶⎉⚇⍟" +⟩ + +def‿keep ← ⊑¨⌾(1⊸⊑) (1=≠)¨⊸⊔ anames +keep∾↩"⌾" +pre←"IsArray←0<≡"‿"_amend←{𝕨˙⌾(𝕗⊸⊑)𝕩}"‿"Identity←{𝕏´⟨⟩}"‿"Fill←•FillFn" + +GetRepls ← { + ki ← (⊑¨⊑𝕩)∊keep + ⊣⌾(ki⊸/)` 𝕩 +} + +⟨E_proc⟩ ← chrs‿GetRepls •Import "../src/pp.bqn" + +rslt ← "⟨"∾"⟩"«∾","⊸∾¨∾chrs # Output all primitives +rt ← {⍎𝕩} ∾∾⟜(@+10)¨ pre ∾ order∾⟜≠⊸⊏E_proc¨ defs∾<rslt +⟨DRun,DCompile⟩ ← •Import "../dc.bqn" +rt⊸DRun |
