test an arithmetic function in test/cells.bqn

This commit is contained in:
dzaima 2023-04-30 00:53:05 +03:00
parent 048352f587
commit 2c207dbebc

View File

@ -23,6 +23,16 @@ GetTests ← { 𝕊:
AddTests {tests 𝕩 @} AddTests {tests 𝕩 @}
Prod { (<) <´ 𝕩} Prod { (<) <´ 𝕩}
FOk { wFgx: # filter out tests that'd immediately error due to bad shapes, or would
g (@g)g¯1
r =¨wx
s ¨wx
k 0r-0(+r×0>) 13g
# •Show k
ok ´ (´k) ¨ s
# {𝕊: ! w 0∘(F⎉g)⎊1 x}⍟¬ ok
ok k00
}¨/
# generating random numerical arrays: # generating random numerical arrays:
# )r N←{⟨⟩:"1";•Repr⊑⍟(1=≠)𝕩} ⋄ J←{(⊣∾𝕨∾⊢)´𝕩} ⋄ •Out '⟨'∾'⟩'∾˜','J ("⥊"J≢⋈○N⥊)¨ 15↑ ⍷ {𝕊: ((1+•rand.Range 4)•rand.Range 4)•rand.Range 10}¨ ↕100 # )r N←{⟨⟩:"1";•Repr⊑⍟(1=≠)𝕩} ⋄ J←{(⊣∾𝕨∾⊢)´𝕩} ⋄ •Out '⟨'∾'⟩'∾˜','J ("⥊"J≢⋈○N⥊)¨ 15↑ ⍷ {𝕊: ((1+•rand.Range 4)•rand.Range 4)•rand.Range 10}¨ ↕100
@ -50,37 +60,44 @@ GetTests ← { 𝕊:
ws 0, 1, 2, 3, ¯1, ¯2, <1 ws 0, 1, 2, 3, ¯1, ¯2, <1
xs 22"a"1"b""cd", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 20, 234, 2234, 34 xs 22"a"1"b""cd", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 20, 234, 2234, 34
ks 0, 1, 2, 3, 4, 01, 02 ks 0, 1, 2, 3, 4, 01, 02
AddTests Prod ws, , ks, xs AddTests FOk Prod ws, , ks, xs
AddTests Prod 0100¯100, , 012, xs0,<4 AddTests FOk Prod 0100¯100, , 012, xs0,<4
} 1 } 1
{ 𝕊: # w ≡⎉k x { 𝕊: # w ≡⎉k x
xs 0, 23@+6 {𝕩×´𝕩}¨ 1, 23, 03, 203, 423, 2423, 31 xs 0, 23@+6 {𝕩×´𝕩}¨ 1, 23, 03, 203, 423, 2423, 31
ks ¯∞, ¯1, 0, 1, 2, 3, 4, 01, 21 ks ¯∞, ¯1, 0, 1, 2, 3, 4, 01, 21
AddTests Prod xs, , ks, xs AddTests FOk Prod xs, , ks, xs
xs2 23175, [¯81¯81¯81, 000]{𝕩-˜𝕩+23'¯'}¨ 0100100000 xs2 23175, [¯81¯81¯81, 000]{𝕩-˜𝕩+23'¯'}¨ 0100100000
AddTests Prod xs2, , ks, xs2 AddTests FOk Prod xs2, , ks, xs2
} 1 } 1
{ 𝕊: # w ⍉⎉k x { 𝕊: # w ⍉⎉k x
ws 0, 1, 2, 3, 4, ¯1, 10 ws 0, 1, 2, 3, 4, ¯1, 10
xs 222"a"1"b", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 20, 234, 2234, 34, 32122 xs 222"a"1"b", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 20, 234, 2234, 34, 32122
ks 0, 1, 2, 3, 4, 5, 01, 02 ks 0, 1, 2, 3, 4, 5, 01, 02
AddTests Prod ws, , ks, xs AddTests FOk Prod ws, , ks, xs
} 1 } 1
{ 𝕊: # w »⎉k x / w «⎉k x { 𝕊: # w »⎉k x / w «⎉k x
ws 0, 1, 'a', "ab", <"h"2 ws 0, 1, 'a', "ab", <"h"2
xs 222"a"1"b", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 20, 234, 2234, 34, 32122 xs 222"a"1"b", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 20, 234, 2234, 34, 32122
ks 0, 1, 2, 3, 4, @, 01, 02 ks 0, 1, 2, 3, 4, @, 01, 02
AddTests Prod ws, «», ks, xs AddTests FOk Prod ws, «», ks, xs
} 1 } 1
{ 𝕊: # w ↑⎉k x / w ↓⎉k x { 𝕊: # w ↑⎉k x / w ↓⎉k x
ws 0,1,2,¯1,¯2,10,11 ws 0,1,2,¯1,¯2,10,11
xs 222"a"1"b", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 02, 20, 234, 2234, 34, 32122 xs 222"a"1"b", 333'a'+27, 36 {𝕩×´𝕩}¨ 23, 02, 20, 234, 2234, 34, 32122
ks 0, 1, 2, 3, 4, @, 01, 02, 1¯1 ks 0, 1, 2, 3, 4, @, 01, 02, 1¯1
AddTests Prod ws, , ks, xs AddTests FOk Prod ws, , ks, xs
} 1
{ 𝕊: # w -⎉k x
xs {𝕩×´𝕩}¨ 234, 23, 34, 2, 3, 4, 2234, 32122
ks 0, 1, 2, 3, 4, ¯1, ¯2, 01, 02, 10, 20, 21, 12
AddTests FOk Prod xs, -, ks, xs
AddTests Prod xs, -, , xs # test regular leading axis behavior
} 1 } 1
tests tests