mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Intrinsics for 'reversed': downTo
#KT-21323 In Progress
This commit is contained in:
26
compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownTo.kt
vendored
Normal file
26
compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownTo.kt
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// WITH_RUNTIME
|
||||
import kotlin.test.*
|
||||
|
||||
fun box(): String {
|
||||
var sum = 0
|
||||
for (i in (4 downTo 1).reversed()) {
|
||||
sum = sum * 10 + i
|
||||
}
|
||||
assertEquals(1234, sum)
|
||||
|
||||
var sumL = 0L
|
||||
for (i in (4L downTo 1L).reversed()) {
|
||||
sumL = sumL * 10 + i
|
||||
}
|
||||
assertEquals(1234L, sumL)
|
||||
|
||||
var sumC = 0
|
||||
for (i in ('4' downTo '1').reversed()) {
|
||||
sumC = sumC * 10 + i.toInt() - '0'.toInt()
|
||||
}
|
||||
assertEquals(1234, sumC)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// 0 reversed
|
||||
Reference in New Issue
Block a user