aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/floatop.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2024-01-02 17:33:41 +0200
committerAndrew Kelley <andrew@ziglang.org>2024-01-06 16:49:41 -0800
commit804cee3b93cb7084c16ee61d3bcb57f7d3c9f0bc (patch)
tree3d8c534b1adc352b248255ef2906ef2bdf11dffc /test/behavior/floatop.zig
parent282ff8d3bd4a0d870a98f145aa87039e0409b745 (diff)
downloadzig-804cee3b93cb7084c16ee61d3bcb57f7d3c9f0bc.tar.gz
zig-804cee3b93cb7084c16ee61d3bcb57f7d3c9f0bc.zip
categorize `behavior/bugs/<issueno>.zig` tests
Diffstat (limited to 'test/behavior/floatop.zig')
-rw-r--r--test/behavior/floatop.zig81
1 files changed, 81 insertions, 0 deletions
diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig
index e1c870bce6..568fe6deef 100644
--- a/test/behavior/floatop.zig
+++ b/test/behavior/floatop.zig
@@ -1556,3 +1556,84 @@ test "comptime fixed-width float non-zero divided by zero produces signed Inf" {
test "comptime_float zero divided by zero produces zero" {
try expect((0.0 / 0.0) == 0.0);
}
+
+test "comptime float compared with runtime int" {
+ const f = 10.0;
+ var i: usize = 0;
+ _ = &i;
+ try std.testing.expect(i < f);
+}
+test "comptime nan < runtime 0" {
+ const f = comptime std.math.nan(f64);
+ var i: usize = 0;
+ _ = &i;
+ try std.testing.expect(!(f < i));
+}
+test "comptime inf > runtime 0" {
+ const f = comptime std.math.inf(f64);
+ var i: usize = 0;
+ _ = &i;
+ try std.testing.expect(f > i);
+}
+test "comptime -inf < runtime 0" {
+ const f = comptime -std.math.inf(f64);
+ var i: usize = 0;
+ _ = &i;
+ try std.testing.expect(f < i);
+}
+test "comptime inf >= runtime 1" {
+ const f = comptime std.math.inf(f64);
+ var i: usize = 1;
+ _ = &i;
+ try std.testing.expect(f >= i);
+}
+test "comptime isNan(nan * 1)" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const nan_times_one = comptime std.math.nan(f64) * 1;
+ try std.testing.expect(std.math.isNan(nan_times_one));
+}
+test "runtime isNan(nan * 1)" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const nan_times_one = std.math.nan(f64) * 1;
+ try std.testing.expect(std.math.isNan(nan_times_one));
+}
+test "comptime isNan(nan * 0)" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const nan_times_zero = comptime std.math.nan(f64) * 0;
+ try std.testing.expect(std.math.isNan(nan_times_zero));
+ const zero_times_nan = 0 * comptime std.math.nan(f64);
+ try std.testing.expect(std.math.isNan(zero_times_nan));
+}
+test "runtime isNan(nan * 0)" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const nan_times_zero = std.math.nan(f64) * 0;
+ try std.testing.expect(std.math.isNan(nan_times_zero));
+ const zero_times_nan = 0 * std.math.nan(f64);
+ try std.testing.expect(std.math.isNan(zero_times_nan));
+}
+test "comptime isNan(inf * 0)" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const inf_times_zero = comptime std.math.inf(f64) * 0;
+ try std.testing.expect(std.math.isNan(inf_times_zero));
+ const zero_times_inf = 0 * comptime std.math.inf(f64);
+ try std.testing.expect(std.math.isNan(zero_times_inf));
+}
+test "runtime isNan(inf * 0)" {
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO
+ if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
+
+ const inf_times_zero = std.math.inf(f64) * 0;
+ try std.testing.expect(std.math.isNan(inf_times_zero));
+ const zero_times_inf = 0 * std.math.inf(f64);
+ try std.testing.expect(std.math.isNan(zero_times_inf));
+}