1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/v/tests/return_match_expr_of_sumtype_result_test.v

26 lines
369 B
V

type Foo = int | string
fn foo1() !Foo {
return match true {
true { 1 }
else { '' }
}
}
fn foo2() ?Foo {
return match true {
true { 1 }
else { '' }
}
}
fn test_return_match_expr_of_sumtype_opt_res() {
ret1 := foo1() or { return }
println(ret1)
assert '${ret1}' == 'Foo(1)'
ret2 := foo2() or { return }
println(ret2)
assert '${ret2}' == 'Foo(1)'
}