mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
test: separate out float vector tests and skip them on unsupported backends
This commit is contained in:
parent
981f84157c
commit
71d0d4bbfe
@ -132,13 +132,19 @@ test "cmp f16" {
|
||||
try comptime testCmp(f16);
|
||||
}
|
||||
|
||||
test "cmp f32/f64" {
|
||||
test "cmp f32" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch.isArm() and builtin.target.abi.float() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
|
||||
|
||||
try testCmp(f32);
|
||||
try comptime testCmp(f32);
|
||||
}
|
||||
|
||||
test "cmp f64" {
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
|
||||
|
||||
try testCmp(f64);
|
||||
try comptime testCmp(f64);
|
||||
}
|
||||
@ -194,6 +200,92 @@ fn testCmp(comptime T: type) !void {
|
||||
try expect(x <= 2.0);
|
||||
}
|
||||
|
||||
@setEvalBranchQuota(2_000);
|
||||
var edges = [_]T{
|
||||
-math.inf(T),
|
||||
-math.floatMax(T),
|
||||
-math.floatMin(T),
|
||||
-math.floatTrueMin(T),
|
||||
-0.0,
|
||||
math.nan(T),
|
||||
0.0,
|
||||
math.floatTrueMin(T),
|
||||
math.floatMin(T),
|
||||
math.floatMax(T),
|
||||
math.inf(T),
|
||||
};
|
||||
_ = &edges;
|
||||
for (edges, 0..) |rhs, rhs_i| {
|
||||
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;
|
||||
const rhs_order = if (rhs_i < 5) rhs_i else rhs_i - 2;
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test "vector cmp f16" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
|
||||
|
||||
try testCmpVector(f16);
|
||||
try comptime testCmpVector(f16);
|
||||
}
|
||||
|
||||
test "vector cmp f32" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
|
||||
|
||||
try testCmpVector(f32);
|
||||
try comptime testCmpVector(f32);
|
||||
}
|
||||
|
||||
test "vector cmp f64" {
|
||||
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch.isArm() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234
|
||||
|
||||
try testCmpVector(f64);
|
||||
try comptime testCmpVector(f64);
|
||||
}
|
||||
|
||||
test "vector cmp f128" {
|
||||
if (builtin.zig_backend == .stage2_wasm) 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_c and builtin.cpu.arch.isArm()) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest;
|
||||
|
||||
try testCmpVector(f128);
|
||||
try comptime testCmpVector(f128);
|
||||
}
|
||||
|
||||
test "vector cmp f80/c_longdouble" {
|
||||
if (true) return error.SkipZigTest;
|
||||
|
||||
try testCmpVector(f80);
|
||||
try comptime testCmpVector(f80);
|
||||
try testCmpVector(c_longdouble);
|
||||
try comptime testCmpVector(c_longdouble);
|
||||
}
|
||||
fn testCmpVector(comptime T: type) !void {
|
||||
@setEvalBranchQuota(4_000);
|
||||
var edges = [_]T{
|
||||
-math.inf(T),
|
||||
@ -210,19 +302,12 @@ fn testCmp(comptime T: type) !void {
|
||||
};
|
||||
_ = &edges;
|
||||
for (edges, 0..) |rhs, rhs_i| {
|
||||
const rhs_v: @Vector(4, T) = @splat(rhs);
|
||||
const rhs_v: @Vector(4, T) = .{ rhs, rhs, rhs, 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;
|
||||
const rhs_order = if (rhs_i < 5) rhs_i else rhs_i - 2;
|
||||
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));
|
||||
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);
|
||||
const lhs_v: @Vector(4, T) = .{ lhs, lhs, lhs, 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));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user