v2 / vlib / v / tests / conditions / matches / match_expr_with_enum_test.v
24 lines · 21 sloc · 239 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1enum Foo {
2 a
3 b
4 c
5}
6
7fn get() Foo {
8 return .a
9}
10
11fn foo(f Foo) string {
12 println(f)
13 return '${f}'
14}
15
16fn test_match_expr_with_enum() {
17 ret := foo(match get() {
18 .a { .b }
19 .b { .c }
20 .c { .a }
21 })
22 println(ret)
23 assert ret == 'b'
24}
25