v/vlib/v/tests/match_sumtype_var_aggregate...

22 lines
271 B
V

struct Foo {}
struct Bar {}
struct Baz {}
type Sum = Bar | Baz | Foo
fn foo(s Sum) Sum {
match s {
Foo, Bar { return s }
Baz { return Baz{} }
}
}
fn test_match_sumtype_var_aggregate() {
a := Foo{}
ret := foo(a)
println(ret)
assert '$ret' == 'Sum(Foo{})'
}