unified int & char cases for ⊔

This commit is contained in:
dzaima 2022-05-01 01:35:04 +03:00
parent 7f9773f971
commit 7ece6b2179
3 changed files with 43 additions and 22 deletions

View File

@ -975,26 +975,20 @@ B group_c2(B t, B w, B x) {
Arr* rf = m_fillarrp(0); fillarr_setFill(rf, m_f64(0)); arr_shVec(rf);
fillarr_setFill(r, taga(rf));
if (TI(x,elType)==el_i8) {
for (usz i = 0; i < ria; i++) { i8* t; rp[i] = m_i8arrv(&t, len[i]); }
i8* xp = i8any_ptr(x);
u8 xe = TI(x,elType);
if (xe==el_i8 || xe==el_c8) {
for (usz i = 0; i < ria; i++) m_tyarrv(rp+i, 1, len[i], el2t(xe));
u8* xp = tyany_ptr(x);
for (usz i = 0; i < xia; i++) {
i32 n = wp[i];
if (n>=0) i8arr_ptr(rp[n])[pos[n]++] = xp[i];
if (n>=0) ((u8*)tyarr_ptr(rp[n]))[pos[n]++] = xp[i];
}
} else if (TI(x,elType)==el_i32) {
for (usz i = 0; i < ria; i++) { i32* t; rp[i] = m_i32arrv(&t, len[i]); }
i32* xp = i32any_ptr(x);
} else if (xe==el_i32 || xe==el_c32) {
for (usz i = 0; i < ria; i++) m_tyarrv(rp+i, 4, len[i], el2t(xe));
u32* xp = tyany_ptr(x);
for (usz i = 0; i < xia; i++) {
i32 n = wp[i];
if (n>=0) i32arr_ptr(rp[n])[pos[n]++] = xp[i];
}
} else if (TI(x,elType)==el_c32) {
for (usz i = 0; i < ria; i++) { u32* t; rp[i] = m_c32arrv(&t, len[i]); }
u32* xp = c32any_ptr(x);
for (usz i = 0; i < xia; i++) {
i32 n = wp[i];
if (n>=0) c32arr_ptr(rp[n])[pos[n]++] = xp[i];
if (n>=0) ((u32*)tyarr_ptr(rp[n]))[pos[n]++] = xp[i];
}
} else {
for (usz i = 0; i < ria; i++) {

View File

@ -14,6 +14,7 @@ static B* arrV_bptr(Arr* x) {
if (x->type==t_fillslice) return ((FillSlice*)x)->a;
return NULL;
}
static void* tyarr_ptr(B x) { return c(TyArr,x)->a; }
static void* tyany_ptr(B x) {
u8 t = v(x)->type;
return IS_SLICE(t)? c(TySlice,x)->a : c(TyArr,x)->a;

View File

@ -1,7 +1,8 @@
LVListVariations, VVariation, I⇐Info, TYType, RefcRefc •internal
LVListVariations, VVariation, ClearRefs⇐ClearRefs, I⇐Info, TYType, RefcRefc, EEQEEqual •internal
u 100×(•UnixTime+1|100וMonoTime)@
rand •MakeRand •Show u
RandVals rand •Import "utils.bqn"
R rand.Range
RB "Ab" V R2 # uniformly random boolean array
RB2 {¬(R 2) "Ab" V 𝕩 R 1+R 2R 10} # random boolean array with random uniform probability
@ -38,10 +39,35 @@ BitSlash ← {ty‿dy‿max𝕊n:
}¨n
}
•Show "`bitarr" OrScanBitarr 100000
•Show "+`bitarr" PlusScanBitarr 100000
_testConsistent { w0 F _𝕣 x0:
´ ( EEQ¨1) 𝕨 {(𝕨 V w0) F (𝕩 V x0)}LV 𝕩? ClearRefs@;
•Show "heap corruption of /bit" @0200 BitSlash 1000000
•Show "heap corruption of bit/i8" "Ai8"150 BitSlash 1000000
•Show "heap corruption of bit/i16" "Ai16"150 BitSlash 1000000
•Show "heap corruption of bit/i32" "Ai32"150 BitSlash 1000000
w0 F _𝕣 x0:
•Out "Fail for:"
"𝕨: ""𝕩: " •Out(•Repr)¨ 𝕨𝕩
tbl 𝕨 {(𝕨 V w0) F (𝕩 V x0)}LV 𝕩
•Show (<¨) tbl
•Exit 1
}
Group {𝕊:
t R 8
l R 10
x l RandVals t
w ¯1+l R 1+l
w _testConsistent x
1
}¨
# •Show "`bitarr" ⋄ OrScanBitarr 100000
# •Show "+`bitarr" ⋄ PlusScanBitarr 100000
# •Show "heap corruption of /bit" ⋄ @‿0‿200 BitSlash 1000000
# •Show "heap corruption of bit/i8" ⋄ "Ai8"‿1‿50 BitSlash 1000000
# •Show "heap corruption of bit/i16" ⋄ "Ai16"‿1‿50 BitSlash 1000000
# •Show "heap corruption of bit/i32" ⋄ "Ai32"‿1‿50 BitSlash 1000000
{
¬0 EEQ -0? •Out "Skipping tests requiring EEQUAL_NEGZERO";
•Show "⊔ consistency" Group 10000
}