Skip to content

Commit

Permalink
add test data for multi statements block formatter
Browse files Browse the repository at this point in the history
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
flan6 committed Aug 23, 2024
1 parent 86bffd6 commit 4519030
Showing 1 changed file with 195 additions and 0 deletions.
195 changes: 195 additions & 0 deletions testdata/script/block-multi.txtar
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()
}
}

0 comments on commit 4519030

Please sign in to comment.