[K/N][Tests] Migrate objcSmoke & objcTests tests

^KT-61259
This commit is contained in:
Vladimir Sukharev
2024-01-24 18:04:17 +01:00
committed by Space Team
parent 58f7dd1c83
commit 524f0d335e
98 changed files with 227 additions and 8 deletions
@@ -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
}