| author | |
| committer | |
| log | e548195fd5ddedb5b2d87ef4b396666917e6d9b6 |
| tree | 674f54217636d2168e804558aa52734b095d618c |
| parent | f34abbf2602c60a562988631de6a3dcbefbbb4cd |
Fix a typo and add a test case.2 files changed, 10 insertions(+), 1 deletions(-)
lib/std/zig/parser_test.zig+9| ... | ... | @@ -7,6 +7,15 @@ test "zig fmt: trailing comma in container declaration" { |
| 7 | 7 | \\const X = struct { foo: i32 align(4) = 1, bar: i32 align(4) = 2 }; |
| 8 | 8 | \\ |
| 9 | 9 | ); |
| 10 | try testTransform( | |
| 11 | \\const X = struct { | |
| 12 | \\ foo: i32, bar: i8 }; | |
| 13 | , | |
| 14 | \\const X = struct { | |
| 15 | \\ foo: i32, bar: i8 | |
| 16 | \\}; | |
| 17 | \\ | |
| 18 | ); | |
| 10 | 19 | } |
| 11 | 20 | |
| 12 | 21 | test "zig fmt: trailing comma in fn parameter list" { |
lib/std/zig/render.zig+1-1| ... | ... | @@ -1181,8 +1181,8 @@ fn renderExpression( |
| 1181 | 1181 | |
| 1182 | 1182 | // Check if the first declaration and the { are on the same line |
| 1183 | 1183 | const src_has_newline = !tree.tokensOnSameLine( |
| 1184 | container_decl.lbrace_token, | |
| 1184 | 1185 | container_decl.fields_and_decls.at(0).*.firstToken(), |
| 1185 | container_decl.rbrace_token, | |
| 1186 | 1186 | ); |
| 1187 | 1187 | |
| 1188 | 1188 | // We can only print all the elements in-line if all the |