Files
swift-mirror/test/1_stdlib/NSEnumeratorAPI.swift
Doug Gregor 6a1b7348e0 Make trailing closure syntax match the last parameter, always.
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
2015-02-02 19:47:31 +00:00

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()