•bit._cast fuzz tester, for refcount 1 lists

This commit is contained in:
Marshall Lochbaum 2022-10-12 21:43:04 -04:00
parent 89c1b39c6d
commit d23d9b8c8f
2 changed files with 29 additions and 1 deletions

27
test/bit.bqn Normal file
View File

@ -0,0 +1,27 @@
u 100×(•UnixTime+1|100וMonoTime)@
r •MakeRand •Show u
RandVals, casts r •Import "utils.bqn"
# Test •bit._cast first
# Convert unsigned width 𝕗 to 𝕘
_cvtu_ {
𝕗=𝕘 ? 𝕩 ;
𝕗<𝕘 ? b2𝕗 +(b×)˝(𝕘÷𝕗)𝕩 ;
b2𝕘 >1(--b×)÷b(1+𝕗÷𝕘)𝕩
}
_bitcast { frto _𝕣 𝕩:
S {𝕊:𝕩+𝕨×𝕩<0; 𝕊:𝕩-𝕨×𝕩𝕨÷2}
_off {("uci"1𝕗),-@,(2𝕗)S}
ft ¨𝕗
to _off f _cvtu_ t fr _off 𝕩
}
TestCast { ft 𝕊 len:
c 𝕨 casts
len + (1÷˜´¨c) | -len # Round up to exact conversion
(c _bitcast c •bit._cast) len RandVals f
}
cs / 64>¨casts # TODO floats
cx (32'c'¨casts)/ cs # TODO 32-bit char output
ls (100) r.Range¨+ 100 × (1.5) 100
{cs ( !TestCast 𝕩˙) cx}¨ ls

View File

@ -11,6 +11,7 @@ chr ← 0‿0‿0‿0‿0‿1‿1‿1
specF64 - π2 ÷0 10
specI32 "Ai32" •internal.Variation (<(231)(-231))/ - 0/ (¯4+8) + 232
vars "Ab""Ai8""Ai16""Ai32""Af64""Ac8""Ac16""Ac32"
casts 1816326481632¨"uiiifccc"
specInts 715({(<(2𝕨)(-2𝕨))/𝕩}¨<)specI32 # TODO 8-bit integer spec is kinda stupid
spec0 01specIntsspecF64@+(1114111-16)(2) (<11141110)/¨ specInts
spec0 (5/¯128¯127¯126¯2¯1012125126127)(1)
@ -43,4 +44,4 @@ RandVals ⇐ {
! "f64arr" •internal.Type 10 RandVals 4
! "c8arr" •internal.Type 10 RandVals 5
! "c16arr" •internal.Type 10 RandVals 6
! "c32arr" •internal.Type 10 RandVals 7
! "c32arr" •internal.Type 10 RandVals 7