Files
kotlin/compiler/testData/codegen/box/ranges/forInUntil/forInUntilInt.kt
Roman Artemev cc14442be1 Add tests for primitive companion object
Update test data
2018-08-24 14:58:42 +03:00

26 lines
472 B
Kotlin
Vendored

// WITH_RUNTIME
import kotlin.test.assertEquals
fun box(): String {
testIntInIntUntilInt()
testNullableIntInIntUntilInt()
return "OK"
}
private fun testIntInIntUntilInt() {
var sum = 0
for (i in 1 until 5) {
sum = sum * 10 + i
}
assertEquals(1234, sum)
}
private fun testNullableIntInIntUntilInt() {
var sum = 0
for (i: Int? in 1 until 5) {
sum = sum * 10 + (i?.toInt() ?: break)
}
assertEquals(1234, sum)
}