Skip to content

Commit 4b2f032

Browse files
committed
[test] Disable tests for newly introduced Range behavior on earlier OSes
1 parent 8da6fbf commit 4b2f032

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

test/stdlib/RangeTraps.swift

+9-6
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,26 @@ RangeTraps.test("throughNaN")
116116
_ = ...Double.nan
117117
}
118118

119-
RangeTraps.test("UncheckedHalfOpen")
119+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
120+
// Debug check was introduced in https://github.com/apple/swift/pull/34961
121+
RangeTraps.test("UncheckedHalfOpen")
120122
.xfail(.custom(
121-
{ !_isDebugAssertConfiguration() },
122-
reason: "assertions are disabled in Release and Unchecked mode"))
123+
{ !_isDebugAssertConfiguration() },
124+
reason: "assertions are disabled in Release and Unchecked mode"))
123125
.code {
124126
expectCrashLater()
125127
var range = Range(uncheckedBounds: (lower: 1, upper: 0))
126128
}
127129

128-
RangeTraps.test("UncheckedClosed")
130+
RangeTraps.test("UncheckedClosed")
129131
.xfail(.custom(
130-
{ !_isDebugAssertConfiguration() },
131-
reason: "assertions are disabled in Release and Unchecked mode"))
132+
{ !_isDebugAssertConfiguration() },
133+
reason: "assertions are disabled in Release and Unchecked mode"))
132134
.code {
133135
expectCrashLater()
134136
var range = ClosedRange(uncheckedBounds: (lower: 1, upper: 0))
135137
}
138+
}
136139

137140
runAllTests()
138141

validation-test/stdlib/Range.swift.gyb

+12-9
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,23 @@ ${TestSuite}.test("init(uncheckedBounds:)")
344344
expectEqual(upperInt, r.upperBound.value)
345345
}
346346

347-
${TestSuite}.test("init(uncheckedBounds:) with invalid values")
347+
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
348+
// Debug check was introduced in https://github.com/apple/swift/pull/34961
349+
${TestSuite}.test("init(uncheckedBounds:) with invalid values")
348350
.xfail(
349351
.custom(
350352
{ _isDebugAssertConfiguration() },
351353
reason: "unchecked initializer still checks its input in Debug mode"))
352354
.code {
353-
let low = 2
354-
let up = 1
355-
// Check that 'init(uncheckedBounds:)' does not perform precondition checks,
356-
// allowing to create ranges that break invariants.
357-
let r = ${Self}(
358-
uncheckedBounds: (lower: ${Bound}(low), upper: ${Bound}(up)))
359-
expectEqual(low, r.lowerBound.value)
360-
expectEqual(up, r.upperBound.value)
355+
let low = 2
356+
let up = 1
357+
// Check that 'init(uncheckedBounds:)' does not perform precondition checks,
358+
// allowing to create ranges that break invariants.
359+
let r = ${Self}(
360+
uncheckedBounds: (lower: ${Bound}(low), upper: ${Bound}(up)))
361+
expectEqual(low, r.lowerBound.value)
362+
expectEqual(up, r.upperBound.value)
363+
}
361364
}
362365

363366
% for (DestinationSelf, _, _, _) in all_range_types:

0 commit comments

Comments
 (0)