blob: 5b6ffbc986883893aa7c9b7fc8d39a5fa35ba690 [file]
// DISABLE_NATIVE: gcType=NOOP
import kotlin.test.*
import kotlin.native.ref.*
@OptIn(kotlin.native.runtime.NativeRuntimeApi::class, kotlin.experimental.ExperimentalNativeApi::class)
@Test fun runTest() {
val weakRefToTrashCycle = createLoop()
kotlin.native.runtime.GC.collect()
assertNull(weakRefToTrashCycle.get())
}
@OptIn(kotlin.experimental.ExperimentalNativeApi::class)
private fun createLoop(): WeakReference<Any> {
val loop = Array<Any?>(1, { null })
loop[0] = loop
return WeakReference(loop)
}