@@ -102,8 +102,8 @@ final class ConsecutiveStatementsTests: XCTestCase {
102102 }
103103 """ ,
104104 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 ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
106+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
107107 DiagnosticSpec ( locationMarker: " 3️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
108108 DiagnosticSpec ( locationMarker: " 4️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
109109 DiagnosticSpec ( locationMarker: " 5️⃣ " , message: " consecutive statements on a line must be separated by ';' " , fixIts: [ " insert ';' " ] ) ,
@@ -129,7 +129,7 @@ final class ConsecutiveStatementsTests: XCTestCase {
129129 )
130130 }
131131
132- func testConsecutiveStatements4 ( ) {
132+ func testConsecutiveStatements4a ( ) {
133133 assertParse (
134134 """
135135 class C {
@@ -142,12 +142,14 @@ final class ConsecutiveStatementsTests: XCTestCase {
142142 }
143143 """ ,
144144 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 ';' " , fixIts: [ " insert newline " , " insert ';'" ] )
146146 ] ,
147+ applyFixIts: [ " insert newline " ] ,
147148 fixedSource: """
148149 class C {
149150 // In a sequence of declarations.
150- var a, b : Int; func d() -> Int {}
151+ var a, b : Int
152+ func d() -> Int {}
151153 init() {
152154 a = 0
153155 b = 0
@@ -157,25 +159,75 @@ final class ConsecutiveStatementsTests: XCTestCase {
157159 )
158160 }
159161
160- func testConsecutiveStatements5( ) {
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 ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
176+ ] ,
177+ applyFixIts: [ " insert ';' " ] ,
178+ fixedSource: """
179+ class C {
180+ // In a sequence of declarations.
181+ var a, b : Int; func d() -> Int {}
182+ init() {
183+ a = 0
184+ b = 0
185+ }
186+ }
187+ """
188+ )
189+ }
190+
191+ func testConsecutiveStatements5a( ) {
161192 assertParse (
162193 """
163194 protocol P {
164195 func a()1️⃣ func b()
165196 }
166197 """ ,
167198 diagnostics: [
168- DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert ';' " ] )
199+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] )
169200 ] ,
201+ applyFixIts: [ " insert newline " ] ,
170202 fixedSource: """
171203 protocol P {
172- func a(); func b()
204+ func a()
205+ func b()
173206 }
174207 """
175208 )
176209 }
177210
178- func testConsecutiveStatements6( ) {
211+ func testConsecutiveStatements5b( ) {
212+ assertParse (
213+ """
214+ protocol P {
215+ func a()1️⃣ func b()
216+ }
217+ """ ,
218+ diagnostics: [
219+ DiagnosticSpec ( message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] )
220+ ] ,
221+ applyFixIts: [ " insert ';' " ] ,
222+ fixedSource: """
223+ protocol P {
224+ func a(); func b()
225+ }
226+ """
227+ )
228+ }
229+
230+ func testConsecutiveStatements6a( ) {
179231 assertParse (
180232 """
181233 enum Color {
@@ -184,18 +236,43 @@ final class ConsecutiveStatementsTests: XCTestCase {
184236 }
185237 """ ,
186238 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 ';' " ] ) ,
239+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
240+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';'" ] ) ,
189241 ] ,
242+ applyFixIts: [ " insert newline " ] ,
190243 fixedSource: """
191244 enum Color {
192- case Red; case Blue
193- func a() {}; func b() {}
245+ case Red
246+ case Blue
247+ func a() {}
248+ func b() {}
194249 }
195250 """
196251 )
197252 }
198253
254+ func testConsecutiveStatements6b( ) {
255+ assertParse (
256+ """
257+ enum Color {
258+ case Red1️⃣ case Blue
259+ func a() {}2️⃣ func b() {}
260+ }
261+ """ ,
262+ diagnostics: [
263+ DiagnosticSpec ( locationMarker: " 1️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] ) ,
264+ DiagnosticSpec ( locationMarker: " 2️⃣ " , message: " consecutive declarations on a line must be separated by ';' " , fixIts: [ " insert newline " , " insert ';' " ] ) ,
265+ ] ,
266+ applyFixIts: [ " insert ';' " ] ,
267+ fixedSource: """
268+ enum Color {
269+ case Red; case Blue
270+ func a() {}; func b() {}
271+ }
272+ """
273+ )
274+ }
275+
199276 func testConsecutiveStatements7( ) {
200277 assertParse (
201278 """
@@ -212,4 +289,24 @@ final class ConsecutiveStatementsTests: XCTestCase {
212289 """
213290 )
214291 }
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 ';' " , fixIts: [ " insert newline " , " insert ';' " ] ) ,
302+ ] ,
303+ applyFixIts: [ " insert newline " ] ,
304+ fixedSource: """
305+ class Foo {
306+ func a() {}/* some comment */
307+ func b() {}
308+ }
309+ """
310+ )
311+ }
215312}
0 commit comments