aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_reduce_builtin.zig
blob: 82b78b838028b53e7a18ae73159d1b9061b0535e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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