Files
kotlin-fork/compiler/testData/ir/irText/expressions/floatingPointComparisons/whenByFloatingPoint.fir.kt.txt
T
2024-02-16 10:19:38 +00:00

81 lines
1.5 KiB
Kotlin
Vendored

fun foo(x: Double): Double {
return x
}
fun testSimple(x: Double): Int {
return { // BLOCK
val tmp_0: Double = x
when {
ieee754equals(arg0 = tmp_0, arg1 = 0.0) -> 0
else -> 1
}
}
}
fun testSmartCastInWhenCondition(x: Double, y: Any): Int {
when {
y !is Double -> return -1
}
return { // BLOCK
val tmp_1: Double = x
when {
ieee754equals(arg0 = tmp_1, arg1 = y /*as Double */) -> 0
else -> 1
}
}
}
fun testSmartCastInWhenConditionInBranch(x: Any): Int {
return { // BLOCK
val tmp_2: Any = x
when {
tmp_2 !is Double -> -1
ieee754equals(arg0 = tmp_2 /*as Double */, arg1 = 0.0) -> 0
else -> 1
}
}
}
fun testSmartCastInWhenSubject(x: Any): Int {
when {
x !is Double -> return -1
}
return { // BLOCK
val tmp_3: Double = x /*as Double */
when {
ieee754equals(arg0 = tmp_3, 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 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
}
}
}