Skip to content

Commit f0641db

Browse files
committed
tests: add a test for a fix of getting an ArraySlice of an CocoaArray
The problem was fixed in 375f289. rdar://74807247
1 parent e9aff35 commit f0641db

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/stdlib/objc-array-slice.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift %s -o %t/a.out
3+
// RUN: %target-codesign %t/a.out
4+
// RUN: %target-run %t/a.out | %FileCheck %s
5+
6+
// REQUIRES: executable_test
7+
// REQUIRES: objc_interop
8+
9+
import Foundation
10+
11+
let array = NSMutableArray()
12+
for _ in 0..<1000 {
13+
array.insert(NSObject(), at: 0)
14+
}
15+
16+
// Check that this does not crash because of an over-release of the array content.
17+
_ = (array as! [NSObject]).prefix(3)
18+
_ = (array as! [NSObject]).prefix(3)
19+
20+
// CHECK: done
21+
print("done")
22+

0 commit comments

Comments
 (0)