| 1 | fn option_arg(x ?int) ?int { |
| 2 | assert x != none |
| 3 | return x |
| 4 | } |
| 5 | |
| 6 | fn option_arg2(x ?f64, y ?int, z ?string) ?string { |
| 7 | assert x != none |
| 8 | assert y != none |
| 9 | assert z != none |
| 10 | return z |
| 11 | } |
| 12 | |
| 13 | fn option_arg3(x ?f64, y ?int, z ?string) bool { |
| 14 | assert x == none |
| 15 | assert y == none |
| 16 | assert z == none |
| 17 | return true |
| 18 | } |
| 19 | |
| 20 | fn test_main() { |
| 21 | var := ?int(1) |
| 22 | assert option_arg(var)? == 1 |
| 23 | assert option_arg(100)? == 100 |
| 24 | assert option_arg2(1.1, 1, '')? == '' |
| 25 | assert option_arg2(1.2, 2, 'foo')? == 'foo' |
| 26 | assert option_arg3(none, none, none) |
| 27 | } |
| 28 | |