zig/test/behavior/select.zig
Andrew Kelley f27d3409bd behavior tests: disable failing stage1 test
My previous commit added a new behavior test that passes for stage2 but
I forgot to check whether it passes for stage1. Since it does not, it
has to be disabled.

Additionally, this commit organizes behavior tests; there is no longer a
section of tests only passing for stage1. Instead, tests are disabled on
an individual basis. There is an except for the file which has global
assembly in it.
2022-03-23 14:06:07 -07:00

27 lines
1.0 KiB
Zig

const std = @import("std");
const builtin = @import("builtin");
const mem = std.mem;
const expect = std.testing.expect;
test "@select" {
if (@import("builtin").zig_backend != .stage1) return error.SkipZigTest; // TODO
const S = struct {
fn doTheTest() !void {
var a: @Vector(4, bool) = [4]bool{ true, false, true, false };
var b: @Vector(4, i32) = [4]i32{ -1, 4, 999, -31 };
var c: @Vector(4, i32) = [4]i32{ -5, 1, 0, 1234 };
var abc = @select(i32, a, b, c);
try expect(mem.eql(i32, &@as([4]i32, abc), &[4]i32{ -1, 1, 999, 1234 }));
var x: @Vector(4, bool) = [4]bool{ false, false, false, true };
var y: @Vector(4, f32) = [4]f32{ 0.001, 33.4, 836, -3381.233 };
var z: @Vector(4, f32) = [4]f32{ 0.0, 312.1, -145.9, 9993.55 };
var xyz = @select(f32, x, y, z);
try expect(mem.eql(f32, &@as([4]f32, xyz), &[4]f32{ 0.0, 312.1, -145.9, -3381.233 }));
}
};
try S.doTheTest();
comptime try S.doTheTest();
}