diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 06adc9c716..19b2201122 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -884,45 +884,6 @@ fn test_direct_modification() { assert foo[2] == 3 } -fn test_shared_modification() { - shared foo := &[2, 0, 5] - lock foo { - unsafe { - foo[1] = 3 - foo[0] *= 7 - foo[1]-- - foo[2] -= 2 - } - } - rlock foo { - unsafe { - assert foo[0] == 14 - assert foo[1] == 2 - assert foo[2] == 3 - } - } -} - -[direct_array_access] -fn test_shared_direct_modification() { - shared foo := &[2, 0, 5] - lock foo { - unsafe { - foo[1] = 3 - foo[0] *= 7 - foo[1]-- - foo[2] -= 2 - } - } - rlock foo { - unsafe { - assert foo[0] == 14 - assert foo[1] == 2 - assert foo[2] == 3 - } - } -} - fn test_bools() { println('test b') mut a := [true, false] diff --git a/vlib/sync/array_rlock_test.v b/vlib/sync/array_rlock_test.v new file mode 100644 index 0000000000..ad4f778b60 --- /dev/null +++ b/vlib/sync/array_rlock_test.v @@ -0,0 +1,38 @@ +fn test_shared_modification() { + shared foo := &[2, 0, 5] + lock foo { + unsafe { + foo[1] = 3 + foo[0] *= 7 + foo[1]-- + foo[2] -= 2 + } + } + rlock foo { + unsafe { + assert foo[0] == 14 + assert foo[1] == 2 + assert foo[2] == 3 + } + } +} + +[direct_array_access] +fn test_shared_direct_modification() { + shared foo := &[2, 0, 5] + lock foo { + unsafe { + foo[1] = 3 + foo[0] *= 7 + foo[1]-- + foo[2] -= 2 + } + } + rlock foo { + unsafe { + assert foo[0] == 14 + assert foo[1] == 2 + assert foo[2] == 3 + } + } +}