v/vlib/v/tests/struct_field_default_value_...

20 lines
238 B
V

struct Foo {
x int
}
struct Bar {}
type FooBar = Bar | Foo
struct Abc {
foobar FooBar = Foo{
x: 123
}
}
fn test_struct_field_default_value_sumtype_cast() {
x := Abc{}
assert x.foobar is Foo
assert (x.foobar as Foo).x == 123
}