uCBQN/test/cases/fuzz/copy.bqn

56 lines
1.4 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.

### WHOLE-FILE-TEST
# tests full array copying via •internal.Variation
helpers •args
R (helpers.GetRand@).Range
Variation, ListVariations, ClearRefs •internal
vn "Ab""Ai8""Ai16""Ai32""Af64""Ac8""Ac16""Ac32""Ah""Af"
vi 0, 0, 0, 0, 1, 2, 2, 2, 1, 1
vf
(5 vn)¨ 5
(35vn)¨ 3
vf (8vn)¨ vf
vf (10) {𝕩 'S'¨ 1¨ (𝕨=0)𝕩}¨ vf
vf {𝕩 "Inc"¨ 𝕩}¨ vf
# •Show¨ vf
count 10000
eqlen 0
{𝕊:
n R 25+R 9
shl 1+•_while_{(R 2)0=1|n÷2𝕩+1} 0
sh (n÷2shl)shl2
{𝕊: sh} (n=1) 0=R 2
! n ×´sh
v R vn
l sh
{𝕊: (v0261430) -˜ n R 2v171531}
{𝕊: ÷n R 0}
{𝕊: @+n R (v-5)256655361114112}
vvi
vs vvf
vsLV ListVariations l
{ 𝕊 v0:
a0 v0 Variation l
! a0 l
{ 𝕊:
a1 𝕩 Variation a0
a0 a1?1;
•Out "fail:"
•Show v0"→"𝕩
!0
}¨ vs
}¨ vs
ClearRefs@
eqlen+ (vs) +´vsvsLV
}¨ count
•Out "Fraction of matching variation count to ListVariations: "(•Repr eqlen÷count)" (expected: ~0.999)"