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

array: fix array_clone (fix #8220) (#8238)

This commit is contained in:
yuyi
2021-01-21 17:17:00 +08:00
committed by GitHub
parent f059a9e96c
commit 242c5760f1
2 changed files with 27 additions and 3 deletions

View File

@ -1343,3 +1343,19 @@ fn test_multi_fixed_array_with_default_init() {
println(a)
assert a == [[10, 10, 10]!, [10, 10, 10]!, [10, 10, 10]!]!
}
struct Abc {
mut:
x i64
y i64
z i64
}
fn test_clone_of_same_elem_size_array() {
mut arr := []Abc{}
arr << Abc{1, 2, 3}
arr << Abc{2, 3, 4}
arr2 := arr.clone()
println(arr2)
assert arr2 == [Abc{1, 2, 3}, Abc{2, 3, 4}]
}