| ... | ... | @@ -697,18 +697,11 @@ pub fn absCast(x: var) switch(@typeInfo(@TypeOf(x))) { |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | test "math.absCast" { |
| 700 | | testing.expect(absCast(@as(i1, -1)) == 1); |
| 701 | | |
| 702 | | testing.expect(absCast(@as(i32, -999)) == 999); |
| 703 | | testing.expect(@TypeOf(absCast(@as(i32, -999))) == u32); |
| 704 | | |
| 705 | | testing.expect(absCast(@as(i32, 999)) == 999); |
| 706 | | testing.expect(@TypeOf(absCast(@as(i32, 999))) == u32); |
| 707 | | |
| 708 | | testing.expect(absCast(@as(i32, minInt(i32))) == -minInt(i32)); |
| 709 | | testing.expect(@TypeOf(absCast(@as(i32, minInt(i32)))) == u32); |
| 710 | | |
| 711 | | testing.expect(absCast(-999) == 999); |
| 700 | testing.expectEqual(@as(u1, 1), absCast(@as(i1, -1))); |
| 701 | testing.expectEqual(@as(u32, 999), absCast(@as(i32, -999))); |
| 702 | testing.expectEqual(@as(u32, 999), absCast(@as(i32, 999))); |
| 703 | testing.expectEqual(@as(u32, -minInt(i32)), absCast(@as(i32, minInt(i32)))); |
| 704 | testing.expectEqual(999, absCast(-999)); |
| 712 | 705 | } |
| 713 | 706 | |
| 714 | 707 | /// Returns the negation of the integer parameter. |