kotlinx.atomicfu JVM/IR compiler plugin support
Merge-request: KT-MR-6541 Merged-by: Maria Sokolova <maria.sokolova@jetbrains.com>
This commit is contained in:
@@ -1,20 +1,34 @@
|
||||
import kotlinx.atomicfu.locks.*
|
||||
import kotlin.test.*
|
||||
|
||||
class ReentrantLockTest {
|
||||
//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 testLockField() {
|
||||
fun testLock() {
|
||||
lock.withLock {
|
||||
state = 1
|
||||
}
|
||||
assertEquals(1, state)
|
||||
assertTrue(lock.tryLock())
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val testClass = ReentrantLockTest()
|
||||
testClass.testLockField()
|
||||
val testClass = ReentrantLockFieldTest()
|
||||
testClass.testLock()
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user