Skip to content

tests: add a test for a fix of getting an ArraySlice of an CocoaArray #36587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions test/stdlib/objc-array-slice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %empty-directory(%t)
// RUN: %target-build-swift %s -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s

// REQUIRES: executable_test
// REQUIRES: objc_interop

import Foundation

let array = NSMutableArray()
for _ in 0..<1000 {
array.insert(NSObject(), at: 0)
}

// Check that this does not crash because of an over-release of the array content.
_ = (array as! [NSObject]).prefix(3)
_ = (array as! [NSObject]).prefix(3)

// CHECK: done
print("done")