uCBQN/test/squeezeExact.bqn
2022-06-30 01:47:50 +03:00

71 lines
1.9 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.

EEqual, ClearRefs, Variation, Squeeze, Type •internal
u 100×(•UnixTime+1|100וMonoTime)@
r •MakeRand •Show u
ntn "bit""i8""i16""i32""f64"
ntv "Ab""Ai8""Ai16""Ai32""Af64"
nmin 0 -2¯1+8×23
nmax 1¯1+2¯1+8×23
int 11110
ctn "c8""c16""c32"
ctv "Ac8""Ac16""Ac32"
cmax 111411228×23
specF64 r •Import "utils.bqn"
spec specF64{}"a⍉𝕨"<"foo"
# currently tests an array of 0s, with only one outstanding element
Do { 𝕊:
val {r.Range𝕩𝕩}
{𝕊: r.Range spec}
{𝕊: (¯5+r.Range 10) + 2r.Range 64}
base 0
len 1+r.Range 23+r.Range 7
pos r.Range len
arr "Ah" Variation val(pos) len<base
tOuttIn {
1=•Type val?
msk ((¬int) valval) 1˜ (nminnmax)val
1msk/ntn "Ah""Af"msk/ntv;
(2•Type val) 1len?
msk {2•Type val? (1len) (val-@)<cmax; 0}
1msk/ctn "Ah""Af"msk/ctv;
# else
"h""fill" "Ah""Af"
}
tIn {'S'1𝕩}¨ "Inc"¨ tIn
{
arrv 𝕩 Variation arr
sq Squeeze arrv
sqt Type sq
sqt{
"arr"¯3sqt? ¯3sqt;
!"slice"¯5sqt ¯5sqt
}
¬ (arrv EEqual arr) (arrv EEqual sq) ((<sqt) tOut)?
•Out "Fail:"
•Show arrv
•Show sq
•Show Type sq
•Show tOut𝕩
•Exit 1
;@
}¨ tIn
ClearRefs@
}
n0a "Af64" Variation 111¯1×π00
n0b Squeeze n0a
{
n0a÷n0b? •Out "Squeeze behavior on negative zero: keep";
•Out "Squeeze behavior on negative zero: discard"
}
Do¨ 100000