zig fmt: fix comment indent after multiline single statement if/while/for

This commit is contained in:
Isaac Freund
2021-02-24 13:46:11 +01:00
parent 15c7c6ab97
commit 371b21bdfb
2 changed files with 91 additions and 35 deletions

View File

@@ -4164,19 +4164,35 @@ test "zig fmt: for loop with ptr payload and index" {
);
}
// TODO
//test "zig fmt: proper indent line comment after multi-line single expr while loop" {
// try testCanonical(
// \\test {
// \\ while (a) : (b)
// \\ foo();
// \\
// \\ // bar
// \\ baz();
// \\}
// \\
// );
//}
test "zig fmt: proper indent line comment after multi-line single expr while loop" {
try testCanonical(
\\test {
\\ while (a) : (b)
\\ foo();
\\
\\ // bar
\\ baz();
\\}
\\
);
}
test "zig fmt: line comment after multiline single expr if statement with multiline string" {
try testCanonical(
\\test {
\\ if (foo)
\\ x =
\\ \\hello
\\ \\hello
\\ \\
\\ ;
\\
\\ // bar
\\ baz();
\\}
\\
);
}
test "zig fmt: respect extra newline between fn and pub usingnamespace" {
try testCanonical(