fmt: Skip extra newline if doc_comment exists

This commit is contained in:
yunsh1
2023-10-09 02:03:20 +09:00
committed by Veikka Tuominen
parent 6a12fd62c1
commit 7e4177a4b1
2 changed files with 66 additions and 1 deletions

View File

@@ -4270,6 +4270,69 @@ test "zig fmt: remove newlines surrounding doc comment" {
);
}
test "zig fmt: remove newlines surrounding doc comment between members" {
try testTransform(
\\f1: i32,
\\
\\
\\/// doc comment
\\
\\f2: i32,
\\
,
\\f1: i32,
\\
\\/// doc comment
\\f2: i32,
\\
);
}
test "zig fmt: remove newlines surrounding doc comment between members within container decl (1)" {
try testTransform(
\\const Foo = struct {
\\ fn foo() void {}
\\
\\
\\ /// doc comment
\\
\\
\\ fn bar() void {}
\\};
\\
,
\\const Foo = struct {
\\ fn foo() void {}
\\
\\ /// doc comment
\\ fn bar() void {}
\\};
\\
);
}
test "zig fmt: remove newlines surrounding doc comment between members within container decl (2)" {
try testTransform(
\\const Foo = struct {
\\ fn foo() void {}
\\ /// doc comment 1
\\
\\ /// doc comment 2
\\
\\ fn bar() void {}
\\};
\\
,
\\const Foo = struct {
\\ fn foo() void {}
\\ /// doc comment 1
\\ /// doc comment 2
\\ fn bar() void {}
\\};
\\
);
}
test "zig fmt: remove newlines surrounding doc comment within container decl" {
try testTransform(
\\const Foo = struct {