mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: fix map clone (#7366)
This commit is contained in:
@ -426,3 +426,17 @@ fn test_modify_map_value() {
|
||||
assert m1['foo'] == 8
|
||||
assert m1['bar'] == 14
|
||||
}
|
||||
|
||||
fn test_map_clone() {
|
||||
mut nums := {
|
||||
'foo': 1,
|
||||
'bar': 2
|
||||
}
|
||||
mut nums2 := nums.clone()
|
||||
nums2['foo']++
|
||||
nums2['bar'] *= 4
|
||||
assert nums['foo'] == 1
|
||||
assert nums['bar'] == 2
|
||||
assert nums2['foo'] == 2
|
||||
assert nums2['bar'] == 8
|
||||
}
|
||||
|
Reference in New Issue
Block a user