[K/N][Tests] Migrate test illegal_sharing_with_weak.kt
^KT-61259
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
@file:OptIn(ObsoleteWorkersApi::class)
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlinx.cinterop.autoreleasepool
|
||||
import objclib.*
|
||||
|
||||
fun main() {
|
||||
autoreleasepool {
|
||||
run()
|
||||
}
|
||||
}
|
||||
|
||||
private class NSObjectImpl : NSObject() {
|
||||
var x = 111
|
||||
}
|
||||
|
||||
fun run() = withWorker {
|
||||
val obj = NSObjectImpl()
|
||||
setObject(obj)
|
||||
|
||||
println("Before")
|
||||
val isAlive = try {
|
||||
execute(TransferMode.SAFE, {}) {
|
||||
isObjectAliveShouldCrash()
|
||||
}.result
|
||||
} catch (e: Throwable) {
|
||||
false
|
||||
}
|
||||
println("After $isAlive")
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
language = Objective-C
|
||||
headerFilter = **/objclib.h
|
||||
@@ -1,13 +0,0 @@
|
||||
#import <objc/NSObject.h>
|
||||
|
||||
static NSObject* __weak globalObject = nil;
|
||||
|
||||
void setObject(NSObject* obj) {
|
||||
globalObject = obj;
|
||||
}
|
||||
|
||||
// Make sure this function persists, because the test expects to find this function in the stack trace.
|
||||
__attribute__((noinline))
|
||||
bool isObjectAliveShouldCrash() {
|
||||
return globalObject != nil;
|
||||
}
|
||||
Reference in New Issue
Block a user