v2 / vlib / v / tests / options / option_unwrap_selector_test.v
29 lines · 25 sloc · 317 bytes · 305a272067557a19b9f5a2abf2cc6e8fa4bebb32
Raw
1interface IBar {
2 opt ?string
3}
4
5struct Bar implements IBar {
6 opt ?string
7}
8
9struct Foo {
10 field IBar
11}
12
13fn (f &Foo) t() {
14 if f.field.opt != none {
15 assert f.field.opt == 'foo'
16 }
17}
18
19fn test_main() {
20 a := Foo{
21 field: Bar{
22 opt: 'foo'
23 }
24 }
25 if a.field.opt != none {
26 assert a.field.opt == 'foo'
27 }
28 a.t()
29}
30