Skip to content

Commit 211aae1

Browse files
committed
[test] Array: Add availability guard to crash test
Array.init(unsafeUninitializedCapacity:…) back-deploys to the 5.0 stdlib, but the implementation there doesn’t catch buffer reassignment.
1 parent 3c33145 commit 211aae1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/stdlib/Inputs/CommonArrayTests.gyb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,11 @@ ${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/validCount")
572572
}
573573

574574
${Suite}.test("${ArrayType}/init(unsafeUninitializedCapacity:...:)/reassignBuffer") {
575+
guard #available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *) else {
576+
// When back-deployed to 5.0, this coding error does not get detected.
577+
return
578+
}
579+
575580
expectCrashLater()
576581
let otherBuffer = UnsafeMutableBufferPointer<Int>.allocate(capacity: 1)
577582
let array = ${ArrayType}<Int>(unsafeUninitializedCapacity: 10) { buffer, _ in

0 commit comments

Comments
 (0)