Skip to content

Commit fb33810

Browse files
authored
Merge pull request #19702 from jrose-apple/who-remembers-mavericks
[test] Tweak some tests so that they run consistently on OS X 10.9
2 parents e6bc834 + c5050bc commit fb33810

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Darwin/Foundation-swiftoverlay-Tests/CodableTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,19 +442,30 @@ class TestCodable : TestCodableSuper {
442442
lazy var indexSetValues: [Int : IndexSet] = [
443443
#line : IndexSet(),
444444
#line : IndexSet(integer: 42),
445+
]
446+
lazy var indexSetMaxValues: [Int : IndexSet] = [
445447
#line : IndexSet(integersIn: 0 ..< Int.max)
446448
]
447449

448450
func test_IndexSet_JSON() {
449451
for (testLine, indexSet) in indexSetValues {
450452
expectRoundTripEqualityThroughJSON(for: indexSet, lineNumber: testLine)
451453
}
454+
if #available(macOS 10.10, iOS 8, *) {
455+
// Mac OS X 10.9 and iOS 7 weren't able to round-trip Int.max in JSON.
456+
for (testLine, indexSet) in indexSetMaxValues {
457+
expectRoundTripEqualityThroughJSON(for: indexSet, lineNumber: testLine)
458+
}
459+
}
452460
}
453461

454462
func test_IndexSet_Plist() {
455463
for (testLine, indexSet) in indexSetValues {
456464
expectRoundTripEqualityThroughPlist(for: indexSet, lineNumber: testLine)
457465
}
466+
for (testLine, indexSet) in indexSetMaxValues {
467+
expectRoundTripEqualityThroughPlist(for: indexSet, lineNumber: testLine)
468+
}
458469
}
459470

460471
// MARK: - Locale
@@ -506,6 +517,9 @@ class TestCodable : TestCodableSuper {
506517
// MARK: - NSRange
507518
lazy var nsrangeValues: [Int : NSRange] = [
508519
#line : NSRange(),
520+
#line : NSRange(location: 5, length: 20),
521+
]
522+
lazy var nsrangeMaxValues: [Int : NSRange] = [
509523
#line : NSRange(location: 0, length: Int.max),
510524
#line : NSRange(location: NSNotFound, length: 0),
511525
]
@@ -514,12 +528,21 @@ class TestCodable : TestCodableSuper {
514528
for (testLine, range) in nsrangeValues {
515529
expectRoundTripEqualityThroughJSON(for: range, lineNumber: testLine)
516530
}
531+
if #available(macOS 10.10, iOS 8, *) {
532+
// Mac OS X 10.9 and iOS 7 weren't able to round-trip Int.max in JSON.
533+
for (testLine, range) in nsrangeMaxValues {
534+
expectRoundTripEqualityThroughJSON(for: range, lineNumber: testLine)
535+
}
536+
}
517537
}
518538

519539
func test_NSRange_Plist() {
520540
for (testLine, range) in nsrangeValues {
521541
expectRoundTripEqualityThroughPlist(for: range, lineNumber: testLine)
522542
}
543+
for (testLine, range) in nsrangeMaxValues {
544+
expectRoundTripEqualityThroughPlist(for: range, lineNumber: testLine)
545+
}
523546
}
524547

525548
// MARK: - PersonNameComponents

Darwin/Foundation-swiftoverlay-Tests/TestCalendar.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,10 @@ class TestCalendar : TestCalendarSuper {
182182

183183
expectEqual(Date(timeIntervalSince1970: 1468652400.0), c.startOfDay(for: d))
184184

185-
expectEqual(.orderedSame, c.compare(d, to: d + 10, toGranularity: .minute))
185+
if #available(iOS 8, macOS 10.10, *) {
186+
// Mac OS X 10.9 and iOS 7 had a bug in NSCalendar for hour, minute, and second granularities.
187+
expectEqual(.orderedSame, c.compare(d, to: d + 10, toGranularity: .minute))
188+
}
186189

187190
expectFalse(c.isDate(d, equalTo: d + 10, toGranularity: .second))
188191
expectTrue(c.isDate(d, equalTo: d + 10, toGranularity: .day))

0 commit comments

Comments
 (0)