@@ -1516,7 +1516,8 @@ final class DeclarationTests: ParserTestCase {
1516
1516
leftSquare: . leftSquareToken( ) ,
1517
1517
element: IdentifierTypeSyntax ( name: . identifier( " third " ) ) ,
1518
1518
rightSquare: . rightSquareToken( presence: . missing)
1519
- )
1519
+ ) ,
1520
+ trailingComma: . commaToken( presence: . missing)
1520
1521
) ,
1521
1522
diagnostics: [
1522
1523
DiagnosticSpec (
@@ -1532,11 +1533,12 @@ final class DeclarationTests: ParserTestCase {
1532
1533
) ,
1533
1534
DiagnosticSpec (
1534
1535
locationMarker: " 4️⃣ " ,
1535
- message: " unexpected code 'fourth: Int' in parameter clause "
1536
+ message: " expected ',' in parameter " ,
1537
+ fixIts: [ " insert ',' " ]
1536
1538
) ,
1537
1539
] ,
1538
1540
fixedSource: """
1539
- func foo(first second: [third]fourth: Int) {}
1541
+ func foo(first second: [third], fourth: Int) {}
1540
1542
"""
1541
1543
)
1542
1544
}
@@ -3402,4 +3404,73 @@ final class DeclarationTests: ParserTestCase {
3402
3404
]
3403
3405
)
3404
3406
}
3407
+
3408
+ func testMissingCommaInParameters( ) {
3409
+ assertParse (
3410
+ " func a(foo: Bar1️⃣ foo2: Bar2) {} " ,
3411
+ diagnostics: [
3412
+ DiagnosticSpec (
3413
+ message: " expected ',' in parameter " ,
3414
+ fixIts: [ " insert ',' " ]
3415
+ )
3416
+ ] ,
3417
+ fixedSource: " func a(foo: Bar, foo2: Bar2) {} "
3418
+ )
3419
+ }
3420
+
3421
+ func testMissingMultipleCommasInParameters( ) {
3422
+ assertParse (
3423
+ " func a(foo: Bar1️⃣ foo2: Bar2, foo3: Bar32️⃣ foo4: Bar4) {} " ,
3424
+ diagnostics: [
3425
+ DiagnosticSpec (
3426
+ locationMarker: " 1️⃣ " ,
3427
+ message: " expected ',' in parameter " ,
3428
+ fixIts: [ " insert ',' " ]
3429
+ ) ,
3430
+ DiagnosticSpec (
3431
+ locationMarker: " 2️⃣ " ,
3432
+ message: " expected ',' in parameter " ,
3433
+ fixIts: [ " insert ',' " ]
3434
+ ) ,
3435
+ ] ,
3436
+ fixedSource: " func a(foo: Bar, foo2: Bar2, foo3: Bar3, foo4: Bar4) {} "
3437
+ )
3438
+ }
3439
+
3440
+ func testMissingCommaInParametersAndAttributes( ) {
3441
+ assertParse (
3442
+ " func a(foo: Bar1️⃣ @escaping foo1: () -> Void) {} " ,
3443
+ diagnostics: [
3444
+ DiagnosticSpec (
3445
+ locationMarker: " 1️⃣ " ,
3446
+ message: " expected ',' in parameter " ,
3447
+ fixIts: [ " insert ',' " ]
3448
+ )
3449
+ ] ,
3450
+ fixedSource: " func a(foo: Bar, @escaping foo1: () -> Void) {} "
3451
+ )
3452
+ }
3453
+
3454
+ func testMissingCommandInParametersWithNewline( ) {
3455
+ assertParse (
3456
+ """
3457
+ func foo(a: Int1️⃣
3458
+ x: Int = 2
3459
+ ) {}
3460
+ """ ,
3461
+ diagnostics: [
3462
+ DiagnosticSpec (
3463
+ locationMarker: " 1️⃣ " ,
3464
+ message: " expected ',' in parameter " ,
3465
+ fixIts: [ " insert ',' " ]
3466
+ )
3467
+ ] ,
3468
+ fixedSource:
3469
+ """
3470
+ func foo(a: Int,
3471
+ x: Int = 2
3472
+ ) {}
3473
+ """
3474
+ )
3475
+ }
3405
3476
}
0 commit comments