forked from mvdan/gofumpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test data for multi statements block formatter
ensures that format removes empty lines at the top of a block unconditionally and bottom unless it is followed by an else-if statement. see issue mvdan#284
- Loading branch information
Showing
1 changed file
with
195 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,195 @@ | ||
exec gofumpt -w foo.go | ||
cmp foo.go foo.go.golden | ||
|
||
exec gofumpt -d foo.go.golden | ||
! stdout . | ||
|
||
-- foo.go -- | ||
package p | ||
|
||
func f() { | ||
if true { | ||
|
||
println() | ||
println() | ||
|
||
println() | ||
} | ||
|
||
for true { | ||
println() | ||
println() | ||
|
||
println() | ||
|
||
} | ||
|
||
{ | ||
|
||
|
||
println(1, 2, | ||
3, 4, `foo | ||
bar`) | ||
|
||
println(1, 2, | ||
3, 4, `foo | ||
bar`) | ||
|
||
|
||
|
||
} | ||
|
||
{ | ||
|
||
// comment directly before | ||
println() | ||
println() | ||
|
||
println() | ||
|
||
// comment after | ||
|
||
} | ||
|
||
{ | ||
|
||
// comment before | ||
|
||
println() | ||
println() | ||
|
||
println() | ||
// comment directly after | ||
|
||
} | ||
|
||
// For readability; the empty line helps separate the multi-line | ||
// condition from the body. | ||
if true && | ||
true { | ||
|
||
println() | ||
println() | ||
|
||
println() | ||
} | ||
if true && | ||
true { | ||
println() | ||
println() | ||
|
||
println() | ||
|
||
} else if true { | ||
println() | ||
println() | ||
|
||
println() | ||
} | ||
for true && | ||
true { | ||
|
||
println() | ||
println() | ||
|
||
println() | ||
} | ||
if true && | ||
true { | ||
|
||
// documented multi statement | ||
println() | ||
println() | ||
|
||
println() | ||
} | ||
} | ||
-- foo.go.golden -- | ||
package p | ||
|
||
func f() { | ||
if true { | ||
println() | ||
println() | ||
|
||
println() | ||
} | ||
|
||
for true { | ||
println() | ||
println() | ||
|
||
println() | ||
} | ||
|
||
{ | ||
println(1, 2, | ||
3, 4, `foo | ||
bar`) | ||
|
||
println(1, 2, | ||
3, 4, `foo | ||
bar`) | ||
} | ||
|
||
{ | ||
// comment directly before | ||
println() | ||
println() | ||
|
||
println() | ||
|
||
// comment after | ||
} | ||
|
||
{ | ||
// comment before | ||
|
||
println() | ||
println() | ||
|
||
println() | ||
// comment directly after | ||
} | ||
|
||
// For readability; the empty line helps separate the multi-line | ||
// condition from the body. | ||
if true && | ||
true { | ||
|
||
println() | ||
println() | ||
|
||
println() | ||
} | ||
if true && | ||
true { | ||
println() | ||
println() | ||
|
||
println() | ||
|
||
} else if true { | ||
println() | ||
println() | ||
|
||
println() | ||
} | ||
for true && | ||
true { | ||
|
||
println() | ||
println() | ||
|
||
println() | ||
} | ||
if true && | ||
true { | ||
|
||
// documented multi statement | ||
println() | ||
println() | ||
|
||
println() | ||
} | ||
} |