| ... | ... | @@ -19,7 +19,9 @@ test "zig fmt: decl between fields" { |
| 19 | 19 | \\ const baz1 = 2; |
| 20 | 20 | \\ b: usize, |
| 21 | 21 | \\}; |
| 22 | | ); |
| 22 | , &[_]Error{ |
| 23 | .DeclBetweenFields, |
| 24 | }); |
| 23 | 25 | } |
| 24 | 26 | |
| 25 | 27 | test "zig fmt: errdefer with payload" { |
| ... | ... | @@ -2828,7 +2830,9 @@ test "zig fmt: extern without container keyword returns error" { |
| 2828 | 2830 | try testError( |
| 2829 | 2831 | \\const container = extern {}; |
| 2830 | 2832 | \\ |
| 2831 | | ); |
| 2833 | , &[_]Error{ |
| 2834 | .ExpectedExpr, |
| 2835 | }); |
| 2832 | 2836 | } |
| 2833 | 2837 | |
| 2834 | 2838 | test "zig fmt: integer literals with underscore separators" { |
| ... | ... | @@ -3030,9 +3034,17 @@ fn testTransform(source: []const u8, expected_source: []const u8) !void { |
| 3030 | 3034 | fn testCanonical(source: []const u8) !void { |
| 3031 | 3035 | return testTransform(source, source); |
| 3032 | 3036 | } |
| 3033 | | fn testError(source: []const u8) !void { |
| 3037 | |
| 3038 | const Error = @TagType(std.zig.ast.Error); |
| 3039 | |
| 3040 | fn testError(source: []const u8, expected_errors: []const Error) !void { |
| 3034 | 3041 | const tree = try std.zig.parse(std.testing.allocator, source); |
| 3035 | 3042 | defer tree.deinit(); |
| 3036 | 3043 | |
| 3037 | | std.testing.expect(tree.errors.len != 0); |
| 3044 | std.testing.expect(tree.errors.len == expected_errors.len); |
| 3045 | for (expected_errors) |expected, i| { |
| 3046 | const err = tree.errors.at(i); |
| 3047 | |
| 3048 | std.testing.expect(expected == err.*); |
| 3049 | } |
| 3038 | 3050 | } |