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:
@@ -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'}"
|
||||
}
|
||||
|
Reference in New Issue
Block a user