1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rand: use time microseconds too in default rand initialization; generate proper uuid_v4

This commit is contained in:
Delyan Angelov
2020-07-24 14:28:27 +03:00
parent c429fa7e27
commit 289974dd15
4 changed files with 17 additions and 5 deletions

View File

@ -25,12 +25,15 @@ fn gen_randoms(seed_data []u32, bound int) []u32 {
}
fn test_pcg32_reproducibility() {
randoms1 := gen_randoms(util.time_seed_array(4), 1000)
randoms2 := gen_randoms(util.time_seed_array(4), 1000)
seed_data := util.time_seed_array(4)
randoms1 := gen_randoms(seed_data, 1000)
randoms2 := gen_randoms(seed_data, 1000)
assert randoms1.len == randoms2.len
len := randoms1.len
for i in 0 .. len {
assert randoms1[i] == randoms2[i]
r1 := randoms1[i]
r2 := randoms2[i]
assert r1 == r2
}
}