[sourcekitd-test] Make expand-placeholder iterative

Instead of getting all edits up front using the same source code, apply
each replacement before calculating the next. Placeholder expansion is
sensitive the surrounding code, so expanding multiple closures
separately can give different results from doing so in order. To allow
testing that, add a magic placeholder identifier __skip__ to skip
expansion during testing.

This is also required for handling multiple trailing closures.
This commit is contained in:
Ben Langmuir
2020-03-09 13:47:06 -07:00
committed by John McCall
parent 78b7bce3a0
commit feaaf39206
2 changed files with 93 additions and 36 deletions

View File

@@ -67,24 +67,41 @@ func f1() {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: }
// FIXME: whether we get a trailing closure or not depends on the order we
// expand the placeholders.
func f1() {
bar(<#T##__skip__: () -> ()##() -> ()#>, <#T##d: () -> ()##() -> ()#>)
}
// CHECK: bar(<#T##__skip__: () -> ()##() -> ()#>, {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: })
func f1() {
bar(<#T##d: () -> ()##() -> ()#>, <#T##d: () -> ()##() -> ()#>)
}
// CHECK: bar({
// CHECK-NEXT: <#code#>
// CHECK-NEXT: }, {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: })
// CHECK-NEXT: <#code#>
// CHECK-NEXT: }) {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: }
// FIXME: whether we get a trailing closure or not depends on the order we
// expand the placeholders.
func f1() {
bar(a : <#T##__skip__: () -> ()##() -> ()#>, b : <#T##d: () -> ()##() -> ()#>)
}
// CHECK: bar(a : <#T##__skip__: () -> ()##() -> ()#>, b : {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: })
func f1() {
bar(a : <#T##d: () -> ()##() -> ()#>, b : <#T##d: () -> ()##() -> ()#>)
}
// CHECK: bar(a : {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: }, b : {
// CHECK-NEXT: }) {
// CHECK-NEXT: <#code#>
// CHECK-NEXT: })
// CHECK-NEXT: }
func f1() {