Files
kotlin-fork/compiler/testData/codegen/box/binaryOp/overflowLong.kt
T
Dmitriy Novozhilov 52b72a7dac [FIR] Implement Int -> Long conversions for literals and operators over them
^KT-38895
^KT-50996 Fixed
^KT-51000 Fixed
^KT-51003 Fixed
^KT-51018 Fixed
2022-02-07 13:36:36 +03:00

17 lines
524 B
Kotlin
Vendored

// LANGUAGE: -ApproximateIntegerLiteralTypesInReceiverPosition
fun box(): String {
val a: Long = 2147483647 + 1
if (a != -2147483648L) return "fail: in this case we should add to ints and than cast the result to long - overflow expected"
val l1 = Long.MAX_VALUE
val l2 = l1 + 1
if (l2 > l1) return "fail: Long.MAX_VALUE + 1 should overflow to negative."
val l3 = Long.MIN_VALUE
val l4 = l3 - 1
if (l4 < l3) return "fail: Long.MIN_VALUE - 1 should overflow to positive."
return "OK"
}