aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/floatop.zig
diff options
context:
space:
mode:
authorkcbanner <kcbanner@gmail.com>2024-11-06 19:33:52 -0500
committerkcbanner <kcbanner@gmail.com>2025-03-03 15:35:07 -0500
commit981f84157ce9e37cdc7ea96ea736808b1273142e (patch)
tree664763af25eda9e0c9beeddd5eb7a21086205dbf /test/behavior/floatop.zig
parentedabcf61927f9699f9b869f304e9aed97f2c4a47 (diff)
downloadzig-981f84157ce9e37cdc7ea96ea736808b1273142e.tar.gz
zig-981f84157ce9e37cdc7ea96ea736808b1273142e.zip
Value: fix comparison of NaN in compareHeteroAdvanaced
Sema: fix equality comparison of signed zeroes and NaN in compareScalar tests: add test coverage for vector float comparisons
Diffstat (limited to 'test/behavior/floatop.zig')
-rw-r--r--test/behavior/floatop.zig11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig
index f2fa2f4b0a..0eb1bd2d93 100644
--- a/test/behavior/floatop.zig
+++ b/test/behavior/floatop.zig
@@ -194,7 +194,7 @@ fn testCmp(comptime T: type) !void {
try expect(x <= 2.0);
}
- @setEvalBranchQuota(2_000);
+ @setEvalBranchQuota(4_000);
var edges = [_]T{
-math.inf(T),
-math.floatMax(T),
@@ -210,6 +210,7 @@ fn testCmp(comptime T: type) !void {
};
_ = &edges;
for (edges, 0..) |rhs, rhs_i| {
+ const rhs_v: @Vector(4, T) = @splat(rhs);
for (edges, 0..) |lhs, lhs_i| {
const no_nan = lhs_i != 5 and rhs_i != 5;
const lhs_order = if (lhs_i < 5) lhs_i else lhs_i - 2;
@@ -220,6 +221,14 @@ fn testCmp(comptime T: type) !void {
try expect((lhs > rhs) == (no_nan and lhs_order > rhs_order));
try expect((lhs <= rhs) == (no_nan and lhs_order <= rhs_order));
try expect((lhs >= rhs) == (no_nan and lhs_order >= rhs_order));
+
+ const lhs_v: @Vector(4, T) = @splat(lhs);
+ try expect(@reduce(.And, (lhs_v == rhs_v)) == (no_nan and lhs_order == rhs_order));
+ try expect(@reduce(.And, (lhs_v != rhs_v)) == !(no_nan and lhs_order == rhs_order));
+ try expect(@reduce(.And, (lhs_v < rhs_v)) == (no_nan and lhs_order < rhs_order));
+ try expect(@reduce(.And, (lhs_v > rhs_v)) == (no_nan and lhs_order > rhs_order));
+ try expect(@reduce(.And, (lhs_v <= rhs_v)) == (no_nan and lhs_order <= rhs_order));
+ try expect(@reduce(.And, (lhs_v >= rhs_v)) == (no_nan and lhs_order >= rhs_order));
}
}
}