v2 / vlib / v / tests / conditions / matches / match_expr_with_result_test.v
23 lines · 20 sloc · 311 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1fn foo(i int) ?bool {
2 return match true {
3 i == 0 { true }
4 else { none }
5 }
6}
7
8fn bar(i int) !bool {
9 return match true {
10 i == 0 { true }
11 else { error('') }
12 }
13}
14
15fn test_match_expr_with_result() {
16 r1 := foo(0) or { false }
17 println(r1)
18 assert r1
19
20 r2 := bar(0) or { false }
21 println(r2)
22 assert r2
23}
24