Files
kotlin-fork/plugins/atomicfu/atomicfu-compiler/testData/box/PropertyDeclarationTest.kt
T
mvicsokolova 93561a1a55 kotlinx.atomicfu compiler plugin for JS_IR backend (#4581)
* kotlinx.atomicfu compiler plugin for JS_IR

Support transformations of atomic operations introduced by the kotlinx.atomicfu library for the JS_IR backend. Compiler plugin is applied externally by the kotlinx.atomicfu gradle plugin.

* Apply compiler plugin for JS platform only

* New plugin test structure

* testGroupOutputDirPrefix changed
2021-12-01 22:33:13 +03:00

34 lines
881 B
Kotlin
Vendored

import kotlinx.atomicfu.*
import kotlinx.atomicfu.locks.*
import kotlin.test.*
class PropertyDeclarationTest {
private val a: AtomicInt
private val head: AtomicRef<String>
private val lateIntArr: AtomicIntArray
private val lateRefArr: AtomicArray<String?>
private val lock: ReentrantLock
init {
a = atomic(0)
head = atomic("AAA")
lateIntArr = AtomicIntArray(55)
lateRefArr = atomicArrayOfNulls<String?>(10)
lock = reentrantLock()
}
fun test() {
assertEquals(0, a.value)
check(head.compareAndSet("AAA", "BBB"))
assertEquals("BBB", head.value)
assertEquals(0, lateIntArr[35].value)
assertEquals(null, lateRefArr[5].value)
assertEquals(null, lock)
}
}
fun box(): String {
val testClass = PropertyDeclarationTest()
testClass.test()
return "OK"
}