| 1 | module main |
| 2 | |
| 3 | fn if_expt(this int) (string, int) { |
| 4 | inc := 1 |
| 5 | mut count := 0 |
| 6 | thing := if this in [0, 1, 2] { |
| 7 | count += 1 |
| 8 | '0..2' |
| 9 | } else if this in [3, 4, 5] { |
| 10 | count += inc |
| 11 | '3..5' |
| 12 | } else { |
| 13 | 'not 0..5' |
| 14 | } |
| 15 | return thing, count |
| 16 | } |
| 17 | |
| 18 | fn test_main() { |
| 19 | a, b := if_expt(1) |
| 20 | assert a == '0..2' |
| 21 | assert b == 1 |
| 22 | c, d := if_expt(4) |
| 23 | assert c == '3..5' |
| 24 | assert d == 1 |
| 25 | e, f := if_expt(7) |
| 26 | assert e == 'not 0..5' |
| 27 | assert f == 0 |
| 28 | } |
| 29 |