v2 / vlib / v / tests / options / option_nested_unwrapping_test.v
20 lines · 18 sloc · 256 bytes · f9106a86fb65ce828c60c8eb004371ce70be61d5
Raw
1type Foo = string | int | f32
2
3fn bar(log ?Foo) {
4 if log != none {
5 dump(log)
6 assert typeof(log).name == 'Foo'
7 if log is string {
8 dump(log)
9 assert true
10 return
11 } else {
12 assert false
13 }
14 }
15 assert false
16}
17
18fn test_main() {
19 bar('foo')
20}
21