[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,37 @@
|
||||
@file:OptIn(kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.ref.WeakReference
|
||||
import kotlinx.cinterop.*
|
||||
import kotlin.test.*
|
||||
import objcTests.*
|
||||
|
||||
@Test
|
||||
fun testKT42482() {
|
||||
// Attempt to make the state predictable:
|
||||
kotlin.native.runtime.GC.collect()
|
||||
|
||||
kt42482Deallocated = false
|
||||
assertFalse(kt42482Deallocated);
|
||||
|
||||
{
|
||||
assertEquals(41, KT42482().fortyTwo())
|
||||
|
||||
val obj: KT42482 = KT42482Impl()
|
||||
assertEquals(42, obj.fortyTwo())
|
||||
|
||||
kt42482Swizzle(obj)
|
||||
assertEquals(43, obj.fortyTwo())
|
||||
|
||||
// Test retain and release on swizzled object:
|
||||
kt42482Global = obj
|
||||
kt42482Global = null
|
||||
}()
|
||||
|
||||
kotlin.native.runtime.GC.collect()
|
||||
|
||||
assertTrue(kt42482Deallocated)
|
||||
}
|
||||
|
||||
class KT42482Impl : KT42482() {
|
||||
override fun fortyTwo() = 42
|
||||
}
|
||||
Reference in New Issue
Block a user