Skip to content

Commit 147087c

Browse files
committed
[test] Adjust new Substring test
We don’t have an easy way to check for the runtime version of the stdlib, so a two-way check for behavioral changes isn’t feasible. (Checking for the OS version isn’t good enough.) Only check for the new behavior, and only when we know for sure that it’s available.
1 parent 462978f commit 147087c

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

test/stdlib/subString.swift

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,21 @@ SubstringTests.test("UTF8View") {
252252
expectEqual("", String(u.dropFirst(100))!)
253253
expectEqual("", String(u.dropLast(100))!)
254254

255-
let expectSubstringWCSIA: Bool
256-
// This availability guard should refer to a concrete OS version in
257-
// future.
258-
if #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) {
259-
expectSubstringWCSIA = true
260-
} else {
261-
expectSubstringWCSIA = false
262-
}
263-
264255
checkHasContiguousStorage(s.utf8, expected: true) // Strings always do
265-
checkHasContiguousStorage(t, expected: expectSubstringWCSIA)
266-
checkHasContiguousStorage(u, expected: expectSubstringWCSIA)
267256
checkHasContiguousStorageSubstring(t)
268257
checkHasContiguousStorageSubstring(u)
269258
checkMatchContiguousStorage(Array(s.utf8), s.utf8, expected: true)
270-
checkMatchContiguousStorage(Array(t), t, expected: expectSubstringWCSIA)
271-
checkMatchContiguousStorage(Array(u), u, expected: expectSubstringWCSIA)
259+
260+
// The specialization for Substring.withContiguousStorageIfAvailable was
261+
// added in https://github.com/apple/swift/pull/29146.
262+
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else {
263+
return
264+
}
265+
266+
checkHasContiguousStorage(t, expected: true)
267+
checkHasContiguousStorage(u, expected: true)
268+
checkMatchContiguousStorage(Array(t), t, expected: true)
269+
checkMatchContiguousStorage(Array(u), u, expected: true)
272270
}
273271
}
274272

0 commit comments

Comments
 (0)