| Add the differential test runner, and a lowering to measure with it | 1 | fn classify(n: i32) -> i32 { |
| 2 | if n < 0 { | |
| 3 | -1 | |
| 4 | } else if n == 0 { | |
| 5 | 0 | |
| 6 | } else { | |
| 7 | 1 | |
| 8 | } | |
| 9 | } | |
| 10 | ||
| 11 | fn main() { | |
| 12 | let mut total: i32 = 0; | |
| 13 | for i in -3..4 { | |
| 14 | total += classify(i); | |
| 15 | println!("{} -> {}", i, classify(i)); | |
| 16 | } | |
| 17 | let mut k: i32 = 0; | |
| 18 | while k < 3 { | |
| 19 | k += 1; | |
| 20 | } | |
| 21 | loop { | |
| 22 | k += 1; | |
| 23 | if k > 5 { | |
| 24 | break; | |
| 25 | } | |
| 26 | } | |
| 27 | println!("total={} k={}", total, k); | |
| 28 | } |