9ff0e0b046
* `nativeTest` task now allows to provide compiler plugins that may be enabled during test compilation * test sets for JVM and K/N backends are equal KT-60800 describes all the issues with native tests that were solved in this commit. Co-authored-by: Dmitriy Dolovov <Dmitriy.Dolovov@jetbrains.com> Merge-request: KT-MR-11401 Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
39 lines
969 B
Kotlin
Vendored
39 lines
969 B
Kotlin
Vendored
import kotlinx.atomicfu.*
|
|
import kotlinx.atomicfu.locks.*
|
|
import kotlin.test.*
|
|
|
|
class LateinitPropertiesTest {
|
|
private val a: AtomicInt
|
|
private val head: AtomicRef<String>
|
|
private val dataRef: AtomicRef<Data>
|
|
private val lateIntArr: AtomicIntArray
|
|
private val lateRefArr: AtomicArray<String?>
|
|
|
|
private class Data(val n: Int)
|
|
|
|
init {
|
|
a = atomic(0)
|
|
head = atomic("AAA")
|
|
lateIntArr = AtomicIntArray(55)
|
|
val data = Data(77)
|
|
dataRef = atomic(data)
|
|
val size = 10
|
|
lateRefArr = atomicArrayOfNulls<String?>(size)
|
|
}
|
|
|
|
fun test() {
|
|
assertEquals(0, a.value)
|
|
assertTrue(head.compareAndSet("AAA", "BBB"))
|
|
assertEquals("BBB", head.value)
|
|
assertEquals(0, lateIntArr[35].value)
|
|
assertEquals(77, dataRef.value.n)
|
|
assertEquals(null, lateRefArr[5].value)
|
|
}
|
|
}
|
|
|
|
@Test
|
|
fun box() {
|
|
val testClass = LateinitPropertiesTest()
|
|
testClass.test()
|
|
}
|