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

array: fix multiple array clone

This commit is contained in:
yuyi
2020-06-19 19:32:55 +08:00
committed by GitHub
parent 8a5ca4cbdc
commit dc8b82e9a4
2 changed files with 21 additions and 1 deletions

View File

@@ -361,6 +361,16 @@ fn test_clone() {
assert nums.slice(1, 3).str() == '[2, 3]'
}
fn test_mutli_array_clone() {
mut array1 := [[1, 2, 3], [4, 5, 6]]
mut array2 := array1.clone()
array1[0][1] = 0
assert array1 == [[1, 0, 3], [4, 5, 6]]
assert array2 == [[1, 2, 3], [4, 5, 6]]
}
fn test_doubling() {
mut nums := [1, 2, 3, 4, 5]
for i in 0..nums.len {