Files
kotlin-fork/compiler/testData/codegen/box/ieee754/smartCastOnWhenSubjectAfterCheckInBranch_properIeeeComparisons.kt
T
2019-11-19 11:00:09 +03:00

26 lines
482 B
Kotlin
Vendored

// !LANGUAGE: +ProperIeee754Comparisons
// IGNORE_BACKEND_FIR: JVM_IR
fun testF(x: Any) =
when (x) {
!is Float -> "!Float"
0.0F -> "0.0"
else -> "other"
}
fun testD(x: Any) =
when (x) {
!is Double -> "!Double"
0.0 -> "0.0"
else -> "other"
}
fun box(): String {
val tf = testF(-0.0F)
if (tf != "0.0") return "Fail 1: $tf"
val td = testD(-0.0)
if (td != "0.0") return "Fail 2: $td"
return "OK"
}