diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-02-08 18:18:47 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-02-08 18:23:38 -0500 |
| commit | c2db077574be841da586fa62d67619c901dd535d (patch) | |
| tree | c8eb64846fa7ffb9027fa1ca035dd8ca5712b9d4 /std/math/fma.zig | |
| parent | be6d022257d8d7e99bd080823d4d8f0175f320c5 (diff) | |
| download | zig-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/fma.zig')
| -rw-r--r-- | std/math/fma.zig | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/std/math/fma.zig b/std/math/fma.zig index 21faf4118d..b084cf3cbd 100644 --- a/std/math/fma.zig +++ b/std/math/fma.zig @@ -1,6 +1,6 @@ const std = @import("../index.zig"); const math = std.math; -const assert = std.debug.assert; +const expect = std.testing.expect; pub fn fma(comptime T: type, x: T, y: T, z: T) T { return switch (T) { @@ -135,30 +135,30 @@ fn add_and_denorm(a: f64, b: f64, scale: i32) f64 { } test "math.fma" { - assert(fma(f32, 0.0, 1.0, 1.0) == fma32(0.0, 1.0, 1.0)); - assert(fma(f64, 0.0, 1.0, 1.0) == fma64(0.0, 1.0, 1.0)); + expect(fma(f32, 0.0, 1.0, 1.0) == fma32(0.0, 1.0, 1.0)); + expect(fma(f64, 0.0, 1.0, 1.0) == fma64(0.0, 1.0, 1.0)); } test "math.fma32" { const epsilon = 0.000001; - assert(math.approxEq(f32, fma32(0.0, 5.0, 9.124), 9.124, epsilon)); - assert(math.approxEq(f32, fma32(0.2, 5.0, 9.124), 10.124, epsilon)); - assert(math.approxEq(f32, fma32(0.8923, 5.0, 9.124), 13.5855, epsilon)); - assert(math.approxEq(f32, fma32(1.5, 5.0, 9.124), 16.624, epsilon)); - assert(math.approxEq(f32, fma32(37.45, 5.0, 9.124), 196.374004, epsilon)); - assert(math.approxEq(f32, fma32(89.123, 5.0, 9.124), 454.739005, epsilon)); - assert(math.approxEq(f32, fma32(123123.234375, 5.0, 9.124), 615625.295875, epsilon)); + expect(math.approxEq(f32, fma32(0.0, 5.0, 9.124), 9.124, epsilon)); + expect(math.approxEq(f32, fma32(0.2, 5.0, 9.124), 10.124, epsilon)); + expect(math.approxEq(f32, fma32(0.8923, 5.0, 9.124), 13.5855, epsilon)); + expect(math.approxEq(f32, fma32(1.5, 5.0, 9.124), 16.624, epsilon)); + expect(math.approxEq(f32, fma32(37.45, 5.0, 9.124), 196.374004, epsilon)); + expect(math.approxEq(f32, fma32(89.123, 5.0, 9.124), 454.739005, epsilon)); + expect(math.approxEq(f32, fma32(123123.234375, 5.0, 9.124), 615625.295875, epsilon)); } test "math.fma64" { const epsilon = 0.000001; - assert(math.approxEq(f64, fma64(0.0, 5.0, 9.124), 9.124, epsilon)); - assert(math.approxEq(f64, fma64(0.2, 5.0, 9.124), 10.124, epsilon)); - assert(math.approxEq(f64, fma64(0.8923, 5.0, 9.124), 13.5855, epsilon)); - assert(math.approxEq(f64, fma64(1.5, 5.0, 9.124), 16.624, epsilon)); - assert(math.approxEq(f64, fma64(37.45, 5.0, 9.124), 196.374, epsilon)); - assert(math.approxEq(f64, fma64(89.123, 5.0, 9.124), 454.739, epsilon)); - assert(math.approxEq(f64, fma64(123123.234375, 5.0, 9.124), 615625.295875, epsilon)); + expect(math.approxEq(f64, fma64(0.0, 5.0, 9.124), 9.124, epsilon)); + expect(math.approxEq(f64, fma64(0.2, 5.0, 9.124), 10.124, epsilon)); + expect(math.approxEq(f64, fma64(0.8923, 5.0, 9.124), 13.5855, epsilon)); + expect(math.approxEq(f64, fma64(1.5, 5.0, 9.124), 16.624, epsilon)); + expect(math.approxEq(f64, fma64(37.45, 5.0, 9.124), 196.374, epsilon)); + expect(math.approxEq(f64, fma64(89.123, 5.0, 9.124), 454.739, epsilon)); + expect(math.approxEq(f64, fma64(123123.234375, 5.0, 9.124), 615625.295875, epsilon)); } |
