diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-06-30 16:14:45 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-06-30 16:15:58 -0400 |
| commit | 3402e16ca056a8bac819a365ccd23d5a6e7b2394 (patch) | |
| tree | 7b6caf47f4c1c9bb6d01f2a53c847b330177ccda /test | |
| parent | faeda7748572e1ae761f033138542a9c1fcd70a1 (diff) | |
Add fuzz testing for dimensions, catenation, and search
Diffstat (limited to 'test')
| -rw-r--r-- | test/fuzz.bqn | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/test/fuzz.bqn b/test/fuzz.bqn index 35a01983..77fccfaf 100644 --- a/test/fuzz.bqn +++ b/test/fuzz.bqn @@ -73,6 +73,8 @@ RandPart ← { ¬⟜» (𝕨-1) (∧∘Rand∾1-˜⊢) 𝕩¬𝕨 } ⟩_randChoose } +RandShape1 ← 1⊸∾⍟(0=≠) RandShape + # 𝕨 is 2⋆⁼bits in type; 𝕩 is shape gen ← { RandInt ← { (1⊸<⊸×m÷2) -˜ 𝕩 Rand m←2⋆2⋆𝕨 } @@ -121,8 +123,7 @@ _testConsistent_ ← {Match←𝔾 FlatMatch ← ≡◶⟨∧´∘⥊=∨∧○(≠˜),1⟩ _testMonArith ← { - _t ← { ! 𝕏 _testConsistent_ FlatMatch 𝕗 } - (𝕨 gen.Arith RandShape 𝕩)_t¨ 𝕗 + (𝕨 gen.Arith RandShape 𝕩)⊸{ ! 𝕏 _testConsistent_ FlatMatch 𝕨 }¨ 𝕗 } RandDyShape ← { @@ -161,9 +162,34 @@ _testDyStruct ← { # ⥊↑↓↕⌽⍉ (no overtake) (r⊏˜p⊐𝕗) { ! (𝕎sh) 𝕏 _testConsistent_ FlatMatch d }¨ 𝕗 } +_testDim ← { # ≠=≢ + (𝕨 gen.Struct RandShape 𝕩)⊸{ ! 𝕏 _testConsistent_ ≡ 𝕨 }¨ 𝕗 +} + +_testCombine ← { # ≍∾«» + a ← 𝕨 gen.Struct sh ← RandShape1 𝕩 + bs ← (RandBound 1⊸+)⌾⊑⍟({≍}≠𝕗) sh + swap ← (Rand 2)⊑{𝔽}‿˜ + ((⊐bs) ⊏ 𝕨⊸gen.Struct¨ ⍷bs) { ! a 𝕏 _testConsistent_ FlatMatch _swap 𝕨 }¨ 𝕗 +} + +_testMonSearch ← { # ⊐⊒∊⍷∧∨⍋⍒ + (𝕨 gen.Arith RandShape1 𝕩)⊸{ ! 𝕏 _testConsistent_ FlatMatch 𝕨 }¨ 𝕗 +} +_testDySearch ← { # ⊐⊒∊⍋⍒ + sh ← RandShape1 𝕩 + k ← ⍋‿⍒⊐𝕗 + a‿b ← 𝕨⊸gen.Arith¨ ⟨sh, (RandShape·⌊𝕩÷×´)⊸∾ 1↓sh⟩ + as ← (⊐k) ⊏ {𝕏a}¨(⍷k)⊏∧‿∨‿⊢ + as { ! 𝕨 𝕏 _testConsistent_ FlatMatch b }¨ {𝕏˜}⍟(∊˙⊸=)¨ 𝕗 +} + cases ← ⟨ ⟨∾`"+-×÷⋆√⌊⌈¬|"‿"∧∨≤<>≥=≠", testMonArith‿testDyArith⟩ ⟨"⥊≍⌽⍉⊏"‿"⥊↑↓↕⌽⍉", testMonStruct‿testDyStruct⟩ # Monadic «» hard to test + ⟨"≠=≢"‿"", testDim‿@⟩ + ⟨""‿"≍∾«»", @‿testCombine⟩ + ⟨"⊐⊒∊⍷∧∨⍋⍒"‿"⊐⊒∊⍋⍒", testMonSearch‿testDySearch⟩ ⟩ MakeTests ← { prim‿test ← <∘>˘ ⍉> 𝕨 |
