authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-20 22:23:51+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-03-21 09:54:49+01:00
log28dbc5883763fb2b87ef8d186a57c3971d3414bc
tree558ee509260855bbc521a11fec469220e185a2ae
parent128e70ff3a056e5b800c624f7157b00fd624509b

Address review comments


3 files changed, 15 insertions(+), 5 deletions(-)

lib/std/zig/parser_test.zig+1-1
......@@ -1,4 +1,4 @@
1test "zig fmt: noasync block" {
1test "zig fmt: errdefer with payload" {
22 try testCanonical(
33 \\pub fn main() anyerror!void {
44 \\ errdefer |a| x += 1;
test/compile_errors.zig+12
......@@ -2,6 +2,18 @@ const tests = @import("tests.zig");
22const std = @import("std");
33
44pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.addTest("unused variable error on errdefer",
6 \\fn foo() !void {
7 \\ errdefer |a| unreachable;
8 \\ return error.A;
9 \\}
10 \\export fn entry() void {
11 \\ foo() catch unreachable;
12 \\}
13 , &[_][]const u8{
14 "tmp.zig:2:15: error: unused variable: 'a'",
15 });
16
517 cases.addTest("shift on type with non-power-of-two size",
618 \\export fn entry() void {
719 \\ const S = struct {
test/stage1/behavior/defer.zig+2-4
......@@ -1,6 +1,7 @@
11const std = @import("std");
22const expect = std.testing.expect;
33const expectEqual = std.testing.expectEqual;
4const expectError = std.testing.expectError;
45
56var result: [3]u8 = undefined;
67var index: usize = undefined;
......@@ -105,10 +106,7 @@ test "errdefer with payload" {
105106 return error.One;
106107 }
107108 fn doTheTest() void {
108 _ = foo() catch |err| switch (err) {
109 error.One => {},
110 else => unreachable,
111 };
109 expectError(error.One, foo());
112110 }
113111 };
114112 S.doTheTest();