Files
LearnGO/go/pkg/mod/mvdan.cc/gofumpt@v0.6.0/testdata/script/short-case.txtar
T
2024-09-19 21:38:24 -04:00

158 lines
2.1 KiB
Plaintext

exec gofumpt -w foo.go
cmp foo.go foo.go.golden
exec gofumpt -d foo.go.golden
! stdout .
-- foo.go --
package p
func f(r rune) {
switch r {
case 'a',
'b',
'c':
case 'd', 'e', 'f':
case 'a', 'b',
'c':
case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g',
'l', 'i', 's', 't', '.', '.', '.':
// before
case 'a',
'b': // inline
// after
case 'a', // middle
'b':
case 'a', 'b', 'c', 'd', 'e', 'f',
'g': // very very long inline comment at the end
case 'a', 'b', 'c',
'd': // short comment
}
{
{
{
{
{
switch r {
case 'i', 'n', 'd', 'e',
'n', 't', 'e', 'd':
}
}
}
}
}
}
}
func s(x int) {
switch x {
case
shortConstant1,
shortConstant2:
// A comment.
fmt.Println(x)
case
shortConstant3,
shortConstant4:
// Do nothing.
default:
// Another comment.
fmt.Println(x * 2)
}
}
func s(x int) {
switch x {
case
longerConstantName1,
longerConstantName2:
// A comment.
fmt.Println(x)
case
longerConstantName3,
longerConstantName4:
// Do nothing.
default:
// Another comment.
fmt.Println(x * 2)
}
}
-- foo.go.golden --
package p
func f(r rune) {
switch r {
case 'a', 'b', 'c':
case 'd', 'e', 'f':
case 'a', 'b', 'c':
case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g',
'l', 'i', 's', 't', '.', '.', '.':
// before
case 'a', 'b': // inline
// after
case 'a', // middle
'b':
case 'a', 'b', 'c', 'd', 'e', 'f',
'g': // very very long inline comment at the end
case 'a', 'b', 'c', 'd': // short comment
}
{
{
{
{
{
switch r {
case 'i', 'n', 'd', 'e',
'n', 't', 'e', 'd':
}
}
}
}
}
}
}
func s(x int) {
switch x {
case shortConstant1, shortConstant2:
// A comment.
fmt.Println(x)
case shortConstant3, shortConstant4:
// Do nothing.
default:
// Another comment.
fmt.Println(x * 2)
}
}
func s(x int) {
switch x {
case
longerConstantName1,
longerConstantName2:
// A comment.
fmt.Println(x)
case
longerConstantName3,
longerConstantName4:
// Do nothing.
default:
// Another comment.
fmt.Println(x * 2)
}
}