| 1 | struct Test { |
| 2 | a ?string |
| 3 | } |
| 4 | |
| 5 | fn foo(a ?string) ? { |
| 6 | println(a?) |
| 7 | if a == none { |
| 8 | assert false |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | fn test_main() { |
| 13 | v := Test{} |
| 14 | $for f in Test.fields { |
| 15 | mut t := v.$(f.name) |
| 16 | assert t == none |
| 17 | z := t or { '' } |
| 18 | assert z == '' |
| 19 | foo(t) |
| 20 | t = 'foo' |
| 21 | assert t != none |
| 22 | foo(t) |
| 23 | assert t? == 'foo' |
| 24 | } |
| 25 | } |
| 26 |