v2 / vlib / v / tests / builtin_maps / map_nested_reference_value_test.v
19 lines · 16 sloc · 462 bytes · 29e962749a17d85c52d72b7d29d808cf74d55c02
Raw
1import net
2
3fn accept_mut_tcp_conn(mut conn net.TcpConn) bool {
4 return true
5}
6
7fn test_nested_map_tcpconn_reference_value_for_in_mut_type() {
8 mut con_list := map[string]map[string]&net.TcpConn{}
9 conn := &net.TcpConn{}
10 con_list['foo'] = {
11 'bar': conn
12 }
13
14 for _, mut connection in unsafe { con_list['foo'] } {
15 assert typeof(connection).name == '&net.TcpConn'
16 assert accept_mut_tcp_conn(mut connection)
17 assert voidptr(connection) == voidptr(conn)
18 }
19}
20