Files
swift-mirror/test/SourceKit/Indexing/index.swift
Ben Langmuir 368e25ec05 [sourcekit] Fix tests that depend on accepting frontend arguments
These tests were relying on sourcekitd parsing as frontend instead of
using the driver.  Update them now to avoid churn when we fix command
line argument parsing in sourcekit.

The changes from clang-importer-sdk to clang-importer-sdk-nosource -I %t
are because clang-importer-sdk implies using -enable-source-import.
Rather than hack them up to use -Xfrontend, it is cleaner to just stop
using source import at all for these tests.  Incidentally, this improved
fidelity in a few places.  When using the generated swift modules we
also need to pass a target triple to sourcekit, which exposed some tests
that had mac-specific data.  This is a systemic issue for sourcekit
tests, but for now just make those few specific tests that we had
problems with run only on mac.
2018-02-05 10:09:03 -08:00

198 lines
2.7 KiB
Swift

// FIXME(integers): %t.response content is non-deterministic with the new
// integer protocols
// XFAIL: *
// RUN: %sourcekitd-test -req=index %s -- -Xfrontend -serialize-diagnostics-path -Xfrontend %t.dia %s | %sed_clean > %t.response
// RUN: diff -u %s.response %t.response
var globV: Int
class CC {
init() {}
var instV: CC
func meth() {}
func instanceFunc0(_ a: Int, b: Float) -> Int {
return 0
}
func instanceFunc1(a x: Int, b y: Float) -> Int {
return 0
}
class func smeth() {}
}
func +(a : CC, b: CC) -> CC {
return a
}
struct S {
func meth() {}
static func smeth() {}
}
enum E {
case EElem
}
protocol Prot {
func protMeth(_ a: Prot)
}
func foo(_ a: CC, b: inout E) {
globV = 0
a + a.instV
a.meth()
CC.smeth()
b = E.EElem
var local: CC
class LocalCC {}
var local2: LocalCC
}
typealias CCAlias = CC
extension CC : Prot {
func meth2(_ x: CCAlias) {}
func protMeth(_ a: Prot) {}
var extV : Int { return 0 }
}
class SubCC : CC, Prot {}
var globV2: SubCC
class ComputedProperty {
var value : Int {
get {
var result = 0
return result
}
set(newVal) {
// completely ignore it!
}
}
var readOnly : Int { return 0 }
}
class BC2 {
func protMeth(_ a: Prot) {}
}
class SubC2 : BC2, Prot {
override func protMeth(_ a: Prot) {}
}
class CC2 {
subscript (i : Int) -> Int {
get {
return i
}
set(v) {
v+1
}
}
}
func test1(_ cp: ComputedProperty, sub: CC2) {
var x = cp.value
x = cp.readOnly
cp.value = x
++cp.value
x = sub[0]
sub[0] = x
++sub[0]
}
struct S2 {
func sfoo() {}
}
var globReadOnly : S2 {
get {
return S2();
}
}
func test2() {
globReadOnly.sfoo()
}
class B1 {
func foo() {}
}
class SB1 : B1 {
override func foo() {
foo()
self.foo()
super.foo()
}
}
func test3(_ c: SB1, s: S2) {
test2()
c.foo()
s.sfoo()
}
extension Undeclared {
func meth() {}
}
class CC4 {
convenience init(x: Int) {
self.init(x:0)
}
}
class SubCC4 : CC4 {
init(x: Int) {
super.init(x:0)
}
}
class Observing {
init() {}
var globObserving : Int {
willSet {
test2()
}
didSet {
test2()
}
}
}
// <rdar://problem/18640140> :: Crash in swift::Mangle::Mangler::mangleIdentifier()
class rdar18640140 {
// didSet is not compatible with set/get
var S1: Int {
get {
return 1
}
set {
}
didSet {
}
}
}
protocol rdar18640140Protocol {
var S1: Int {
get
set
get
}
}
@available(*, unavailable)
class AlwaysUnavailableClass {
}
@available(iOS 99.99, *)
class ConditionalUnavailableClass1{
}
@available(OSX 99.99, *)
class ConditionalUnavailableClass2{
}