From 0e830b16306945ffc74ef95198eb74743ab9f184 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 22 Apr 2022 07:52:21 -0700 Subject: [PATCH] clean up behavior tests Split big test into the two separate things it is testing. Add missing checks to the test which revealed the test is not actually passing yet for the C backend. --- test/behavior/array.zig | 6 +++--- test/behavior/fn.zig | 30 +++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/test/behavior/array.zig b/test/behavior/array.zig index bf5e74e81924cfa1a7bd271bd910386bd5b3016b..728e05271ace44ee61c7847fc3806c7431cf64b4 100644 --- a/test/behavior/array.zig +++ b/test/behavior/array.zig @@ -163,9 +163,9 @@ test "nested arrays of strings" { } test "nested arrays of integers" { - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; + 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) return error.SkipZigTest; // TODO const array_of_numbers = [_][2]u8{ [2]u8{ 1, 2 }, diff --git a/test/behavior/fn.zig b/test/behavior/fn.zig index eabb6c77f41e324cb867f3b316751725bfb959b4..26185f6ac1ac6772caa19063a8694c558525727a 100644 --- a/test/behavior/fn.zig +++ b/test/behavior/fn.zig @@ -349,9 +349,9 @@ fn numberLiteralArg(a: anytype) !void { } test "function call with anon list literal" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { @@ -363,19 +363,31 @@ test "function call with anon list literal" { try expect(vec[1] == 8); try expect(vec[2] == 7); } + }; + try S.doTheTest(); + comptime try S.doTheTest(); +} + +test "function call with anon list literal - 2D" { + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO - fn doThe2DTest() !void { - try consume2DVec(.{ .{ 9, 8 }, .{ 7, 6 } }); + const S = struct { + fn doTheTest() !void { + try consumeVec(.{ .{ 9, 8 }, .{ 7, 6 } }); } - fn consume2DVec(vec: [2][2]f32) !void { - _ = vec; + fn consumeVec(vec: [2][2]f32) !void { + try expect(vec[0][0] == 9); + try expect(vec[0][1] == 8); + try expect(vec[1][0] == 7); + try expect(vec[1][1] == 6); } }; try S.doTheTest(); comptime try S.doTheTest(); - try S.doThe2DTest(); - comptime try S.doThe2DTest(); } test "ability to give comptime types and non comptime types to same parameter" { -- 2.54.0