Skip to content

Commit b71e263

Browse files
committed
Update dictionary tests
1 parent 822fec7 commit b71e263

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

validation-test/stdlib/Dictionary.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,10 +1180,12 @@ DictionaryTestSuite.test("COW.Fast.ValuesAccessDoesNotReallocate") {
11801180
assert(d1.values[i] == 1010)
11811181
assert(d1[i] == (10, 1010))
11821182

1183+
#if swift(>=4.0)
11831184
d2.values[i] += 1
11841185
assert(d2.values[i] == 1011)
11851186
assert(d2[10]! == 1011)
11861187
assert(identity1 != d2._rawIdentifier())
1188+
#endif
11871189

11881190
assert(d1[10]! == 1010)
11891191
assert(identity1 == d1._rawIdentifier())
@@ -1242,8 +1244,10 @@ DictionaryTestSuite.test("COW.Fast.KeysAccessDoesNotReallocate") {
12421244
// keys.index(of:) - O(1) bucket + linear search
12431245
MinimalHashableValue.timesEqualEqualWasCalled = 0
12441246
let l = d2.keys.index(of: lastKey)!
1247+
#if swift(>=4.0)
12451248
expectLE(MinimalHashableValue.timesEqualEqualWasCalled, 4)
1246-
1249+
#endif
1250+
12471251
expectEqual(j, k)
12481252
expectEqual(k, l)
12491253
}

validation-test/stdlib/HashedCollectionFilter3.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-run-stdlib-swift
1+
// RUN: %target-run-stdlib-swift -swift-version 3
22
// REQUIRES: executable_test
33

44
import StdlibUnittest
@@ -21,14 +21,16 @@ FilterTestSuite.test("Dictionary.keys -> LazyMapCollection") {
2121
let d = [10: 1010, 20: 1020, 30: 1030, 40: 1040]
2222
// .keys should produce a LazyMapCollection in Swift 3
2323
let f: Any = d.keys
24-
expectEqual(4, f.count)
24+
let g = f as! LazyMapCollection<[Int: Int], Int>
25+
expectEqual(4, g.count)
2526
}
2627

2728
FilterTestSuite.test("Dictionary.values -> LazyMapCollection") {
2829
let d = [10: 1010, 20: 1020, 30: 1030, 40: 1040]
2930
// .values should produce a LazyMapCollection in Swift 3
3031
let f: Any = d.values
31-
expectEqual(4, f.count)
32+
let g = f as! LazyMapCollection<[Int: Int], Int>
33+
expectEqual(4, g.count)
3234
}
3335

3436
runAllTests()

validation-test/stdlib/HashedCollectionFilter4.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ FilterTestSuite.test("Dictionary.filter(_:) -> [Key: Value]")
1010
{
1111
let d = [10: 1010, 20: 1020, 30: 1030, 40: 1040]
1212
// filter(_:) should produce a dictionary in Swift 4
13-
let f: Any = d.filter { (k, v) in k > 20 }
13+
let f: Any = d.filter { $0.key > 20 }
1414
expectTrue(f is [Int: Int])
1515
}
1616

1717
FilterTestSuite.test("Dictionary.filter(_:) -> [(Key, Value)] available") {
1818
let d = [10: 1010, 20: 1020, 30: 1030, 40: 1040]
1919
// The Array-returning version from Sequence should still be accessible
20-
let f: [(Int, Int)] = d.filter { (k, v) in k > 20 }
20+
let f: [(Int, Int)] = d.filter { $0.key > 20 }
2121
expectEqual(2, f.count)
2222
}
2323

@@ -37,14 +37,18 @@ FilterTestSuite.test("Set.filter(_:) -> [Element] available") {
3737
expectEqual(2, f.count)
3838
}
3939

40-
FilterTestSuite.test("Dictionary.keys -> Keys") {
40+
FilterTestSuite.test("Dictionary.keys -> Keys")
41+
.xfail(.always("Not actually running under Swift 4")).code
42+
{
4143
let d = [10: 1010, 20: 1020, 30: 1030, 40: 1040]
4244
// .keys should produce a Dictionary.Keys in Swift 4
4345
let f: Any = d.keys
4446
expectTrue(f is Dictionary<Int, Int>.Keys)
4547
}
4648

47-
FilterTestSuite.test("Dictionary.values -> Values") {
49+
FilterTestSuite.test("Dictionary.values -> Values")
50+
.xfail(.always("Not actually running under Swift 4")).code
51+
{
4852
let d = [10: 1010, 20: 1020, 30: 1030, 40: 1040]
4953
// .values should produce a Dictionary.Values in Swift 4
5054
let f: Any = d.values

0 commit comments

Comments
 (0)