Files
kotlin-fork/compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.fir.kt.txt
T
Vladimir Sukharev bae8b283c7 [IR] Normalize temp var names in Kotlin-like dump
^KT-61983 Fixed
2023-10-11 07:49:35 +00:00

81 lines
1.5 KiB
Kotlin
Vendored

fun testSimple(x: Double): Int {
return { // BLOCK
val tmp_0: Double = x
when {
ieee754equals(arg0 = tmp_0, arg1 = 0.0) -> 0
else -> 1
}
}
}
fun testSmartCastInWhenSubject(x: Any): Int {
when {
x !is Double -> return -1
}
return { // BLOCK
val tmp_1: Double = x /*as Double */
when {
ieee754equals(arg0 = tmp_1, arg1 = 0.0) -> 0
else -> 1
}
}
}
fun testSmartCastInWhenCondition(x: Double, y: Any): Int {
when {
y !is Double -> return -1
}
return { // BLOCK
val tmp_2: Double = x
when {
ieee754equals(arg0 = tmp_2, arg1 = y /*as Double */) -> 0
else -> 1
}
}
}
fun testSmartCastInWhenConditionInBranch(x: Any): Int {
return { // BLOCK
val tmp_3: Any = x
when {
tmp_3 !is Double -> -1
ieee754equals(arg0 = tmp_3 /*as Double */, arg1 = 0.0) -> 0
else -> 1
}
}
}
fun testSmartCastToDifferentTypes(x: Any, y: Any): Int {
when {
x !is Double -> return -1
}
when {
y !is Float -> return -1
}
return { // BLOCK
val tmp_4: Double = x /*as Double */
when {
ieee754equals(arg0 = tmp_4, arg1 = y /*as Float */.toDouble()) -> 0
else -> 1
}
}
}
fun foo(x: Double): Double {
return x
}
fun testWithPrematureExitInConditionSubexpression(x: Any): Int {
return { // BLOCK
val tmp_5: Any = x
when {
EQEQ(arg0 = tmp_5, arg1 = foo(x = when {
x !is Double -> return 42
else -> x /*as Double */
})) -> 0
else -> 1
}
}
}