You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Tests/SwiftParserTest/translated/ConsecutiveStatementsTests.swift
+106-9Lines changed: 106 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -102,8 +102,8 @@ 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(locationMarker:"1️⃣", message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"]),
106
+
DiagnosticSpec(locationMarker:"2️⃣", message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"]),
107
107
DiagnosticSpec(locationMarker:"3️⃣", message:"consecutive statements on a line must be separated by ';'", fixIts:["insert ';'"]),
108
108
DiagnosticSpec(locationMarker:"4️⃣", message:"consecutive statements on a line must be separated by ';'", fixIts:["insert ';'"]),
109
109
DiagnosticSpec(locationMarker:"5️⃣", message:"consecutive statements on a line must be separated by ';'", fixIts:["insert ';'"]),
@@ -129,7 +129,7 @@ final class ConsecutiveStatementsTests: XCTestCase {
129
129
)
130
130
}
131
131
132
-
functestConsecutiveStatements4(){
132
+
functestConsecutiveStatements4a(){
133
133
assertParse(
134
134
"""
135
135
class C {
@@ -142,8 +142,39 @@ final class ConsecutiveStatementsTests: XCTestCase {
142
142
}
143
143
""",
144
144
diagnostics:[
145
-
DiagnosticSpec(message:"consecutive declarations on a line must be separated by ';'", fixIts:["insert ';'"])
145
+
DiagnosticSpec(message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"])
146
146
],
147
+
applyFixIts:["insert newline"],
148
+
fixedSource:"""
149
+
class C {
150
+
// In a sequence of declarations.
151
+
var a, b : Int
152
+
func d() -> Int {}
153
+
init() {
154
+
a = 0
155
+
b = 0
156
+
}
157
+
}
158
+
"""
159
+
)
160
+
}
161
+
162
+
func testConsecutiveStatements4b(){
163
+
assertParse(
164
+
"""
165
+
class C {
166
+
// In a sequence of declarations.
167
+
var a, b : Int1️⃣ func d() -> Int {}
168
+
init() {
169
+
a = 0
170
+
b = 0
171
+
}
172
+
}
173
+
""",
174
+
diagnostics:[
175
+
DiagnosticSpec(message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"])
176
+
],
177
+
applyFixIts:["insert ';'"],
147
178
fixedSource:"""
148
179
class C {
149
180
// In a sequence of declarations.
@@ -157,16 +188,37 @@ final class ConsecutiveStatementsTests: XCTestCase {
157
188
)
158
189
}
159
190
160
-
func testConsecutiveStatements5(){
191
+
func testConsecutiveStatements5a(){
192
+
assertParse(
193
+
"""
194
+
protocol P {
195
+
func a()1️⃣ func b()
196
+
}
197
+
""",
198
+
diagnostics:[
199
+
DiagnosticSpec(message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"])
200
+
],
201
+
applyFixIts:["insert newline"],
202
+
fixedSource:"""
203
+
protocol P {
204
+
func a()
205
+
func b()
206
+
}
207
+
"""
208
+
)
209
+
}
210
+
211
+
func testConsecutiveStatements5b(){
161
212
assertParse(
162
213
"""
163
214
protocol P {
164
215
func a()1️⃣ func b()
165
216
}
166
217
""",
167
218
diagnostics:[
168
-
DiagnosticSpec(message:"consecutive declarations on a line must be separated by ';'", fixIts:["insert ';'"])
219
+
DiagnosticSpec(message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"])
169
220
],
221
+
applyFixIts:["insert ';'"],
170
222
fixedSource:"""
171
223
protocol P {
172
224
func a(); func b()
@@ -175,7 +227,31 @@ final class ConsecutiveStatementsTests: XCTestCase {
175
227
)
176
228
}
177
229
178
-
func testConsecutiveStatements6(){
230
+
func testConsecutiveStatements6a(){
231
+
assertParse(
232
+
"""
233
+
enum Color {
234
+
case Red1️⃣ case Blue
235
+
func a() {}2️⃣ func b() {}
236
+
}
237
+
""",
238
+
diagnostics:[
239
+
DiagnosticSpec(locationMarker:"1️⃣", message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"]),
240
+
DiagnosticSpec(locationMarker:"2️⃣", message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"]),
241
+
],
242
+
applyFixIts:["insert newline"],
243
+
fixedSource:"""
244
+
enum Color {
245
+
case Red
246
+
case Blue
247
+
func a() {}
248
+
func b() {}
249
+
}
250
+
"""
251
+
)
252
+
}
253
+
254
+
func testConsecutiveStatements6b(){
179
255
assertParse(
180
256
"""
181
257
enum Color {
@@ -184,9 +260,10 @@ final class ConsecutiveStatementsTests: XCTestCase {
184
260
}
185
261
""",
186
262
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 ';'"]),
263
+
DiagnosticSpec(locationMarker:"1️⃣", message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"]),
264
+
DiagnosticSpec(locationMarker:"2️⃣", message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"]),
189
265
],
266
+
applyFixIts:["insert ';'"],
190
267
fixedSource:"""
191
268
enum Color {
192
269
case Red; case Blue
@@ -212,4 +289,24 @@ final class ConsecutiveStatementsTests: XCTestCase {
212
289
"""
213
290
)
214
291
}
292
+
293
+
func testConsecutiveStatements8(){
294
+
assertParse(
295
+
"""
296
+
class Foo {
297
+
func a() {}1️⃣/* some comment */ func b() {}
298
+
}
299
+
""",
300
+
diagnostics:[
301
+
DiagnosticSpec(locationMarker:"1️⃣", message:"consecutive declarations on a line must be separated by newline or ';'", fixIts:["insert newline","insert ';'"])
0 commit comments