mirror of
https://github.com/ziglang/zig.git
synced 2024-11-30 09:02:32 +00:00
16 lines
462 B
Zig
16 lines
462 B
Zig
const std = @import("std");
|
|
const expect = std.testing.expect;
|
|
|
|
test "vector @reduce" {
|
|
const V = @Vector(4, i32);
|
|
const value = V{ 1, -1, 1, -1 };
|
|
const result = value > @as(V, @splat(0));
|
|
// result is { true, false, true, false };
|
|
try comptime expect(@TypeOf(result) == @Vector(4, bool));
|
|
const is_all_true = @reduce(.And, result);
|
|
try comptime expect(@TypeOf(is_all_true) == bool);
|
|
try expect(is_all_true == false);
|
|
}
|
|
|
|
// test
|