authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-16 11:22:28-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-12-16 11:22:28-05:00
log1cad0acc7e4450d2f114ea87da2fd88b81694332
tree0ef840543483d59f37445249bada1d8ff1f3df54
parent9468d6381997dedaf3330f0c6e1b4290a9af1345
signaturelock-open Commit is signed but in an unrecognized format.

add behavior test for vector comparison


1 files changed, 18 insertions(+), 0 deletions(-)

test/stage1/behavior/math.zig+18
...@@ -4,6 +4,7 @@ const expectEqual = std.testing.expectEqual;...@@ -4,6 +4,7 @@ const expectEqual = std.testing.expectEqual;
4const expectEqualSlices = std.testing.expectEqualSlices;4const expectEqualSlices = std.testing.expectEqualSlices;
5const maxInt = std.math.maxInt;5const maxInt = std.math.maxInt;
6const minInt = std.math.minInt;6const minInt = std.math.minInt;
7const mem = std.mem;
78
8test "division" {9test "division" {
9 if (@import("builtin").arch == .riscv64) {10 if (@import("builtin").arch == .riscv64) {
...@@ -653,3 +654,20 @@ test "128-bit multiplication" {...@@ -653,3 +654,20 @@ test "128-bit multiplication" {
653 var c = a * b;654 var c = a * b;
654 expect(c == 6);655 expect(c == 6);
655}656}
657
658test "vector comparison" {
659 const S = struct {
660 fn doTheTest() void {
661 var a: @Vector(6, i32) = [_]i32{1, 3, -1, 5, 7, 9};
662 var b: @Vector(6, i32) = [_]i32{-1, 3, 0, 6, 10, -10};
663 expect(mem.eql(bool, &@as([6]bool, a < b), &[_]bool{false, false, true, true, true, false}));
664 expect(mem.eql(bool, &@as([6]bool, a <= b), &[_]bool{false, true, true, true, true, false}));
665 expect(mem.eql(bool, &@as([6]bool, a == b), &[_]bool{false, true, false, false, false, false}));
666 expect(mem.eql(bool, &@as([6]bool, a != b), &[_]bool{true, false, true, true, true, true}));
667 expect(mem.eql(bool, &@as([6]bool, a > b), &[_]bool{true, false, false, false, false, true}));
668 expect(mem.eql(bool, &@as([6]bool, a >= b), &[_]bool{true, true, false, false, false, true}));
669 }
670 };
671 S.doTheTest();
672 comptime S.doTheTest();
673}