aboutsummaryrefslogtreecommitdiff
path: root/std/math/trunc.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-02-08 18:18:47 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-02-08 18:23:38 -0500
commitc2db077574be841da586fa62d67619c901dd535d (patch)
treec8eb64846fa7ffb9027fa1ca035dd8ca5712b9d4 /std/math/trunc.zig
parentbe6d022257d8d7e99bd080823d4d8f0175f320c5 (diff)
downloadzig-c2db077574be841da586fa62d67619c901dd535d.tar.gz
zig-c2db077574be841da586fa62d67619c901dd535d.zip
std.debug.assert: remove special case for test builds
Previously, std.debug.assert would `@panic` in test builds, if the assertion failed. Now, it's always `unreachable`. This makes release mode test builds more accurately test the actual code that will be run. However this requires tests to call `std.testing.expect` rather than `std.debug.assert` to make sure output is correct. Here is the explanation of when to use either one, copied from the assert doc comments: Inside a test block, it is best to use the `std.testing` module rather than assert, because assert may not detect a test failure in ReleaseFast and ReleaseSafe mode. Outside of a test block, assert is the correct function to use. closes #1304
Diffstat (limited to 'std/math/trunc.zig')
-rw-r--r--std/math/trunc.zig38
1 files changed, 19 insertions, 19 deletions
diff --git a/std/math/trunc.zig b/std/math/trunc.zig
index bb309a1e24..8c91ccc568 100644
--- a/std/math/trunc.zig
+++ b/std/math/trunc.zig
@@ -6,7 +6,7 @@
const std = @import("../index.zig");
const math = std.math;
-const assert = std.debug.assert;
+const expect = std.testing.expect;
const maxInt = std.math.maxInt;
pub fn trunc(x: var) @typeOf(x) {
@@ -61,34 +61,34 @@ fn trunc64(x: f64) f64 {
}
test "math.trunc" {
- assert(trunc(f32(1.3)) == trunc32(1.3));
- assert(trunc(f64(1.3)) == trunc64(1.3));
+ expect(trunc(f32(1.3)) == trunc32(1.3));
+ expect(trunc(f64(1.3)) == trunc64(1.3));
}
test "math.trunc32" {
- assert(trunc32(1.3) == 1.0);
- assert(trunc32(-1.3) == -1.0);
- assert(trunc32(0.2) == 0.0);
+ expect(trunc32(1.3) == 1.0);
+ expect(trunc32(-1.3) == -1.0);
+ expect(trunc32(0.2) == 0.0);
}
test "math.trunc64" {
- assert(trunc64(1.3) == 1.0);
- assert(trunc64(-1.3) == -1.0);
- assert(trunc64(0.2) == 0.0);
+ expect(trunc64(1.3) == 1.0);
+ expect(trunc64(-1.3) == -1.0);
+ expect(trunc64(0.2) == 0.0);
}
test "math.trunc32.special" {
- assert(trunc32(0.0) == 0.0); // 0x3F800000
- assert(trunc32(-0.0) == -0.0);
- assert(math.isPositiveInf(trunc32(math.inf(f32))));
- assert(math.isNegativeInf(trunc32(-math.inf(f32))));
- assert(math.isNan(trunc32(math.nan(f32))));
+ expect(trunc32(0.0) == 0.0); // 0x3F800000
+ expect(trunc32(-0.0) == -0.0);
+ expect(math.isPositiveInf(trunc32(math.inf(f32))));
+ expect(math.isNegativeInf(trunc32(-math.inf(f32))));
+ expect(math.isNan(trunc32(math.nan(f32))));
}
test "math.trunc64.special" {
- assert(trunc64(0.0) == 0.0);
- assert(trunc64(-0.0) == -0.0);
- assert(math.isPositiveInf(trunc64(math.inf(f64))));
- assert(math.isNegativeInf(trunc64(-math.inf(f64))));
- assert(math.isNan(trunc64(math.nan(f64))));
+ expect(trunc64(0.0) == 0.0);
+ expect(trunc64(-0.0) == -0.0);
+ expect(math.isPositiveInf(trunc64(math.inf(f64))));
+ expect(math.isNegativeInf(trunc64(-math.inf(f64))));
+ expect(math.isNan(trunc64(math.nan(f64))));
}