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/atan.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/atan.zig')
| -rw-r--r-- | std/math/atan.zig | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/std/math/atan.zig b/std/math/atan.zig index 6ca94dd84a..72d17b4db2 100644 --- a/std/math/atan.zig +++ b/std/math/atan.zig @@ -5,7 +5,7 @@ const std = @import("../index.zig"); const math = std.math; -const assert = std.debug.assert; +const expect = std.testing.expect; pub fn atan(x: var) @typeOf(x) { const T = @typeOf(x); @@ -206,44 +206,44 @@ fn atan64(x_: f64) f64 { } test "math.atan" { - assert(@bitCast(u32, atan(f32(0.2))) == @bitCast(u32, atan32(0.2))); - assert(atan(f64(0.2)) == atan64(0.2)); + expect(@bitCast(u32, atan(f32(0.2))) == @bitCast(u32, atan32(0.2))); + expect(atan(f64(0.2)) == atan64(0.2)); } test "math.atan32" { const epsilon = 0.000001; - assert(math.approxEq(f32, atan32(0.2), 0.197396, epsilon)); - assert(math.approxEq(f32, atan32(-0.2), -0.197396, epsilon)); - assert(math.approxEq(f32, atan32(0.3434), 0.330783, epsilon)); - assert(math.approxEq(f32, atan32(0.8923), 0.728545, epsilon)); - assert(math.approxEq(f32, atan32(1.5), 0.982794, epsilon)); + expect(math.approxEq(f32, atan32(0.2), 0.197396, epsilon)); + expect(math.approxEq(f32, atan32(-0.2), -0.197396, epsilon)); + expect(math.approxEq(f32, atan32(0.3434), 0.330783, epsilon)); + expect(math.approxEq(f32, atan32(0.8923), 0.728545, epsilon)); + expect(math.approxEq(f32, atan32(1.5), 0.982794, epsilon)); } test "math.atan64" { const epsilon = 0.000001; - assert(math.approxEq(f64, atan64(0.2), 0.197396, epsilon)); - assert(math.approxEq(f64, atan64(-0.2), -0.197396, epsilon)); - assert(math.approxEq(f64, atan64(0.3434), 0.330783, epsilon)); - assert(math.approxEq(f64, atan64(0.8923), 0.728545, epsilon)); - assert(math.approxEq(f64, atan64(1.5), 0.982794, epsilon)); + expect(math.approxEq(f64, atan64(0.2), 0.197396, epsilon)); + expect(math.approxEq(f64, atan64(-0.2), -0.197396, epsilon)); + expect(math.approxEq(f64, atan64(0.3434), 0.330783, epsilon)); + expect(math.approxEq(f64, atan64(0.8923), 0.728545, epsilon)); + expect(math.approxEq(f64, atan64(1.5), 0.982794, epsilon)); } test "math.atan32.special" { const epsilon = 0.000001; - assert(atan32(0.0) == 0.0); - assert(atan32(-0.0) == -0.0); - assert(math.approxEq(f32, atan32(math.inf(f32)), math.pi / 2.0, epsilon)); - assert(math.approxEq(f32, atan32(-math.inf(f32)), -math.pi / 2.0, epsilon)); + expect(atan32(0.0) == 0.0); + expect(atan32(-0.0) == -0.0); + expect(math.approxEq(f32, atan32(math.inf(f32)), math.pi / 2.0, epsilon)); + expect(math.approxEq(f32, atan32(-math.inf(f32)), -math.pi / 2.0, epsilon)); } test "math.atan64.special" { const epsilon = 0.000001; - assert(atan64(0.0) == 0.0); - assert(atan64(-0.0) == -0.0); - assert(math.approxEq(f64, atan64(math.inf(f64)), math.pi / 2.0, epsilon)); - assert(math.approxEq(f64, atan64(-math.inf(f64)), -math.pi / 2.0, epsilon)); + expect(atan64(0.0) == 0.0); + expect(atan64(-0.0) == -0.0); + expect(math.approxEq(f64, atan64(math.inf(f64)), math.pi / 2.0, epsilon)); + expect(math.approxEq(f64, atan64(-math.inf(f64)), -math.pi / 2.0, epsilon)); } |
