| 1 | import math |
| 2 | |
| 3 | fn test_min() { |
| 4 | assert math.min(42, 13) == 13 |
| 5 | assert math.min(5, -10) == -10 |
| 6 | assert math.min(7.1, 7.3) == 7.1 |
| 7 | assert math.min(u32(32), u32(17)) == 17 |
| 8 | } |
| 9 | |
| 10 | fn test_max() { |
| 11 | assert math.max(42, 13) == 42 |
| 12 | assert math.max(5, -10) == 5 |
| 13 | assert math.max(7.1, 7.3) == 7.3 |
| 14 | assert math.max(u32(60), u32(17)) == 60 |
| 15 | } |
| 16 | |
| 17 | fn test_abs() { |
| 18 | assert math.abs(99) == 99 |
| 19 | assert math.abs(-10) == 10 |
| 20 | assert math.abs(1.2345) == 1.2345 |
| 21 | assert math.abs(-5.5) == 5.5 |
| 22 | } |
| 23 | |
| 24 | fn test_max_min_int_has_type_of_int() { |
| 25 | assert math.max(int(100), min_int) == 100 |
| 26 | assert math.min(int(100), max_int) == 100 |
| 27 | } |
| 28 | |