mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Previously, trailing closures would try to match the first parameter of (possibly optional) function type that didn't seem to have an argument already, but in practice this broke when there were parameters with default arguments before the function parameter. The new rule is far simpler: a trailing closure matches the last parameter. Fixes rdar://problem/17965209. Swift SVN r24898
29 lines
626 B
Swift
29 lines
626 B
Swift
// RUN: %target-run-simple-swift
|
|
|
|
// REQUIRES: objc_interop
|
|
|
|
import StdlibUnittest
|
|
import Foundation
|
|
|
|
var NSEnumeratorAPI = TestSuite("NSEnumeratorAPI")
|
|
|
|
NSEnumeratorAPI.test("SequenceType") {
|
|
let result = NSDictionary().keyEnumerator()
|
|
isSequenceType(result)
|
|
}
|
|
|
|
NSEnumeratorAPI.test("keyEnumerator") {
|
|
let result = [1: "one", 2: "two"]
|
|
expectEqualsUnordered(
|
|
[1, 2], NSDictionary(dictionary: result).keyEnumerator(),
|
|
{
|
|
switch ($0 as! Int, $1 as! Int) {
|
|
case let (x, y) where x == y: return .EQ
|
|
case let (x, y) where x < y: return .LT
|
|
case _: return .GT
|
|
}
|
|
})
|
|
}
|
|
|
|
runAllTests()
|