aboutsummaryrefslogtreecommitdiff
path: root/std/math/atanh.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/atanh.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/atanh.zig')
-rw-r--r--std/math/atanh.zig38
1 files changed, 19 insertions, 19 deletions
diff --git a/std/math/atanh.zig b/std/math/atanh.zig
index c97855c234..f2feab0207 100644
--- a/std/math/atanh.zig
+++ b/std/math/atanh.zig
@@ -6,7 +6,7 @@
const std = @import("../index.zig");
const math = std.math;
-const assert = std.debug.assert;
+const expect = std.testing.expect;
const maxInt = std.math.maxInt;
pub fn atanh(x: var) @typeOf(x) {
@@ -78,38 +78,38 @@ fn atanh_64(x: f64) f64 {
}
test "math.atanh" {
- assert(atanh(f32(0.0)) == atanh_32(0.0));
- assert(atanh(f64(0.0)) == atanh_64(0.0));
+ expect(atanh(f32(0.0)) == atanh_32(0.0));
+ expect(atanh(f64(0.0)) == atanh_64(0.0));
}
test "math.atanh_32" {
const epsilon = 0.000001;
- assert(math.approxEq(f32, atanh_32(0.0), 0.0, epsilon));
- assert(math.approxEq(f32, atanh_32(0.2), 0.202733, epsilon));
- assert(math.approxEq(f32, atanh_32(0.8923), 1.433099, epsilon));
+ expect(math.approxEq(f32, atanh_32(0.0), 0.0, epsilon));
+ expect(math.approxEq(f32, atanh_32(0.2), 0.202733, epsilon));
+ expect(math.approxEq(f32, atanh_32(0.8923), 1.433099, epsilon));
}
test "math.atanh_64" {
const epsilon = 0.000001;
- assert(math.approxEq(f64, atanh_64(0.0), 0.0, epsilon));
- assert(math.approxEq(f64, atanh_64(0.2), 0.202733, epsilon));
- assert(math.approxEq(f64, atanh_64(0.8923), 1.433099, epsilon));
+ expect(math.approxEq(f64, atanh_64(0.0), 0.0, epsilon));
+ expect(math.approxEq(f64, atanh_64(0.2), 0.202733, epsilon));
+ expect(math.approxEq(f64, atanh_64(0.8923), 1.433099, epsilon));
}
test "math.atanh32.special" {
- assert(math.isPositiveInf(atanh_32(1)));
- assert(math.isNegativeInf(atanh_32(-1)));
- assert(math.isSignalNan(atanh_32(1.5)));
- assert(math.isSignalNan(atanh_32(-1.5)));
- assert(math.isNan(atanh_32(math.nan(f32))));
+ expect(math.isPositiveInf(atanh_32(1)));
+ expect(math.isNegativeInf(atanh_32(-1)));
+ expect(math.isSignalNan(atanh_32(1.5)));
+ expect(math.isSignalNan(atanh_32(-1.5)));
+ expect(math.isNan(atanh_32(math.nan(f32))));
}
test "math.atanh64.special" {
- assert(math.isPositiveInf(atanh_64(1)));
- assert(math.isNegativeInf(atanh_64(-1)));
- assert(math.isSignalNan(atanh_64(1.5)));
- assert(math.isSignalNan(atanh_64(-1.5)));
- assert(math.isNan(atanh_64(math.nan(f64))));
+ expect(math.isPositiveInf(atanh_64(1)));
+ expect(math.isNegativeInf(atanh_64(-1)));
+ expect(math.isSignalNan(atanh_64(1.5)));
+ expect(math.isSignalNan(atanh_64(-1.5)));
+ expect(math.isNan(atanh_64(math.nan(f64))));
}