mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
The code goes into its own sub-tree under 'tools' but tests go under 'test', so that running 'check-swift' will also run all the SourceKit tests. SourceKit is disabled on non-darwin platforms.
79 lines
2.8 KiB
Swift
79 lines
2.8 KiB
Swift
|
|
protocol FooProtocol {
|
|
/// fooInstanceVar Aaa.
|
|
/// Bbb.
|
|
///
|
|
/// Ccc.
|
|
var fooInstanceVar: Int { get }
|
|
typealias FooTypeAlias1
|
|
func fooInstanceFunc0() -> Double
|
|
func fooInstanceFunc1(a: Int) -> Double
|
|
subscript(i: Int) -> Double { get }
|
|
}
|
|
|
|
func test1(a: FooProtocol) {
|
|
a.
|
|
}
|
|
|
|
func testOptional1(a: FooProtocol?) {
|
|
a.
|
|
}
|
|
|
|
class C {
|
|
@available(*, unavailable) func unavail() {}
|
|
}
|
|
|
|
func test_unavail(a: C) {
|
|
a.
|
|
}
|
|
|
|
class Base {
|
|
func foo() {}
|
|
}
|
|
|
|
class Derived: Base {
|
|
func foo() {}
|
|
}
|
|
|
|
func testOverrideUSR() {
|
|
Derived().
|
|
}
|
|
|
|
// RUN: %sourcekitd-test -req=complete -pos=15:5 %s -- %s > %t.response
|
|
// RUN: diff -u %s.response %t.response
|
|
//
|
|
// RUN: %sourcekitd-test -req=complete -pos=19:5 %s -- %s | FileCheck %s -check-prefix=CHECK-OPTIONAL
|
|
// RUN: %sourcekitd-test -req=complete.open -pos=19:5 %s -- %s | FileCheck %s -check-prefix=CHECK-OPTIONAL-OPEN
|
|
// CHECK-OPTIONAL: {
|
|
// CHECK-OPTIONAL: key.kind: source.lang.swift.decl.function.method.instance,
|
|
// CHECK-OPTIONAL: key.name: "fooInstanceFunc0()",
|
|
// CHECK-OPTIONAL-LABEL: key.sourcetext: "?.fooInstanceFunc1(<#T##a: Int##Int#>)",
|
|
// CHECK-OPTIONAL-NEXT: key.description: "fooInstanceFunc1(a: Int)",
|
|
// CHECK-OPTIONAL-NEXT: key.typename: "Double",
|
|
// CHECK-OPTIONAL-NEXT: key.context: source.codecompletion.context.thisclass,
|
|
// CHECK-OPTIONAL-NEXT: key.num_bytes_to_erase: 1,
|
|
// CHECK-OPTIONAL-NEXT: key.associated_usrs: "s:FP15complete_member11FooProtocol16fooInstanceFunc1FSiSd",
|
|
// CHECK-OPTIONAL-NEXT: key.modulename: "complete_member"
|
|
// CHECK-OPTIONAL-NEXT: },
|
|
|
|
// RUN: %sourcekitd-test -req=complete.open -pos=19:5 %s -- %s | FileCheck %s -check-prefix=CHECK-OPTIONAL-OPEN
|
|
// CHECK-OPTIONAL-OPEN-NOT: key.description: "fooInstanceFunc1
|
|
// CHECK-OPTIONAL-OPEN: key.description: "?.fooInstanceFunc1(a: Int)",
|
|
// CHECK-OPTIONAL-OPEN-NOT: key.description: "fooInstanceFunc1
|
|
|
|
// RUN: %sourcekitd-test -req=complete -pos=27:5 %s -- %s | FileCheck %s -check-prefix=CHECK-UNAVAIL
|
|
// CHECK-UNAVAIL-NOT: key.name: "unavail()",
|
|
|
|
// RUN: %sourcekitd-test -req=complete -pos=39:15 %s -- %s | FileCheck %s -check-prefix=CHECK-OVERRIDE_USR
|
|
// CHECK-OVERRIDE_USR: {
|
|
// CHECK-OVERRIDE_USR: key.kind: source.lang.swift.decl.function.method.instance,
|
|
// CHECK-OVERRIDE_USR-NEXT: key.name: "foo()",
|
|
// CHECK-OVERRIDE_USR-NEXT: key.sourcetext: "foo()",
|
|
// CHECK-OVERRIDE_USR-NEXT: key.description: "foo()",
|
|
// CHECK-OVERRIDE_USR-NEXT: key.typename: "Void",
|
|
// CHECK-OVERRIDE_USR-NEXT: key.context: source.codecompletion.context.thisclass,
|
|
// CHECK-OVERRIDE_USR-NEXT: key.num_bytes_to_erase: 0,
|
|
// CHECK-OVERRIDE_USR-NEXT: key.associated_usrs: "s:FC15complete_member7Derived3fooFT_T_ s:FC15complete_member4Base3fooFT_T_",
|
|
// CHECK-OVERRIDE_USR-NEXT: key.modulename: "complete_member"
|
|
// CHECK-OVERRIDE_USR-NEXT: }
|