aboutsummaryrefslogtreecommitdiff
path: root/std/math/tan.zig
diff options
context:
space:
mode:
authorMarc Tiehuis <marctiehuis@gmail.com>2017-06-20 23:01:04 +1200
committerMarc Tiehuis <marctiehuis@gmail.com>2017-06-20 23:10:22 +1200
commit5bbec42a4edb3f6758a9d67fcf763c660ac3f204 (patch)
tree3dc324d083f142935df53c5900edfc04c0f956f8 /std/math/tan.zig
parentc9fc8bd802f5ed52c4cc78b93f18fc5dc9b6bb7f (diff)
downloadzig-5bbec42a4edb3f6758a9d67fcf763c660ac3f204.tar.gz
zig-5bbec42a4edb3f6758a9d67fcf763c660ac3f204.zip
Add math special case tests and general fixes
- Should cover special case inputs for most functions - Fixed a number of runtime panicking behaviour reliant on shift overflow/division by zero etc.
Diffstat (limited to 'std/math/tan.zig')
-rw-r--r--std/math/tan.zig22
1 files changed, 22 insertions, 0 deletions
diff --git a/std/math/tan.zig b/std/math/tan.zig
index a2b7fddfa1..4ef4bf6c73 100644
--- a/std/math/tan.zig
+++ b/std/math/tan.zig
@@ -1,3 +1,9 @@
+// Special Cases:
+//
+// - tan(+-0) = +-0
+// - tan(+-inf) = nan
+// - tan(nan) = nan
+
const math = @import("index.zig");
const assert = @import("../debug.zig").assert;
@@ -150,3 +156,19 @@ test "math.tan64" {
assert(math.approxEq(f64, tan64(37.45), -0.254397, epsilon));
assert(math.approxEq(f64, tan64(89.123), 2.2858376, epsilon));
}
+
+test "math.tan32.special" {
+ assert(tan32(0.0) == 0.0);
+ assert(tan32(-0.0) == -0.0);
+ assert(math.isNan(tan32(math.inf(f32))));
+ assert(math.isNan(tan32(-math.inf(f32))));
+ assert(math.isNan(tan32(math.nan(f32))));
+}
+
+test "math.tan64.special" {
+ assert(tan64(0.0) == 0.0);
+ assert(tan64(-0.0) == -0.0);
+ assert(math.isNan(tan64(math.inf(f64))));
+ assert(math.isNan(tan64(-math.inf(f64))));
+ assert(math.isNan(tan64(math.nan(f64))));
+}