uCBQN/test/cases/under.bqn
2024-09-10 01:45:56 +03:00

144 lines
12 KiB
BQN
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%DEF var V•internal.Variation LV•internal.ListVariations CLR•internal.ClearRefs
%DEF tvar %USE var _tvar {F _𝕣 x: (CLR@) {F 𝕩 V x}¨ LV 𝕩; w F _𝕣 x: (CLR@) (LV 𝕨) {(𝕨 V w) F 𝕩 V x} LV 𝕩}
%DEF eqvar %USE tvar _eqvar {r 𝕨 𝔽 _tvar 𝕩 !(r)¨ r r}
%DEF evar %USE tvar _evar {ok{} r𝕨 ok𝔽{𝕊: •CurrentError@} _tvar 𝕩 {okr? !"TEST FAIL: variation didn't error"; ("TEST FAIL: varying error messages" ! 1=)r !r}}
# ¨ & ˘
# !% ⊢⌾(⊢¨) 4 # TODO enable
# !% ⊢⌾(⊢˘) 4 # TODO enable
# ⊑
!"𝔽⌾(a⊸⊑): Incompatible result elements" % 1020(12,12) 459
!"𝔽⌾(a⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨2⟩, got ⟨3⟩)" % 102030(12,21) 4416
!"𝔽⌾(a⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨2⟩, got ⟨3⟩)" % 1(12,21) 4416
!"𝔽⌾(n⊸⊑)𝕩: reading out-of-bounds (n≡¯10, 3≡≠𝕩)" % 1+(¯10) 3
!"⊑: 𝕨 contained list with mixed-type elements" % 'a'(1'a') 459
!"⊑: Indexing out-of-bounds (index 1‿5 in array of shape 4‿5)" % 'a'(15) 459
10,2030(12,13,21) 459 %% 4501234561020013034567801
!"⊑: Picking item at wrong rank (index 1‿1‿1 in array of shape 10‿10)" % 1¨(111) 10101
!"⊑: Picking item at wrong rank (index ⟨1⟩ in array of shape 10‿10)" % 1¨(1) 10101
a1010101000 ! a a((a)) a
{𝕊: a(1+•rand.Range 200)•rand.Range 2 i•rand.Rangea ! a (ia)(i) 2(i) a}¨10000
100+(5) 44 %% (100×5=16) + 44
100+(¯5) 44 %% (100×11=16) + 44
100+ 44 %% (100×161) + 44
1+(¯2) 4 %% 0133
1+(¯2) 0.5+4 %% 0.51.53.53.5
# !% ⊢⌾⊑ 4 # TODO enable
# !% ⊢⌾(⊑⊑) 4 # TODO enable
# ⊏
n500 an i(-n)+2×n r(2×n)a ! (a) r(i) a
!"⊏: 𝕩 cannot be a unit" % 00(00) <0
!"⊏: 𝕩 cannot be a unit" % %USE evar (0) {(𝕨)𝕩}_evar <0
!"𝔽⌾(a⊸⊏)𝕩: Indexing out-of-bounds (¯11∊a, ⟨10⟩≡≢𝕩)" % %USE evar 5¯11 {01(𝕨)𝕩}_evar 10101
!"𝔽⌾(a⊸⊏)𝕩: Indexing out-of-bounds (10∊a, ⟨10⟩≡≢𝕩)" % %USE evar 910 {01(𝕨)𝕩}_evar 10101
!"𝔽⌾(a⊸⊏)𝕩: Indexing out-of-bounds (10∊a, ⟨10⟩≡≢𝕩)" % %USE evar "ab" {𝕨(910)𝕩}_evar 10"foo"
100+(124) <¨10 %% <¨ 0101102310456789
100+(124) <¨10 %% <¨ 0101102310456789
100+(124) 10 %% 0101102310456789
100+¨(124) 10 %% 0101102310456789
100+(12¯4) <¨10 %% <¨ 0101102345106789
100+(12¯4) 10 %% 0101102345106789
10+(12) 0a4, a %% 011123,0123
%USE eqvar 0011 {𝕨(1245) 𝕩} _eqvar 101010110 %% 100011110
!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨2⟩ ≡ shape of a, ⟨⟩ ≡ shape of ⊏𝕩, ⟨3⟩ ≡ shape of result of 𝔽)" % 102030(23) 10
!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨2⟩ ≡ shape of a, ⟨⟩ ≡ shape of ⊏𝕩, ⟨3⟩ ≡ shape of result of 𝔽)" % 1(23) 10
!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (⟨3⟩ ≡ shape of a, ⟨10⟩ ≡ shape of ⊏𝕩, 2‿10 ≡ shape of result of 𝔽)" % %USE evar 1(234)_evar 10100
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 34(11) 10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 34(1¯9) 10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % %USE evar 34 {𝕨(1¯9) 𝕩}_evar 10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % %USE evar "ab" {𝕨(1¯9) 𝕩}_evar 'a'+10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 345(112) 10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 345(112) <¨10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 345(112) a<¨10 •internal.Keep a
!"𝔽⌾(a⊸⊏): Incompatible result elements" % 34(("Ah"•internal.Variation 11)) <¨10
!"𝔽⌾(a⊸⊏): Incompatible result elements" % %USE evar (2730) {𝕨((3010)) 𝕩} _evar 1001
!"𝔽⌾(a⊸⊏): Incompatible result elements" % %USE evar !¨ {{¬(314)𝕩}•internal.Keep((10<𝕩)) 𝕩} _evar 105110011
%USE eqvar {¬((10<𝕩)) 𝕩} _eqvar 105110011 %% 105001100
2020(11) 10 %% 0202+8
100+(12¯1) 5 %% 01011023104
100+(12¯1) <¨5 %% <¨ 01011023104
1+(((10010)10/10)) 10 %% 1+10
%USE eqvar 1+((2/5)) _eqvar 10 %% <5+ 10
%USE eqvar 1+((2/5)) _eqvar ˘ 10 %% ˘ <5+ 10
%USE eqvar •internal.Keep((2/5)) _eqvar 10040 %% 10040
%USE eqvar (<) {•internal.Keep(𝕨) 𝕩}_eqvar¨ 01, "ab""cd" %% 01, "ab""cd"
# ⥊
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (16 ≡ ≢⥊𝕩, ⟨17⟩ ≡ shape of result of 𝔽)" % 1 4416
1+ 5 %% (<6)
1+ <5 %% (<6)
1+ 5 %% (6)
1+ 2 %% 12
1+ 236 %% (1+236)
236 %% (236)
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (1 ≡ ≢⥊𝕩, ⟨2⟩ ≡ shape of result of 𝔽)" % 1 4
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (1 ≡ ≢⥊𝕩, ⟨2⟩ ≡ shape of result of 𝔽)" % 1 <4
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (1 ≡ ≢⥊𝕩, ⟨2⟩ ≡ shape of result of 𝔽)" % 1 4
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (2 ≡ ≢⥊𝕩, ⟨3⟩ ≡ shape of result of 𝔽)" % 1 12
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (6 ≡ ≢⥊𝕩, ⟨7⟩ ≡ shape of result of 𝔽)" % 1 236
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (1 ≡ ≢⥊𝕩, ⟨⟩ ≡ shape of result of 𝔽)" % 4
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (1 ≡ ≢⥊𝕩, ⟨⟩ ≡ shape of result of 𝔽)" % <4
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (1 ≡ ≢⥊𝕩, ⟨⟩ ≡ shape of result of 𝔽)" % 4
!"𝔽⌾⥊: 𝔽 must return an array with the same shape as its input (2 ≡ ≢⥊𝕩, 2‿1 ≡ shape of result of 𝔽)" % 21 12
# !% ⊢⌾⥊ 4 # TODO enable
# !% ⊢⌾(3⥊⊢) 4 # TODO enable
# /
!"/: Lengths of components of 𝕨 must match 𝕩 (3 ≠ 10)" % 1(101/) 10
10+(1,01/)22 %% 2200,1011,10,1111
!"𝔽⌾(a⊸/): Incompatible result elements" % 12(20/)2
1+((10)/) 10 %% ×+ 10
# ↓ & ↑
!"𝔽⌾(n⊸↑)𝕩: 𝔽 must return an array with the same shape as its input (2 ≡ n, ⟨1⟩ ≡ shape of result of 𝔽)" % 1(2) 4
!"𝔽⌾(n⊸↓)𝕩: 𝔽 must return an array with the same shape as its input (2 ≡ n, ⟨1⟩ ≡ shape of result of 𝔽)" % 1(2) 4
!"𝔽⌾(n⊸↑)𝕩: 𝔽 must return an array with the same shape as its input (¯2 ≡ n, ⟨3⟩ ≡ shape of result of 𝔽)" % 1(¯2) 4
!"𝔽⌾(n⊸↓)𝕩: 𝔽 must return an array with the same shape as its input (¯2 ≡ n, ⟨3⟩ ≡ shape of result of 𝔽)" % 1(¯2) 4
!"𝔽⌾(n⊸↓)𝕩: 𝔽 must return an array with the same shape as its input (5 ≡ n, ⟨1⟩ ≡ shape of result of 𝔽)" % 1(5) 4
!"𝔽⌾(n⊸↓)𝕩: 𝔽 must return an array with the same shape as its input (1 ≡ n, 4‿5‿2 ≡ shape of result of 𝔽)" % (1) 34560
!"𝔽⌾(n⊸↑)𝕩: 𝔽 must return an array with the same shape as its input (¯2 ≡ n, 4‿5‿2 ≡ shape of result of 𝔽)" % (¯2) 34560
!"𝔽⌾(n⊸↑)𝕩: Cannot modify fill with Under (5 ≡ n, ⟨4⟩ ≡ ≢𝕩)" % (5) 4
(4) 4 %% 4
(5) 4 %% 4
•internal.Keep(¯5) 4 %% 4
{!(a×1+9× 012𝕩+3) 10×(𝕩) a34560}¨ ¯5+10
{!(a×1+9׬012𝕩+3) 10×(𝕩) a34560}¨ ¯3+7
%USE eqvar 100011 { 1¨(𝕨/)𝕩}_eqvar 010101 %% 110111
%USE eqvar 100011 { 0¨(𝕨/)𝕩}_eqvar 010101 %% 010100
%USE eqvar 100011 {'!'¨(𝕨/)𝕩}_eqvar 010101 %% '!'101'!''!'
%USE eqvar 100011 { ˙¨(𝕨/)𝕩}_eqvar 010101 %% 101
%USE eqvar 100011 { 3¨(𝕨/)𝕩}_eqvar "hellow" %% 3'e''l''l'33
%USE eqvar 100011 { +˙¨(𝕨/)𝕩}_eqvar -÷×=<> %% +÷×=++
!"/: Lengths of components of 𝕨 must match 𝕩 (6 ≠ 7)" % 0¨(100011/) 0101010
4 (3)(010/) 3 %% 0,3,2,0
4 (010/) 3 %% 0,1,2,0
4 (000/) 3 %% 0,1,2,0
# <
< 4 %% 4
(<5)< 4 %% 5
{<"cd"}< "ab" %% "cd"
!"<⁼: Argument wasn't a rank 0 array" % 4< "ab"
!"<⁼: Argument wasn't a rank 0 array" % {}< "ab"
!"<⁼: Argument wasn't a rank 0 array" % < 2
# ⋈
4 %% 4
(5) 4 %% 5
{"cd"} "ab" %% "cd"
!"⋈⁼: Argument wasn't a length-1 list" % 4 "ab"
!"⋈⁼: Argument wasn't a length-1 list" % {} "ab"
!"⋈⁼: Argument wasn't a length-1 list" % 2
!"⋈⁼: Argument wasn't a length-1 list" % (<4) 2
# k⊸⌽
!"⌽⁼: 𝕩 must have rank at least 1" % 1(2) 10
(2) 1010100 %% 28292021222324252627
(12) 5525 %% 1552223242021234017895612131410111718191516