v2 / vlib / v / tests / options / nested_or_expr_call_test.v
18 lines · 17 sloc · 311 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1fn get_name() !string {
2 return error('failed')
3}
4
5fn test_nested_or_expr_call() {
6 uid_map := map[int]string{}
7 uid := 2
8 username := if uid <= 0 {
9 'unknown'
10 } else {
11 uid_map[uid] or {
12 name := get_name() or { 'unknown' }
13 name
14 }
15 }
16 assert username == 'unknown'
17 println('${uid} is ${username}')
18}
19