v2 / vlib / v / tests / aliases / alias_map_operator_overloading_test.v
23 lines · 20 sloc · 330 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1type Map = map[string]string
2
3pub fn new_map() Map {
4 return Map({
5 '23': 'str'
6 })
7}
8
9fn (a Map) + (b Map) Map {
10 str := b['23']
11 return Map({
12 '34': str + '12'
13 })
14}
15
16fn test_map_alias_op_overloading() {
17 a := new_map()
18 b := new_map()
19 assert a + b == Map({
20 '34': 'str12'
21 })
22 assert '${a + b}' == "Map({'34': 'str12'})"
23}
24