mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Most tests were using %swift or similar substitutions, which did not include the target triple and SDK. The driver was defaulting to the host OS. Thus, we could not run the tests when the standard library was not built for OS X. Swift SVN r24504
39 lines
948 B
Swift
39 lines
948 B
Swift
// RUN: %target-parse-verify-swift
|
|
|
|
func takeIntToInt(f: (Int) -> Int) { }
|
|
func takeIntIntToInt(f: (Int, Int) -> Int) { }
|
|
|
|
// Anonymous arguments with inference
|
|
func myMap<T, U>(array: [T], f: (T) -> U) -> [U] {}
|
|
|
|
func testMap(array: [Int]) {
|
|
var farray = myMap(array, { Float($0) })
|
|
var f : Float = farray[0]
|
|
var farray2 = myMap(array, { x in Float(x) })
|
|
farray = farray2
|
|
}
|
|
|
|
// Infer result type.
|
|
func testResultType() {
|
|
takeIntToInt({x in
|
|
return x + 1
|
|
})
|
|
|
|
takeIntIntToInt({x, y in
|
|
return 2 + 3
|
|
})
|
|
}
|
|
|
|
// Closures with unnamed parameters
|
|
func unnamed() {
|
|
takeIntToInt({_ in return 1})
|
|
takeIntIntToInt({_, _ in return 1})
|
|
}
|
|
|
|
// Regression tests.
|
|
|
|
var nestedClosuresWithBrokenInference = { f: Int in {} }
|
|
// expected-error@-1 {{unable to infer closure type in the current context}}
|
|
// expected-error@-2 {{consecutive statements on a line must be separated by ';'}}
|
|
// expected-error@-3 {{expected expression}}
|