Skip to content

Commit acfc744

Browse files
committed
Added test for undercounted collection not crashing
1 parent 3677d8e commit acfc744

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

validation-test/stdlib/Arrays.swift.gyb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ ArrayTestSuite.test("${array_type}/appendNonUnique") {
233233
}
234234
}
235235

236+
ArrayTestSuite.test("${array_type}/appendUndercountedCollection") {
237+
// test that the array safely handles a
238+
// collection that understates its count
239+
var i = 0
240+
let l = repeatElement(42, count: 10_000).lazy.filter { _ in i += 1; return i > 10_000 }
241+
var a: ${array_type}<Int> = []
242+
a.append(contentsOf: l)
243+
}
244+
236245
ArrayTestSuite.test("${array_type}/emptyAllocation") {
237246
let arr0 = ${array_type}<Int>()
238247
let arr1 = ${array_type}<LifetimeTracked>(repeating: LifetimeTracked(0), count: 0)

0 commit comments

Comments
 (0)