aboutsummaryrefslogtreecommitdiff
path: root/test/cases
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-22 22:22:45 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-01-22 22:22:45 -0500
commit92a343d6aa20c1a93dfd5d5b276506285806bada (patch)
tree510aed210296d25419b3ea5f33c2b6ab0e0a3f5c /test/cases
parentf9b5c720e4502ee0848a032f642ceed468478791 (diff)
Fill tests
Diffstat (limited to 'test/cases')
-rw-r--r--test/cases/fill.bqn69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/cases/fill.bqn b/test/cases/fill.bqn
new file mode 100644
index 00000000..ef9e86c3
--- /dev/null
+++ b/test/cases/fill.bqn
@@ -0,0 +1,69 @@
+# String fill
+' ' ≡ ⊑""
+
+# Match doesn't use fills
+"ab" ≡○(0⊸↑) ↕2
+
+# Functions that fill
+" "≡5⥊""
+("abc"≍"de ") ≡ 2‿↑⥊"abcde"
+"abc "≡5↑"abc"
+" ab" ≡ »"abc"
+"bc " ≡ «"abc"
+
+# Box generates arbitrary fill elements
+∧´ (2⊸↑ ≡ 1‿0⊸×)∘<¨ ⟨π, ↕3, "", 2+⌜○↕3, ≍˘⟨2‿1,↕4‿2⟩⟩
+(0¨ ≡ 1⊑2↑<) ∞‿¯∞‿0
+" "‿0 ≡ ⊑0⥊<"xy"‿¯π
+⟨7⥊0‿' '⟩ ≡ »≍<'a'⍟(2⊸|)¨↕7
+
+# Special cases
+0 ≡ ⊑↕0
+0‿1‿2‿0 ≡ 4↑↕3
+≡⟜(⊑↕) 0‿0‿0
+(⥊⟜(<0⊸×) ≡ »∘↕) 1‿2
+(4⊸↑ ≡ 0‿1‿2‿0⊸⊏) ↑↕2
+(↑ ≡○(⊑¯7⊸↑) ↓) ≍˘⟨↕3,"ab"⟩
+
+# Arithmetic
+∧´{0‿0≡⊑0⥊𝕏↕2‿4}¨ +‿-‿×‿÷‿⋆‿√‿⌊‿⌈‿|‿¬
+∧´{(2⥊<0‿0)≡⊑0⥊⟨0‿1,23⟩𝕏○(3⥊<)⟨01,2‿3⟩}¨ +‿-‿×‿÷‿⋆‿√‿⌊‿⌈‿|‿¬‿∧‿∨
+∧´{(2⥊<0‿0)≡⊑0⥊⟨0‿'c',2‿'d'⟩𝕏○(3⥊<)⟨01,"ch"⟩}¨ <‿>‿≠‿=‿≤‿≥
+0‿' '‿' ' ≡ ⊑0⥊ 0‿1‿'c'+○<0‿'b'‿2
+0‿' '‿0 ≡ ⊑0⥊ 0‿'b'‿'c'-○<0‿1‿'c'
+
+# Fill-preserving functions
+' ' ≡ ⊑0⥊ ⥊@
+" ab" ≡ ⥊»2‿∘⥊"abcd"
+(≍3⥊<" ") ≡ »≍3⥊<"abcd"
+" cba" ≡ ¯4↑⌽"abc"
+"bca " ≡ 4↑1⌽"abc"
+≡○»⟜(⊏≍) ⥊<"ab"‿∞
+"c " ≡ 3↑⍉'c'
+(≍" ") ≡ »⍉⌊‿1⥊"wxy"
+" "≡1↑»3/"ab"
+⟨⟨⟩⟩ ≡ »0‿1/↑1↓↕2
+0‿0 ≡ ⊑0↑0‿0⍉↕3‿2
+' '‿0 ≡ ⊑0⥊1‿2‿0⍉3↕(<'a'‿1)+↕4‿5
+"cb " ≡ 4↑2‿1⊏"abc"
+(3⥊0) ≡ ⊑0⥊ ⟨2‿0,<1,≍1‿3⟩⊏↕3‿2‿4
+" cba" ≡ ¯4↑⍷"cbaba"
+"abc " ≡ 5↑∧"bca"
+"cabc " ≡ 5↑⊏∨3‿4⥊"abc"
+0‿' ' ≡ ⊑0⥊ <` (↕3) + <0‿'x'
+
+# Fill 0
+⌽⊸≡ 7↑/2‿3
+∧´{0≡⊑»𝕏"abdbcda"}¨ ≢‿⍋‿⍒‿∊‿⊐‿⊒
+∧´⟨6‿2⥊↕2,5‿2⥊↕3⟩⊸{0≡⊑0⥊𝕏´𝕨}¨ ⍋‿⍒‿∊‿⍷‿⊐‿⊒
+
+# Combinations
+(' '¨⊸≍"abc") ≡ »>⟨"abc","def"⟩
+(' '¨⊸≍"abc") ≡ »"abc"≍"def"
+≡○(⊑0⊸⥊)⟜(∾↑) 0‿'a'‿2 + <⟨0,1‿2⟩
+0‿0 ≡ ⊑0⊸⥊ 1‿3∾○↕2‿3
+
+# Group
+"" ≡ ⊑0⥊⟨⟩⊔""
+0‿1‿1‿0 ≡ ⊐4↑2‿1⊔"aa"
+" " ≡ (⊑0⥊⊢)¨ 2‿1⊔"aa"