Skip to content

Commit 687b4c8

Browse files
authored
Merge pull request #36587 from eeckstein/main
tests: add a test for a fix of getting an ArraySlice of an CocoaArray
2 parents 3fe2534 + f0641db commit 687b4c8

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)