Files
swift-mirror/test/Interpreter/testability.swift
Chris Lattner 92750511df Convert the last uses of __FILE__ etc in the testsuite over to the new
syntax.  I left the tests for the deprecation warnings in
test/expr/expressions.swift.
2016-02-04 15:41:09 -08:00

30 lines
1.1 KiB
Swift

// RUN: rm -rf %t && mkdir %t
// RUN: %target-build-swift -emit-library -c %S/Inputs/testability_helper.swift -enable-testing -force-single-frontend-invocation -o %t/testability_helper.o -emit-module
// RUN: %target-build-swift %s -I %t -Xlinker %t/testability_helper.o -o %t/main
// RUN: %target-run %t/main | FileCheck %s
// REQUIRES: executable_test
@testable import testability_helper
func log(value: Any, line: Int = #line) {
print("\(line): \(value)")
}
log(Base(1)) // CHECK: {{^}}[[@LINE]]: instance 1{{$}}
log(Base(2).description) // CHECK: {{^}}[[@LINE]]: instance 2{{$}}
log((Base(3) as CustomStringConvertible).description) // CHECK: {{^}}[[@LINE]]: instance 3{{$}}
class Sub : Base {
override var description: String {
return "sub " + super.description
}
}
log(Sub(1)) // CHECK: {{^}}[[@LINE]]: sub instance 1{{$}}
log(Sub(2) as Any as? Base) // CHECK: {{^}}[[@LINE]]: Optional(sub instance 2){{$}}
log(Base(1).callPrivate()) // CHECK: {{^}}[[@LINE]]: private 1{{$}}
log(Sub(2).callPrivate()) // CHECK: {{^}}[[@LINE]]: private 2{{$}}
log(getPrivateInstance().callPrivate()) // CHECK: {{^}}[[@LINE]]: really private{{$}}