forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashableIndices.swift
38 lines (29 loc) · 981 Bytes
/
HashableIndices.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
import StdlibUnittest
var HashTests = TestSuite("HashableIndices")
HashTests.test("ClosedRangeIndex") {
let a = 1...10
checkHashable(a.indices, equalityOracle: { $0 == $1 })
}
HashTests.test("FlattenIndex") {
let a = [1...10, 11...20, 21...30].joined()
checkHashable(a.indices, equalityOracle: { $0 == $1 })
}
HashTests.test("LazyDropWhileIndex") {
let a = (1...10).lazy.drop(while: { $0 < 5 })
checkHashable(a.indices, equalityOracle: { $0 == $1 })
}
HashTests.test("LazyPrefixWhileIndex") {
let a = (1...10).lazy.prefix(while: { $0 < 5 })
checkHashable(a.indices, equalityOracle: { $0 == $1 })
}
HashTests.test("ReversedIndex") {
let a = (1...10).lazy.filter({ $0 > 3 }).reversed()
checkHashable(a.indices, equalityOracle: { $0 == $1 })
}
HashTests.test("ReversedRandomAccessIndex") {
let a = (1...10).reversed()
checkHashable(a.indices, equalityOracle: { $0 == $1 })
}
runAllTests()