cgen: fix map clone (#7366)

This commit is contained in:
Ned Palacios 2020-12-17 15:44:50 +08:00 committed by GitHub
parent 8addb31440
commit c164586fd5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -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
}