From 2f18c0546ff739286554adc0c7cb7b5c0dd42cac Mon Sep 17 00:00:00 2001 From: dzaima Date: Sun, 1 Jun 2025 07:01:10 +0300 Subject: [PATCH] split up & move test/various.bqn to test/run.bqn system --- test/README.md | 1 - test/cases/fuzz/arith.bqn | 25 ++++++++ test/cases/fuzz/group.bqn | 16 +++++ test/cases/fuzz/scan.bqn | 23 ++++++- test/cases/unnecessary/fuzz-slash.bqn | 31 ++++++++++ test/various.bqn | 88 --------------------------- 6 files changed, 94 insertions(+), 90 deletions(-) create mode 100644 test/cases/fuzz/arith.bqn create mode 100644 test/cases/fuzz/group.bqn create mode 100644 test/cases/unnecessary/fuzz-slash.bqn delete mode 100644 test/various.bqn diff --git a/test/README.md b/test/README.md index 93fb0624..5195f832 100644 --- a/test/README.md +++ b/test/README.md @@ -7,7 +7,6 @@ test/mainCfgs.sh path/to/mlochbaum/BQN // run the test suite for a couple primar test/x86Cfgs.sh path/to/mlochbaum/BQN // run the test suite for x86-64-specific configurations, including singeli; 32-bit build is "supposed" to fail one test involving ⋆⁼ test/moreCfgs.sh path/to/mlochbaum/BQN // run "2+2" in a bunch of configurations; requires dzaima/BQN to be accessible as dbqn test/run.bqn // run tests in test/cases/ -./BQN test/various.bqn // tests for various small things ./BQN test/joinReuse.bqn // test in-place join; requires -DPRINT_JOIN_REUSE make -C test/ffi // test FFI functionality; expects both regular and shared library CBQN builds to already exist diff --git a/test/cases/fuzz/arith.bqn b/test/cases/fuzz/arith.bqn new file mode 100644 index 00000000..77b9074b --- /dev/null +++ b/test/cases/fuzz/arith.bqn @@ -0,0 +1,25 @@ +( + helpers ← ⊑•args + R ← (helpers.GetRand@).Range + ⟨EEqual, Variation⟩ ⇐ •internal + + Mod ← {𝕊: + modOptions ← ⟨∞,¯∞,0÷0⟩ ∾ ∾⟜- 2⋆↕34 + {𝕊: + n ← R 2⋆4+R 6 + w ← R∘≠⊸⊑ modOptions + x ← -⍟(R 2) (2⋆R 34) + (↕n)-R n + got ← w|x + exp ← w|"Ah" Variation x + ¬exp EEqual got? + •Out "𝕨: "∾•Repr w + •Out "𝕩: "∾(•Repr x)∾" / "∾•internal.Info x + •Out "exp: "∾•Repr exp + •Out "got: "∾•Repr got + !0 + ;@ + }¨ ↕𝕩 + } + + •Show "powerOfTwo | arr" ⋄ Mod 100000 +) \ No newline at end of file diff --git a/test/cases/fuzz/group.bqn b/test/cases/fuzz/group.bqn new file mode 100644 index 00000000..3eb85bc7 --- /dev/null +++ b/test/cases/fuzz/group.bqn @@ -0,0 +1,16 @@ +%DEF eqvar ⟨_eqvar⟩←⊑•args + +( + %USE eqvar + helpers ← ⊑•args + rand ← helpers.GetRand@ + R ← rand.Range + ⟨RandVals⟩ ← ⟨rand⟩ helpers.Import "utils.bqn" + {𝕊: + t ← R 8 + l ← R 10 + x ← l RandVals t + w ← ¯1+l R 1+l + w ⊔_eqvar x + }¨ ↕10000 +) \ No newline at end of file diff --git a/test/cases/fuzz/scan.bqn b/test/cases/fuzz/scan.bqn index ad4592ca..ba1f50b7 100644 --- a/test/cases/fuzz/scan.bqn +++ b/test/cases/fuzz/scan.bqn @@ -1,2 +1,23 @@ # tests scan on a matrix checking for overflow in tail elements -8‿16‿32 {e𝕊n‿w: m←2⋆e-2 ⋄ ! (m⊸+⌾(⟨¯1,w|n⟩⊸⊑) ⌽‿w⥊(n+w+1)⥊m) ≡ +` •internal.Squeeze ↑‿w⥊ (w⥊m)∾(n⥊0)∾m}⌜ 1+↕200‿65 \ No newline at end of file +8‿16‿32 {e𝕊n‿w: m←2⋆e-2 ⋄ ! (m⊸+⌾(⟨¯1,w|n⟩⊸⊑) ⌽‿w⥊(n+w+1)⥊m) ≡ +` •internal.Squeeze ↑‿w⥊ (w⥊m)∾(n⥊0)∾m}⌜ 1+↕200‿65 + +%DEF rand R ← ((⊑•args).GetRand@).Range ⋄ ⟨V⇐Variation⟩ ← •internal + +# ∨`bitarr +( + %USE rand + {𝕊: + n ← 1 + R 2⋆R 13 + ! (∨` ≡ ⊢∘∨`) "Ab" V {𝕊: 1⌾((R n)⊸⊑)𝕩}⍟2 "Ai8" V 0⥊˜ n + }¨ ↕100000 +) + +# +`bitarr +( + %USE rand + RB2 ← {¬⍟(R 2) "Ab" V 𝕩 R 1+R 2⋆R 10} # random boolean array with random uniform probability + {𝕊: + a ← RB2 R 2⋆R 13 + ! (+` ≡ ⊢∘+`) a + }¨ ↕100000 +) diff --git a/test/cases/unnecessary/fuzz-slash.bqn b/test/cases/unnecessary/fuzz-slash.bqn new file mode 100644 index 00000000..5de163dd --- /dev/null +++ b/test/cases/unnecessary/fuzz-slash.bqn @@ -0,0 +1,31 @@ +### WHOLE-FILE-TEST +# generally unnecessary now that debug builds include heap corruption testing +⟨LV⇐ListVariations, V⇐Variation, ClearRefs⇐ClearRefs, I⇐Info, TY⇐Type, Refc⇐Refc, EEQ⇐EEqual⟩ ← •internal +helpers ← ⊑•args +R ← (helpers.GetRand@).Range +RB2 ← {¬⍟(R 2) "Ab" V 𝕩 R 1+R 2⋆R 10} # random boolean array with random uniform probability + +rByteVals ← "Ai8"V {𝕩-256×𝕩>127} ∾{{2⊸×⊸+˜´ 8↑/⁼ 𝕩 •rand.Subset 8}¨ ↕9}¨↕20 +RByte ← (R (≠rByteVals)˙)⊸(⊑⟜rByteVals) + +RH ← "Ai8"⊸V¨ R⥊¨RByte # store to a variable to randomize heap by 𝕨 values, each up to 𝕩 bytes +CH ← { # do "var CH↩" to a variable assigned to a result of RH + "heap corruption" ! ∧´2=Refc¨ 𝕩 + "heap corruption" ! 1 ≡ Refc 𝕩 + 0 +} +BitSlash ← {ty‿dy‿max𝕊n: + f ← dy ⊑ ⟨/∘⊢ ⋄ {𝕩/ty V 𝕨 R 100}⟩ + {𝕊: + # 𝕩⊸{•Show 𝕨}⍟⊢ 0=10000|𝕩 + t1←20 RH 100 + n←R max + x←n F n↑RB2 128+n + t2←20 RH 100 + x↩0 ⋄ t1 CH↩ ⋄ t2 CH↩ + }¨↕n +} +•Show "heap corruption test of /bit" ⋄ @‿0‿200 BitSlash 1000000 +•Show "heap corruption test of bit/i8" ⋄ "Ai8"‿1‿50 BitSlash 1000000 +•Show "heap corruption test of bit/i16" ⋄ "Ai16"‿1‿50 BitSlash 1000000 +•Show "heap corruption test of bit/i32" ⋄ "Ai32"‿1‿50 BitSlash 1000000 diff --git a/test/various.bqn b/test/various.bqn deleted file mode 100644 index c7099ac4..00000000 --- a/test/various.bqn +++ /dev/null @@ -1,88 +0,0 @@ -⟨LV⇐ListVariations, V⇐Variation, ClearRefs⇐ClearRefs, I⇐Info, TY⇐Type, Refc⇐Refc, EEQ⇐EEqual⟩ ← •internal -u ← ⌊100×(•UnixTime+1|100וMonoTime)@ - -rand ← •MakeRand •Show u -⟨RandVals⟩ ← ⟨rand⟩ •Import "utils.bqn" -R ← rand.Range -RB ← "Ab" V R⟜2 # uniformly random boolean array -RB2 ← {¬⍟(R 2) "Ab" V 𝕩 R 1+R 2⋆R 10} # random boolean array with random uniform probability - -rByteVals ← "Ai8"V {𝕩-256×𝕩>127} ∾{{2⊸×⊸+˜´ 8↑/⁼ 𝕩 •rand.Subset 8}¨ ↕9}¨↕20 -RByte ← (R (≠rByteVals)˙)⊸(⊑⟜rByteVals) -RH ← "Ai8"⊸V¨ R⥊¨RByte # store to a variable to randomize heap by 𝕨 values, each up to 𝕩 bytes -CH ← { # do "var CH↩" to a variable assigned to a result of RH - "heap corruption" ! ∧´2=Refc¨ 𝕩 - "heap corruption" ! 1 ≡ Refc 𝕩 - 0 -} - -OrScanBitarr ← {𝕊: - n ← 1 + R 2⋆R 13 - ! (∨` ≡ ⊢∘∨`) "Ab" V {𝕊: 1⌾((R n)⊸⊑)𝕩}⍟2 "Ai8" V 0⥊˜ n -}¨ ↕ - -PlusScanBitarr ← {𝕊: - a ← RB2 R 2⋆R 13 - ! (+` ≡ ⊢∘+`) a -}¨ ↕ - -BitSlash ← {ty‿dy‿max𝕊n: - f ← dy ⊑ ⟨/∘⊢ ⋄ {𝕩/ty V 𝕨 R 100}⟩ - {𝕊: - # 𝕩⊸{•Show 𝕨}⍟⊢ 0=10000|𝕩 - t1←20 RH 100 - n←R max - x←n F n↑RB2 128+n - t2←20 RH 100 - x↩0 ⋄ t1 CH↩ ⋄ t2 CH↩ - }¨↕n -} - -_testConsistent ← { w0 F _𝕣 x0: - ∧´ (⊏ EEQ¨1↓⊢) ⥊𝕨 {(𝕨 V w0) F (𝕩 V x0)}⌜○LV 𝕩? ClearRefs@; - - w0 F _𝕣 x0: - •Out "Fail for:" - "𝕨: "‿"𝕩: " •Out∘(∾⟜•Repr)¨ 𝕨⋈𝕩 - tbl ← 𝕨 {(𝕨 V w0) F (𝕩 V x0)}⌜○LV 𝕩 - •Show (<∘⊑≡¨⊢) tbl - •Exit 1 -} - -Group ← {𝕊: - t ← R 8 - l ← R 10 - x ← l RandVals t - w ← ¯1+l R 1+l - w ⊔_testConsistent x - 1 -}¨ ↕ - -Mod ← {𝕊: - modOptions ← ⟨∞,¯∞,0÷0⟩ ∾ ∾⟜- 2⋆↕34 - {𝕊: - n ← R 2⋆4+R 6 - w ← R∘≠⊸⊑ modOptions - x ← -⍟(R 2) (2⋆R 34) + (↕n)-R n - got ← w|x - exp ← w|"Ah"V x - ¬exp EEQ got? - •Out "𝕨: "∾•Repr w - •Out "𝕩: "∾(•Repr x)∾" / "∾I x - •Out "exp: "∾•Repr exp - •Out "got: "∾•Repr got - •Exit 1 - ;@ - }¨ ↕𝕩 -} - -•Show "powerOfTwo | arr" ⋄ Mod 100000 -•Show "∨`bitarr" ⋄ OrScanBitarr 100000 -•Show "+`bitarr" ⋄ PlusScanBitarr 100000 - -# •Show "heap corruption test of /bit" ⋄ @‿0‿200 BitSlash 1000000 -# •Show "heap corruption test of bit/i8" ⋄ "Ai8"‿1‿50 BitSlash 1000000 -# •Show "heap corruption test of bit/i16" ⋄ "Ai16"‿1‿50 BitSlash 1000000 -# •Show "heap corruption test of bit/i32" ⋄ "Ai32"‿1‿50 BitSlash 1000000 - -•Show "⊔ consistency" ⋄ Group 10000