v2 / vlib / v / tests / options / option_nested_selector_unwrap_test.v
22 lines · 19 sloc · 262 bytes · 496451ecbbddd7ad6af1fc67a97df2328497aaf7
Raw
1type Foo = string | int | f32
2
3struct Bar {
4 log ?Foo
5}
6
7fn Bar.init(log ?Foo) {
8 mut bar := Bar{
9 log: log
10 }
11 if bar.log != none {
12 if bar.log is string {
13 assert bar.log == 'foobar'
14 return
15 }
16 }
17 assert false
18}
19
20fn test_main() {
21 Bar.init('foobar')
22}
23