Skip to content

Commit 7c5e290

Browse files
committed
[test] SwiftFixIt: Add XFAILed test for duplicate insertion fix-its
1 parent c37bf5e commit 7c5e290

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

Tests/SwiftFixItTests/FilteringTests.swift

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,4 +411,126 @@ struct FilteringTests {
411411
)
412412
}
413413
}
414+
415+
@Test
416+
func testDuplicateInsertionFixIts() throws {
417+
withKnownIssue("FIXME: Filter out duplicate insertion fix-its") {
418+
try self._testDuplicateInsertionFixIts()
419+
}
420+
}
421+
422+
func _testDuplicateInsertionFixIts() throws {
423+
try testAPI1File { path in
424+
.init(
425+
edits: .init(input: "var x = 1", result: "@W var yx = 21"),
426+
summary: .init(
427+
// 4 because skipped by SwiftIDEUtils.FixItApplier, not SwiftFixIt.
428+
numberOfFixItsApplied: 6,
429+
numberOfFilesChanged: 1
430+
),
431+
diagnostics: [
432+
// Duplicate fix-it pairs:
433+
// - on primary + on primary.
434+
// - on note + on note.
435+
// - on primary + on note.
436+
PrimaryDiagnostic(
437+
level: .error,
438+
text: "error1_fixit1",
439+
location: .init(path: path, line: 1, column: 1),
440+
fixIts: [
441+
// Applied.
442+
.init(
443+
start: .init(path: path, line: 1, column: 1),
444+
end: .init(path: path, line: 1, column: 1),
445+
text: "@W "
446+
),
447+
]
448+
),
449+
PrimaryDiagnostic(
450+
level: .error,
451+
text: "error2_fixit2",
452+
location: .init(path: path, line: 1, column: 2),
453+
notes: [
454+
Note(
455+
text: "error2_note1",
456+
location: .init(path: path, line: 1, column: 9),
457+
fixIts: [
458+
// Applied.
459+
.init(
460+
start: .init(path: path, line: 1, column: 9),
461+
end: .init(path: path, line: 1, column: 9),
462+
text: "2"
463+
),
464+
]
465+
),
466+
]
467+
),
468+
PrimaryDiagnostic(
469+
level: .error,
470+
text: "error3_fixit1",
471+
location: .init(path: path, line: 1, column: 3),
472+
fixIts: [
473+
// FIXME: Should be skipped.
474+
.init(
475+
start: .init(path: path, line: 1, column: 1),
476+
end: .init(path: path, line: 1, column: 1),
477+
text: "@W "
478+
),
479+
]
480+
),
481+
PrimaryDiagnostic(
482+
level: .error,
483+
text: "error4_fixit3",
484+
location: .init(path: path, line: 1, column: 4),
485+
fixIts: [
486+
// Applied.
487+
.init(
488+
start: .init(path: path, line: 1, column: 5),
489+
end: .init(path: path, line: 1, column: 5),
490+
text: "y"
491+
),
492+
]
493+
),
494+
PrimaryDiagnostic(
495+
level: .error,
496+
text: "error5_fixit2",
497+
location: .init(path: path, line: 1, column: 5),
498+
notes: [
499+
Note(
500+
text: "error5_note1",
501+
location: .init(path: path, line: 1, column: 9),
502+
fixIts: [
503+
// FIXME: Should be skipped.
504+
.init(
505+
start: .init(path: path, line: 1, column: 9),
506+
end: .init(path: path, line: 1, column: 9),
507+
text: "2"
508+
),
509+
]
510+
),
511+
]
512+
),
513+
PrimaryDiagnostic(
514+
level: .error,
515+
text: "error6_fixit3",
516+
location: .init(path: path, line: 1, column: 6),
517+
notes: [
518+
Note(
519+
text: "error6_note1",
520+
location: .init(path: path, line: 1, column: 5),
521+
fixIts: [
522+
// FIXME: Should be skipped.
523+
.init(
524+
start: .init(path: path, line: 1, column: 5),
525+
end: .init(path: path, line: 1, column: 5),
526+
text: "y"
527+
),
528+
]
529+
),
530+
]
531+
),
532+
]
533+
)
534+
}
535+
}
414536
}

0 commit comments

Comments
 (0)