aboutsummaryrefslogtreecommitdiff
path: root/std/math/cbrt.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/cbrt.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/cbrt.zig')
-rw-r--r--std/math/cbrt.zig50
1 files changed, 25 insertions, 25 deletions
diff --git a/std/math/cbrt.zig b/std/math/cbrt.zig
index c067c5155a..957e026af4 100644
--- a/std/math/cbrt.zig
+++ b/std/math/cbrt.zig
@@ -6,7 +6,7 @@
const std = @import("../index.zig");
const math = std.math;
-const assert = std.debug.assert;
+const expect = std.testing.expect;
pub fn cbrt(x: var) @typeOf(x) {
const T = @typeOf(x);
@@ -114,44 +114,44 @@ fn cbrt64(x: f64) f64 {
}
test "math.cbrt" {
- assert(cbrt(f32(0.0)) == cbrt32(0.0));
- assert(cbrt(f64(0.0)) == cbrt64(0.0));
+ expect(cbrt(f32(0.0)) == cbrt32(0.0));
+ expect(cbrt(f64(0.0)) == cbrt64(0.0));
}
test "math.cbrt32" {
const epsilon = 0.000001;
- assert(cbrt32(0.0) == 0.0);
- assert(math.approxEq(f32, cbrt32(0.2), 0.584804, epsilon));
- assert(math.approxEq(f32, cbrt32(0.8923), 0.962728, epsilon));
- assert(math.approxEq(f32, cbrt32(1.5), 1.144714, epsilon));
- assert(math.approxEq(f32, cbrt32(37.45), 3.345676, epsilon));
- assert(math.approxEq(f32, cbrt32(123123.234375), 49.748501, epsilon));
+ expect(cbrt32(0.0) == 0.0);
+ expect(math.approxEq(f32, cbrt32(0.2), 0.584804, epsilon));
+ expect(math.approxEq(f32, cbrt32(0.8923), 0.962728, epsilon));
+ expect(math.approxEq(f32, cbrt32(1.5), 1.144714, epsilon));
+ expect(math.approxEq(f32, cbrt32(37.45), 3.345676, epsilon));
+ expect(math.approxEq(f32, cbrt32(123123.234375), 49.748501, epsilon));
}
test "math.cbrt64" {
const epsilon = 0.000001;
- assert(cbrt64(0.0) == 0.0);
- assert(math.approxEq(f64, cbrt64(0.2), 0.584804, epsilon));
- assert(math.approxEq(f64, cbrt64(0.8923), 0.962728, epsilon));
- assert(math.approxEq(f64, cbrt64(1.5), 1.144714, epsilon));
- assert(math.approxEq(f64, cbrt64(37.45), 3.345676, epsilon));
- assert(math.approxEq(f64, cbrt64(123123.234375), 49.748501, epsilon));
+ expect(cbrt64(0.0) == 0.0);
+ expect(math.approxEq(f64, cbrt64(0.2), 0.584804, epsilon));
+ expect(math.approxEq(f64, cbrt64(0.8923), 0.962728, epsilon));
+ expect(math.approxEq(f64, cbrt64(1.5), 1.144714, epsilon));
+ expect(math.approxEq(f64, cbrt64(37.45), 3.345676, epsilon));
+ expect(math.approxEq(f64, cbrt64(123123.234375), 49.748501, epsilon));
}
test "math.cbrt.special" {
- assert(cbrt32(0.0) == 0.0);
- assert(cbrt32(-0.0) == -0.0);
- assert(math.isPositiveInf(cbrt32(math.inf(f32))));
- assert(math.isNegativeInf(cbrt32(-math.inf(f32))));
- assert(math.isNan(cbrt32(math.nan(f32))));
+ expect(cbrt32(0.0) == 0.0);
+ expect(cbrt32(-0.0) == -0.0);
+ expect(math.isPositiveInf(cbrt32(math.inf(f32))));
+ expect(math.isNegativeInf(cbrt32(-math.inf(f32))));
+ expect(math.isNan(cbrt32(math.nan(f32))));
}
test "math.cbrt64.special" {
- assert(cbrt64(0.0) == 0.0);
- assert(cbrt64(-0.0) == -0.0);
- assert(math.isPositiveInf(cbrt64(math.inf(f64))));
- assert(math.isNegativeInf(cbrt64(-math.inf(f64))));
- assert(math.isNan(cbrt64(math.nan(f64))));
+ expect(cbrt64(0.0) == 0.0);
+ expect(cbrt64(-0.0) == -0.0);
+ expect(math.isPositiveInf(cbrt64(math.inf(f64))));
+ expect(math.isNegativeInf(cbrt64(-math.inf(f64))));
+ expect(math.isNan(cbrt64(math.nan(f64))));
}