v2 / vlib / v / tests / options / option_if_expr_test.v
16 lines · 15 sloc · 176 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1fn f() ?int {
2 return none
3}
4
5fn test_option_if_expr() {
6 i := f() or {
7 if err is none {
8 int(0)
9 } else {
10 eprintln(err)
11 int(-1)
12 }
13 }
14 println(i)
15 assert i == 0
16}
17