[atomicfu-K/N] Tests for K/N atomicfu-compiler-plugin
* `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>
This commit is contained in:
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
import kotlinx.atomicfu.*
|
||||
import kotlin.test.*
|
||||
|
||||
class IndexArrayElementGetterTest {
|
||||
private val clazz = AtomicArrayClass()
|
||||
|
||||
fun fib(a: Int): Int = if (a == 0 || a == 1) a else fib(a - 1) + fib(a - 2)
|
||||
|
||||
fun testIndexArrayElementGetting() {
|
||||
clazz.intArr[8].value = 3
|
||||
val i = fib(4)
|
||||
val j = fib(5)
|
||||
assertEquals(3, clazz.intArr[i + j].value)
|
||||
assertEquals(3, clazz.intArr[fib(4) + fib(5)].value)
|
||||
clazz.longArr[3].value = 100
|
||||
assertEquals(100, clazz.longArr[fib(6) - fib(5)].value)
|
||||
assertEquals(100, clazz.longArr[(fib(6) + fib(4)) % 8].value)
|
||||
assertEquals(100, clazz.longArr[(fib(6) + fib(4)) % 8].value)
|
||||
assertEquals(100, clazz.longArr[(fib(4) + fib(5)) % fib(5)].value)
|
||||
}
|
||||
|
||||
private class AtomicArrayClass {
|
||||
val intArr = AtomicIntArray(10)
|
||||
val longArr = AtomicLongArray(10)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun box() {
|
||||
val testClass = IndexArrayElementGetterTest()
|
||||
testClass.testIndexArrayElementGetting()
|
||||
}
|
||||
Reference in New Issue
Block a user