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/asin.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/asin.zig')
| -rw-r--r-- | std/math/asin.zig | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/std/math/asin.zig b/std/math/asin.zig index 30b3a57e32..c9dbdf704f 100644 --- a/std/math/asin.zig +++ b/std/math/asin.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 asin(x: var) @typeOf(x) { const T = @typeOf(x); @@ -136,42 +136,42 @@ fn asin64(x: f64) f64 { } test "math.asin" { - assert(asin(f32(0.0)) == asin32(0.0)); - assert(asin(f64(0.0)) == asin64(0.0)); + expect(asin(f32(0.0)) == asin32(0.0)); + expect(asin(f64(0.0)) == asin64(0.0)); } test "math.asin32" { const epsilon = 0.000001; - assert(math.approxEq(f32, asin32(0.0), 0.0, epsilon)); - assert(math.approxEq(f32, asin32(0.2), 0.201358, epsilon)); - assert(math.approxEq(f32, asin32(-0.2), -0.201358, epsilon)); - assert(math.approxEq(f32, asin32(0.3434), 0.350535, epsilon)); - assert(math.approxEq(f32, asin32(0.5), 0.523599, epsilon)); - assert(math.approxEq(f32, asin32(0.8923), 1.102415, epsilon)); + expect(math.approxEq(f32, asin32(0.0), 0.0, epsilon)); + expect(math.approxEq(f32, asin32(0.2), 0.201358, epsilon)); + expect(math.approxEq(f32, asin32(-0.2), -0.201358, epsilon)); + expect(math.approxEq(f32, asin32(0.3434), 0.350535, epsilon)); + expect(math.approxEq(f32, asin32(0.5), 0.523599, epsilon)); + expect(math.approxEq(f32, asin32(0.8923), 1.102415, epsilon)); } test "math.asin64" { const epsilon = 0.000001; - assert(math.approxEq(f64, asin64(0.0), 0.0, epsilon)); - assert(math.approxEq(f64, asin64(0.2), 0.201358, epsilon)); - assert(math.approxEq(f64, asin64(-0.2), -0.201358, epsilon)); - assert(math.approxEq(f64, asin64(0.3434), 0.350535, epsilon)); - assert(math.approxEq(f64, asin64(0.5), 0.523599, epsilon)); - assert(math.approxEq(f64, asin64(0.8923), 1.102415, epsilon)); + expect(math.approxEq(f64, asin64(0.0), 0.0, epsilon)); + expect(math.approxEq(f64, asin64(0.2), 0.201358, epsilon)); + expect(math.approxEq(f64, asin64(-0.2), -0.201358, epsilon)); + expect(math.approxEq(f64, asin64(0.3434), 0.350535, epsilon)); + expect(math.approxEq(f64, asin64(0.5), 0.523599, epsilon)); + expect(math.approxEq(f64, asin64(0.8923), 1.102415, epsilon)); } test "math.asin32.special" { - assert(asin32(0.0) == 0.0); - assert(asin32(-0.0) == -0.0); - assert(math.isNan(asin32(-2))); - assert(math.isNan(asin32(1.5))); + expect(asin32(0.0) == 0.0); + expect(asin32(-0.0) == -0.0); + expect(math.isNan(asin32(-2))); + expect(math.isNan(asin32(1.5))); } test "math.asin64.special" { - assert(asin64(0.0) == 0.0); - assert(asin64(-0.0) == -0.0); - assert(math.isNan(asin64(-2))); - assert(math.isNan(asin64(1.5))); + expect(asin64(0.0) == 0.0); + expect(asin64(-0.0) == -0.0); + expect(math.isNan(asin64(-2))); + expect(math.isNan(asin64(1.5))); } |
