mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Running the SourceKit stress tester with verification of solver-based cursor info returned quite a few differences but in all of them, the old AST-based implementation was actually incorrect. So, instead of verifying the results, deliver the results from solver-baesd cursor info and only fall back to AST-based cursor info if the solver-based implementation returned no results. rdar://103369449
47 lines
1.6 KiB
Swift
47 lines
1.6 KiB
Swift
func sink(_ a: (Int) -> Void) {}
|
|
|
|
func testSingleStatementClosure() {
|
|
sink { items in
|
|
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):9 %s -- %s | %FileCheck %s --check-prefix=SINGLE-STMT-CLOSURE
|
|
var items = items
|
|
}
|
|
// SINGLE-STMT-CLOSURE: s:13discriminator26testSingleStatementClosureyyFySiXEfU_5itemsL0_Sivp
|
|
}
|
|
|
|
|
|
func testMultiStatementClosure() {
|
|
sink { items in
|
|
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):9 %s -- %s | %FileCheck %s --check-prefix=MULTI-STMT-CLOSURE
|
|
var items = items
|
|
print("xxx")
|
|
}
|
|
// MULTI-STMT-CLOSURE: s:13discriminator25testMultiStatementClosureyyFySiXEfU_5itemsL0_Sivp
|
|
}
|
|
|
|
func testNestedClosures() {
|
|
func dataTask(completionHandler: (Int?) -> Void) {}
|
|
func async2(execute work: () -> Void) {}
|
|
|
|
dataTask { (error) in
|
|
do {
|
|
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 1):17 %s -- %s | %FileCheck %s --check-prefix=NESTED_CLOSURE
|
|
} catch let error {
|
|
async2 {
|
|
print("")
|
|
}
|
|
}
|
|
}
|
|
// NESTED_CLOSURE: s:13discriminator18testNestedClosuresyyFySiSgXEfU_5errorL1_s5Error_pvp
|
|
}
|
|
|
|
func testReuseAST(bytes: Int) {
|
|
// RUN: %sourcekitd-test -req=cursor -pos=%(line + 2):7 %s -- %s == \
|
|
// RUN: -req=cursor -pos=%(line + 2):7 %s -- %s | %FileCheck %s --check-prefix=REUSE_AST
|
|
let size = 3
|
|
var bytes = 6
|
|
// REUSE_AST: source.lang.swift.decl.var.local (40:7-40:11)
|
|
// REUSE_AST: s:13discriminator12testReuseAST5bytesySi_tF4sizeL_Sivp
|
|
// REUSE_AST: source.lang.swift.decl.var.local (41:7-41:12)
|
|
// REUSE_AST: s:13discriminator12testReuseAST5bytesySi_tFACL0_Sivp
|
|
}
|