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/ceil.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/ceil.zig')
| -rw-r--r-- | std/math/ceil.zig | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/std/math/ceil.zig b/std/math/ceil.zig index 8a5221d862..5c6b98b2ca 100644 --- a/std/math/ceil.zig +++ b/std/math/ceil.zig @@ -7,7 +7,7 @@ const builtin = @import("builtin"); const std = @import("../index.zig"); const math = std.math; -const assert = std.debug.assert; +const expect = std.testing.expect; pub fn ceil(x: var) @typeOf(x) { const T = @typeOf(x); @@ -81,34 +81,34 @@ fn ceil64(x: f64) f64 { } test "math.ceil" { - assert(ceil(f32(0.0)) == ceil32(0.0)); - assert(ceil(f64(0.0)) == ceil64(0.0)); + expect(ceil(f32(0.0)) == ceil32(0.0)); + expect(ceil(f64(0.0)) == ceil64(0.0)); } test "math.ceil32" { - assert(ceil32(1.3) == 2.0); - assert(ceil32(-1.3) == -1.0); - assert(ceil32(0.2) == 1.0); + expect(ceil32(1.3) == 2.0); + expect(ceil32(-1.3) == -1.0); + expect(ceil32(0.2) == 1.0); } test "math.ceil64" { - assert(ceil64(1.3) == 2.0); - assert(ceil64(-1.3) == -1.0); - assert(ceil64(0.2) == 1.0); + expect(ceil64(1.3) == 2.0); + expect(ceil64(-1.3) == -1.0); + expect(ceil64(0.2) == 1.0); } test "math.ceil32.special" { - assert(ceil32(0.0) == 0.0); - assert(ceil32(-0.0) == -0.0); - assert(math.isPositiveInf(ceil32(math.inf(f32)))); - assert(math.isNegativeInf(ceil32(-math.inf(f32)))); - assert(math.isNan(ceil32(math.nan(f32)))); + expect(ceil32(0.0) == 0.0); + expect(ceil32(-0.0) == -0.0); + expect(math.isPositiveInf(ceil32(math.inf(f32)))); + expect(math.isNegativeInf(ceil32(-math.inf(f32)))); + expect(math.isNan(ceil32(math.nan(f32)))); } test "math.ceil64.special" { - assert(ceil64(0.0) == 0.0); - assert(ceil64(-0.0) == -0.0); - assert(math.isPositiveInf(ceil64(math.inf(f64)))); - assert(math.isNegativeInf(ceil64(-math.inf(f64)))); - assert(math.isNan(ceil64(math.nan(f64)))); + expect(ceil64(0.0) == 0.0); + expect(ceil64(-0.0) == -0.0); + expect(math.isPositiveInf(ceil64(math.inf(f64)))); + expect(math.isNegativeInf(ceil64(-math.inf(f64)))); + expect(math.isNan(ceil64(math.nan(f64)))); } |
