diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-05-09 22:23:44 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2023-05-10 15:16:50 -0400 |
| commit | c5b96c7447efde0d10de9689f03d151afcafbad5 (patch) | |
| tree | 5defce62f9cca4ee233197487c786ac197a7fb75 /test/behavior/maximum_minimum.zig | |
| parent | 2d2d79a05b8423c7638348dc5a89793c1e0cafce (diff) | |
| download | zig-c5b96c7447efde0d10de9689f03d151afcafbad5.tar.gz zig-c5b96c7447efde0d10de9689f03d151afcafbad5.zip | |
llvm: fix `@max`/`@min` of unsupported float types
Closes #15611
Diffstat (limited to 'test/behavior/maximum_minimum.zig')
| -rw-r--r-- | test/behavior/maximum_minimum.zig | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/behavior/maximum_minimum.zig b/test/behavior/maximum_minimum.zig index e6a8553e8c..1bd3723fca 100644 --- a/test/behavior/maximum_minimum.zig +++ b/test/behavior/maximum_minimum.zig @@ -96,6 +96,31 @@ test "@min for vectors" { comptime try S.doTheTest(); } +test "@min/max for floats" { + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO + + const S = struct { + fn doTheTest(comptime T: type) !void { + var x: T = -3.14; + var y: T = 5.27; + try expectEqual(x, @min(x, y)); + try expectEqual(x, @min(y, x)); + try expectEqual(y, @max(x, y)); + try expectEqual(y, @max(y, x)); + } + }; + + inline for (.{ f16, f32, f64, f80, f128, c_longdouble }) |T| { + try S.doTheTest(T); + comptime try S.doTheTest(T); + } + comptime try S.doTheTest(comptime_float); +} + test "@min/@max on lazy values" { const A = extern struct { u8_4: [4]u8 }; const B = extern struct { u8_16: [16]u8 }; |
