Debian Codegraph @

testdata/script/short-case.txtar

raw
1 exec gofumpt -w foo.go
2 cmp foo.go foo.go.golden
3
4 exec gofumpt -d foo.go.golden
5 ! stdout .
6
7 -- foo.go --
8 package p
9
10 func f(r rune) {
11 switch r {
12 case 'a',
13 'b',
14 'c':
15
16 case 'd', 'e', 'f':
17
18 case 'a', 'b',
19 'c':
20
21 case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g',
22 'l', 'i', 's', 't', '.', '.', '.':
23
24 // before
25 case 'a',
26 'b': // inline
27 // after
28
29 case 'a', // middle
30 'b':
31
32 case 'a', 'b', 'c', 'd', 'e', 'f',
33 'g': // very very long inline comment at the end
34
35 case 'a', 'b', 'c',
36 'd': // short comment
37 }
38 {
39 {
40 {
41 {
42 {
43 switch r {
44 case 'i', 'n', 'd', 'e',
45 'n', 't', 'e', 'd':
46 }
47 }
48 }
49 }
50 }
51 }
52 }
53
54 func s(x int) {
55 switch x {
56 case
57 shortConstant1,
58 shortConstant2:
59 // A comment.
60 fmt.Println(x)
61 case
62 shortConstant3,
63 shortConstant4:
64 // Do nothing.
65 default:
66 // Another comment.
67 fmt.Println(x * 2)
68 }
69 }
70
71 func s(x int) {
72 switch x {
73 case
74 longerConstantName1,
75 longerConstantName2:
76 // A comment.
77 fmt.Println(x)
78 case
79 longerConstantName3,
80 longerConstantName4:
81 // Do nothing.
82 default:
83 // Another comment.
84 fmt.Println(x * 2)
85 }
86 }
87 -- foo.go.golden --
88 package p
89
90 func f(r rune) {
91 switch r {
92 case 'a', 'b', 'c':
93
94 case 'd', 'e', 'f':
95
96 case 'a', 'b', 'c':
97
98 case 'v', 'e', 'r', 'y', 'l', 'o', 'n', 'g',
99 'l', 'i', 's', 't', '.', '.', '.':
100
101 // before
102 case 'a', 'b': // inline
103 // after
104
105 case 'a', // middle
106 'b':
107
108 case 'a', 'b', 'c', 'd', 'e', 'f',
109 'g': // very very long inline comment at the end
110
111 case 'a', 'b', 'c', 'd': // short comment
112 }
113 {
114 {
115 {
116 {
117 {
118 switch r {
119 case 'i', 'n', 'd', 'e',
120 'n', 't', 'e', 'd':
121 }
122 }
123 }
124 }
125 }
126 }
127 }
128
129 func s(x int) {
130 switch x {
131 case shortConstant1, shortConstant2:
132 // A comment.
133 fmt.Println(x)
134 case shortConstant3, shortConstant4:
135 // Do nothing.
136 default:
137 // Another comment.
138 fmt.Println(x * 2)
139 }
140 }
141
142 func s(x int) {
143 switch x {
144 case
145 longerConstantName1,
146 longerConstantName2:
147 // A comment.
148 fmt.Println(x)
149 case
150 longerConstantName3,
151 longerConstantName4:
152 // Do nothing.
153 default:
154 // Another comment.
155 fmt.Println(x * 2)
156 }
157 }