From d25f281b25d452a53586f3a764a4c2407eb83531 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 26 Oct 2024 17:22:06 +0300 Subject: [PATCH] tests: fix compilation of the semaphore_wait.v program with latest V --- cmd/tools/vtest-all.v | 5 +++++ vlib/v/tests/reliability/semaphore_wait.v | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/tools/vtest-all.v b/cmd/tools/vtest-all.v index 3ac76c4ea9..9073892a92 100644 --- a/cmd/tools/vtest-all.v +++ b/cmd/tools/vtest-all.v @@ -294,6 +294,11 @@ fn get_all_commands() []Command { rmfile: 'vtmp_unused' } $if linux { + res << Command{ + line: '${vexe} -o swait vlib/v/tests/reliability/semaphore_wait.v' + okmsg: 'V can compile semaphore_wait.v on Linux with GC on.' + rmfile: 'swait' + } res << Command{ line: '${vexe} -cc gcc -keepc -freestanding -o bel vlib/os/bare/bare_example_linux.v' okmsg: 'V can compile with -freestanding on Linux with GCC.' diff --git a/vlib/v/tests/reliability/semaphore_wait.v b/vlib/v/tests/reliability/semaphore_wait.v index 7811c32e4b..f21cfaecd0 100644 --- a/vlib/v/tests/reliability/semaphore_wait.v +++ b/vlib/v/tests/reliability/semaphore_wait.v @@ -46,23 +46,23 @@ const log2n = 9 const n = 1 << log2n const n4 = f64(u64(1) << (4 * log2n)) -fn waste_mem() { +fn waste_mem() ! { mut objs := PtrPtrObj{ - nxt: []&PtrObj{len: n} + nxt: unsafe { []&PtrObj{len: n} } } for { - sz := rand.int_in_range(10, 1000) + sz := rand.int_in_range(10, 1000)! mut new_obj := &PtrObj{ - nxt: []&DataObj{len: sz} + nxt: unsafe { []&DataObj{len: sz} } } - sz2 := rand.int_in_range(10, 500000) + sz2 := rand.int_in_range(10, 500000)! new_obj2 := &DataObj{ data: []f64{len: sz2} } - idx2 := rand.int_in_range(0, sz) + idx2 := rand.int_in_range(0, sz)! new_obj.nxt[idx2] = new_obj2 // non-equally distributed random index - idx := int(math.sqrt(math.sqrt(rand.f64n(n4)))) + idx := int(math.sqrt(math.sqrt(rand.f64n(n4)!))) objs.nxt[idx] = new_obj } }