mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 00:21:28 +00:00
26 lines
472 B
Kotlin
Vendored
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)
|
|
}
|