Files
kotlin-fork/plugins/atomicfu/atomicfu-compiler/testData/box/ReentrantLockTest.kt
T
mvicsokolova 8053746ae0 kotlinx.atomicfu JVM/IR compiler plugin support
Merge-request: KT-MR-6541
Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
2022-06-26 07:17:06 +00:00

34 lines
668 B
Kotlin
Vendored

import kotlinx.atomicfu.locks.*
import kotlin.test.*
//class ReentrantLockTest {
// private val lock = reentrantLock()
// private var state = 0
//
// fun testLockField() {
// lock.withLock {
// state = 1
// }
// assertEquals(1, state)
// }
//}
class ReentrantLockFieldTest {
private val lock = reentrantLock()
private var state = 0
fun testLock() {
lock.withLock {
state = 1
}
assertEquals(1, state)
assertTrue(lock.tryLock())
lock.unlock()
}
}
fun box(): String {
val testClass = ReentrantLockFieldTest()
testClass.testLock()
return "OK"
}