| author | |
| committer | |
| log | 28dbc5883763fb2b87ef8d186a57c3971d3414bc |
| tree | 558ee509260855bbc521a11fec469220e185a2ae |
| parent | 128e70ff3a056e5b800c624f7157b00fd624509b |
3 files changed, 15 insertions(+), 5 deletions(-)
lib/std/zig/parser_test.zig+1-1| ... | ... | @@ -1,4 +1,4 @@ |
| 1 | test "zig fmt: noasync block" { | |
| 1 | test "zig fmt: errdefer with payload" { | |
| 2 | 2 | try testCanonical( |
| 3 | 3 | \\pub fn main() anyerror!void { |
| 4 | 4 | \\ errdefer |a| x += 1; |
test/compile_errors.zig+12| ... | ... | @@ -2,6 +2,18 @@ const tests = @import("tests.zig"); |
| 2 | 2 | const std = @import("std"); |
| 3 | 3 | |
| 4 | 4 | pub 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 | ||
| 5 | 17 | cases.addTest("shift on type with non-power-of-two size", |
| 6 | 18 | \\export fn entry() void { |
| 7 | 19 | \\ const S = struct { |
test/stage1/behavior/defer.zig+2-4| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const expect = std.testing.expect; |
| 3 | 3 | const expectEqual = std.testing.expectEqual; |
| 4 | const expectError = std.testing.expectError; | |
| 4 | 5 | |
| 5 | 6 | var result: [3]u8 = undefined; |
| 6 | 7 | var index: usize = undefined; |
| ... | ... | @@ -105,10 +106,7 @@ test "errdefer with payload" { |
| 105 | 106 | return error.One; |
| 106 | 107 | } |
| 107 | 108 | fn doTheTest() void { |
| 108 | _ = foo() catch |err| switch (err) { | |
| 109 | error.One => {}, | |
| 110 | else => unreachable, | |
| 111 | }; | |
| 109 | expectError(error.One, foo()); | |
| 112 | 110 | } |
| 113 | 111 | }; |
| 114 | 112 | S.doTheTest(); |