mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
This commit is contained in:
parent
8011121d43
commit
93a3f5ff7d
6 changed files with 110 additions and 0 deletions
|
@ -1607,3 +1607,27 @@ fn test_using_array_name_variable() {
|
|||
println(array)
|
||||
assert array == [0, 1, 2, 3]
|
||||
}
|
||||
|
||||
struct Data {
|
||||
mut:
|
||||
sub_map map[int]int
|
||||
}
|
||||
|
||||
fn test_array_of_struct_with_map_field() {
|
||||
n := 3
|
||||
mut arr := []Data{len: n}
|
||||
for i, mut a in arr {
|
||||
arr[i].sub_map[i] = 1
|
||||
a.sub_map[i] += 1
|
||||
}
|
||||
println(arr)
|
||||
assert arr[0].sub_map == {
|
||||
0: 2
|
||||
}
|
||||
assert arr[1].sub_map == {
|
||||
1: 2
|
||||
}
|
||||
assert arr[2].sub_map == {
|
||||
2: 2
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue