Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/contextsAndAccessors/kt26858.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

25 lines
709 B
Kotlin
Vendored

// WITH_STDLIB
@Suppress("OPTIONAL_DECLARATION_USAGE_IN_NON_COMMON_SOURCE")
@kotlin.jvm.JvmInline
value class Direction(private val direction: Int) {
fun dx() = dx[direction]
fun dy() = dy[direction]
companion object {
private val dx = intArrayOf(0, 1, 0, -1)
private val dy = intArrayOf(-1, 0, 1, 0)
}
}
fun box(): String {
val dirs = arrayOf(Direction(0), Direction(1), Direction(2), Direction(3))
val expectedDx = intArrayOf(0, 1, 0, -1)
val expectedDy = intArrayOf(-1, 0, 1, 0)
for (i in 0 .. 3) {
if (dirs[i].dx() != expectedDx[i]) throw AssertionError()
if (dirs[i].dy() != expectedDy[i]) throw AssertionError()
}
return "OK"
}