v2 / vlib / v / tests / map_cast_test.v
25 lines · 21 sloc · 303 bytes · 9fc83526aaea9f100fb9d0e68b43ae210d8d067f
Raw
1fn foo() map[int]int {
2 return {
3 1: 2
4 }
5}
6
7fn test_main() {
8 a := ?map[int]int(none)
9 assert a == none
10
11 b := ?map[int]int({
12 1: 2
13 })
14 assert b?[1] == 2
15
16 c := ?map[int]map[string]string({
17 1: {
18 'foo': 'bar'
19 }
20 })
21 assert c?[1]['foo'] == 'bar'
22
23 d := ?map[int]int(foo())
24 assert d?[1] == 2
25}
26