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

cgen: support .str() for maps with non string keys (#7806)

This commit is contained in:
Swastik Baranwal
2021-01-02 23:55:46 +05:30
committed by GitHub
parent fc6d45b2d7
commit dee3bbffe9
2 changed files with 28 additions and 2 deletions

View File

@@ -517,6 +517,8 @@ fn test_rune_keys() {
assert m[`!`] == 2
m[`@`] = 7
assert m.len == 3
println(m)
assert '$m' == '{`!`: 2, `%`: 3, `@`: 7}'
mut a := []rune{}
for k, v in m {
@@ -588,3 +590,9 @@ fn test_eq() {
}
}
}
fn test_non_string_key_map_str() {
assert {23: 4}.str() == '{23: 4}'
assert {`a`: 12, `b`: 13}.str() == '{`a`: 12, `b`: 13}'
assert {23: 'foo', 25: 'bar'}.str() == "{23: 'foo', 25: 'bar'}"
}