diff options
| author | Carl Ã…stholm <carl@astholm.se> | 2023-08-20 23:47:06 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-08-21 11:26:25 -0700 |
| commit | 60fc18bd1c154f3c728a147c4574b5db8a17f08e (patch) | |
| tree | b5cbc46487b23e553715aba706e85cedb7c7eef5 /test/behavior/floatop.zig | |
| parent | f74e10cd4722512ac671f574b3d274ab48abb1a7 (diff) | |
| download | zig-60fc18bd1c154f3c728a147c4574b5db8a17f08e.tar.gz zig-60fc18bd1c154f3c728a147c4574b5db8a17f08e.zip | |
compiler_rt: fix f80 comparisons
This corrects comparisons between negative numbers.
Diffstat (limited to 'test/behavior/floatop.zig')
| -rw-r--r-- | test/behavior/floatop.zig | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index 6825dccf86..bd6fe1c2eb 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -70,6 +70,28 @@ fn testDifferentSizedFloatComparisons() !void { try expect(a < b); } +test "f80 comparisons" { + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_c and comptime builtin.cpu.arch.isArmOrThumb()) return error.SkipZigTest; + + try expect(compareF80(0.0, .eq, -0.0)); + try expect(compareF80(0.0, .lte, -0.0)); + try expect(compareF80(0.0, .gte, -0.0)); + try expect(compareF80(1.0, .neq, -1.0)); + try expect(compareF80(2.0, .lt, 4.0)); + try expect(compareF80(2.0, .lte, 4.0)); + try expect(compareF80(-2.0, .gt, -4.0)); + try expect(compareF80(-2.0, .gte, -4.0)); +} + +fn compareF80(x: f80, op: math.CompareOperator, y: f80) bool { + return math.compare(x, op, y); +} + // TODO This is waiting on library support for the Windows build (not sure why the other's don't need it) //test "@nearbyint" { // comptime testNearbyInt(); |
