@@ -102,8 +102,16 @@ final class ConsecutiveStatementsTests: XCTestCase {
102
102
}
103
103
""" ,
104
104
diagnostics: [
105
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
106
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
105
+ DiagnosticSpec (
106
+ locationMarker: " 1️⃣ " ,
107
+ message: " consecutive declarations on a line must be separated by newline or ';' " ,
108
+ fixIts: [ " insert newline " , " insert ';' " ]
109
+ ) ,
110
+ DiagnosticSpec (
111
+ locationMarker: " 2️⃣ " ,
112
+ message: " consecutive declarations on a line must be separated by newline or ';' " ,
113
+ fixIts: [ " insert newline " , " insert ';' " ]
114
+ ) ,
107
115
DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
108
116
DiagnosticSpec ( locationMarker: " 4️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
109
117
DiagnosticSpec ( locationMarker: " 5️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
@@ -129,7 +137,7 @@ final class ConsecutiveStatementsTests: XCTestCase {
129
137
)
130
138
}
131
139
132
- func testConsecutiveStatements4 ( ) {
140
+ func testConsecutiveStatements4a ( ) {
133
141
assertParse (
134
142
"""
135
143
class C {
@@ -142,8 +150,39 @@ final class ConsecutiveStatementsTests: XCTestCase {
142
150
}
143
151
""" ,
144
152
diagnostics: [
145
- DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] )
153
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by newline or ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
146
154
] ,
155
+ applyFixIts: [ " insert newline " ] ,
156
+ fixedSource: """
157
+ class C {
158
+ // In a sequence of declarations.
159
+ var a, b : Int
160
+ func d() -> Int {}
161
+ init() {
162
+ a = 0
163
+ b = 0
164
+ }
165
+ }
166
+ """
167
+ )
168
+ }
169
+
170
+ func testConsecutiveStatements4b( ) {
171
+ assertParse (
172
+ """
173
+ class C {
174
+ // In a sequence of declarations.
175
+ var a, b : Int1️⃣ func d() -> Int {}
176
+ init() {
177
+ a = 0
178
+ b = 0
179
+ }
180
+ }
181
+ """ ,
182
+ diagnostics: [
183
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by newline or ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
184
+ ] ,
185
+ applyFixIts: [ " insert ';' " ] ,
147
186
fixedSource: """
148
187
class C {
149
188
// In a sequence of declarations.
@@ -157,16 +196,37 @@ final class ConsecutiveStatementsTests: XCTestCase {
157
196
)
158
197
}
159
198
160
- func testConsecutiveStatements5( ) {
199
+ func testConsecutiveStatements5a( ) {
200
+ assertParse (
201
+ """
202
+ protocol P {
203
+ func a()1️⃣ func b()
204
+ }
205
+ """ ,
206
+ diagnostics: [
207
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by newline or ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
208
+ ] ,
209
+ applyFixIts: [ " insert newline " ] ,
210
+ fixedSource: """
211
+ protocol P {
212
+ func a()
213
+ func b()
214
+ }
215
+ """
216
+ )
217
+ }
218
+
219
+ func testConsecutiveStatements5b( ) {
161
220
assertParse (
162
221
"""
163
222
protocol P {
164
223
func a()1️⃣ func b()
165
224
}
166
225
""" ,
167
226
diagnostics: [
168
- DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] )
227
+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by newline or ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
169
228
] ,
229
+ applyFixIts: [ " insert ';' " ] ,
170
230
fixedSource: """
171
231
protocol P {
172
232
func a(); func b()
@@ -175,7 +235,39 @@ final class ConsecutiveStatementsTests: XCTestCase {
175
235
)
176
236
}
177
237
178
- func testConsecutiveStatements6( ) {
238
+ func testConsecutiveStatements6a( ) {
239
+ assertParse (
240
+ """
241
+ enum Color {
242
+ case Red1️⃣ case Blue
243
+ func a() {}2️⃣ func b() {}
244
+ }
245
+ """ ,
246
+ diagnostics: [
247
+ DiagnosticSpec (
248
+ locationMarker: " 1️⃣ " ,
249
+ message: " consecutive declarations on a line must be separated by newline or ';' " ,
250
+ fixIts: [ " insert newline " , " insert ';' " ]
251
+ ) ,
252
+ DiagnosticSpec (
253
+ locationMarker: " 2️⃣ " ,
254
+ message: " consecutive declarations on a line must be separated by newline or ';' " ,
255
+ fixIts: [ " insert newline " , " insert ';' " ]
256
+ ) ,
257
+ ] ,
258
+ applyFixIts: [ " insert newline " ] ,
259
+ fixedSource: """
260
+ enum Color {
261
+ case Red
262
+ case Blue
263
+ func a() {}
264
+ func b() {}
265
+ }
266
+ """
267
+ )
268
+ }
269
+
270
+ func testConsecutiveStatements6b( ) {
179
271
assertParse (
180
272
"""
181
273
enum Color {
@@ -184,9 +276,18 @@ final class ConsecutiveStatementsTests: XCTestCase {
184
276
}
185
277
""" ,
186
278
diagnostics: [
187
- DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
188
- DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
279
+ DiagnosticSpec (
280
+ locationMarker: " 1️⃣ " ,
281
+ message: " consecutive declarations on a line must be separated by newline or ';' " ,
282
+ fixIts: [ " insert newline " , " insert ';' " ]
283
+ ) ,
284
+ DiagnosticSpec (
285
+ locationMarker: " 2️⃣ " ,
286
+ message: " consecutive declarations on a line must be separated by newline or ';' " ,
287
+ fixIts: [ " insert newline " , " insert ';' " ]
288
+ ) ,
189
289
] ,
290
+ applyFixIts: [ " insert ';' " ] ,
190
291
fixedSource: """
191
292
enum Color {
192
293
case Red; case Blue
@@ -212,4 +313,28 @@ final class ConsecutiveStatementsTests: XCTestCase {
212
313
"""
213
314
)
214
315
}
316
+
317
+ func testConsecutiveStatements8( ) {
318
+ assertParse (
319
+ """
320
+ class Foo {
321
+ func a() {}1️⃣/* some comment */ func b() {}
322
+ }
323
+ """ ,
324
+ diagnostics: [
325
+ DiagnosticSpec (
326
+ locationMarker: " 1️⃣ " ,
327
+ message: " consecutive declarations on a line must be separated by newline or ';' " ,
328
+ fixIts: [ " insert newline " , " insert ';' " ]
329
+ )
330
+ ] ,
331
+ applyFixIts: [ " insert newline " ] ,
332
+ fixedSource: """
333
+ class Foo {
334
+ func a() {}/* some comment */
335
+ func b() {}
336
+ }
337
+ """
338
+ )
339
+ }
215
340
}
0 commit comments