[K/N][Tests] Migrate objcSmoke & objcTests tests
^KT-61259
This commit is contained in:
committed by
Space Team
parent
58f7dd1c83
commit
524f0d335e
@@ -0,0 +1,34 @@
|
||||
@file:OptIn(kotlin.experimental.ExperimentalNativeApi::class, FreezingIsDeprecated::class, ObsoleteWorkersApi::class)
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.test.*
|
||||
import objcTests.*
|
||||
|
||||
private class NSObjectImpl : NSObject() {
|
||||
var x = 111
|
||||
}
|
||||
|
||||
// Also see counterpart interop/objc/illegal_sharing.kt
|
||||
@Test fun testSharing() = withWorker {
|
||||
val obj = NSObjectImpl()
|
||||
val array = nsArrayOf(obj)
|
||||
|
||||
assertFalse(obj.isFrozen)
|
||||
|
||||
obj.x = 222
|
||||
|
||||
if (Platform.isFreezingEnabled) {
|
||||
obj.freeze()
|
||||
assertTrue(obj.isFrozen)
|
||||
runInWorker {
|
||||
val obj1 = array.objectAtIndex(0) as NSObjectImpl
|
||||
assertFailsWith<InvalidMutabilityException> {
|
||||
obj1.x = 333
|
||||
}
|
||||
}
|
||||
assertEquals(222, obj.x)
|
||||
}
|
||||
|
||||
// TODO: test [obj release] etc.
|
||||
}
|
||||
Reference in New Issue
Block a user