Files
kotlin/compiler/testData/codegen/bytecodeText/boxingOptimization/maxMinBy.kt
Alexander Udalov f5ff3d2fa9 Remove directives that have no effect from bytecode text tests
All bytecode text tests are run with stdlib in the classpath and only
for JVM backend, therefore directives WITH_RUNTIME, TARGET_BACKEND,
IGNORE_BACKEND are not needed
2018-12-20 12:53:24 +01:00

36 lines
809 B
Kotlin
Vendored

// FILE: list.kt
val intList = listOf(1, 2, 3)
val longList = listOf(1L, 2L, 3L)
// FILE: box.kt
fun box(): String {
val intListMin = intList.minBy { it } ?: -1
if (intListMin != 1) return "Fail intListMin=$intListMin"
val intListMax = intList.maxBy { it } ?: -1
if (intListMax != 3) return "Fail intListMax=$intListMax"
val longListMin = longList.minBy { it } ?: -1
if (longListMin != 1L) return "Fail longListMin=$longListMin"
val longListMax = longList.maxBy { it } ?: -1
if (longListMax != 3L) return "Fail longListMax=$longListMax"
return "OK"
}
// @BoxKt.class:
// -- no boxing
// 0 valueOf
// -- no compareTo
// 0 compareTo
// -- comparisons are properly fused with conditional jumps
// 0 ICONST_0
// 1 IF_ICMPGE
// 1 IF_ICMPLE
// 4 LCMP
// 1 IFGE
// 1 IFLE