Skip to content

Commit 21fe402

Browse files
committed
[test] Disable some tests on OS X 10.9 that require a newer Foundation
1 parent b517693 commit 21fe402

File tree

3 files changed

+37
-10
lines changed

3 files changed

+37
-10
lines changed

test/Interpreter/SDK/objc_bridge_cast.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,16 @@ func testValueToObjectBridgingInSwitch() {
254254
}
255255
}
256256

257-
#if arch(i386) || arch(arm)
258-
#else
259-
// Small strings should be immortal
260-
autoreleasepool {
261-
let string = "hello"
262-
let nsString = string as NSString
263-
objc_setAssociatedObject(
264-
nsString, &ImmortalCanaryAssocObjectHandle, ImmortalCanary(),
265-
.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
257+
#if !(arch(i386) || arch(arm))
258+
// Small strings should be immortal on new enough 64-bit Apple platforms.
259+
if #available(macOS 10.10, *) {
260+
autoreleasepool {
261+
let string = "hello"
262+
let nsString = string as NSString
263+
objc_setAssociatedObject(
264+
nsString, &ImmortalCanaryAssocObjectHandle, ImmortalCanary(),
265+
.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
266+
}
266267
}
267268
#endif // 64-bit
268269
print("Done")

test/stdlib/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

test/stdlib/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)