Update box test for unsigned to signed conversions
Updated test checks, that large unsigned numbers are converted to corresponding negative signed numbers properly. Using unsinged constants instead of signed in test allows to remove supressed OI error as well as use test with NI.
This commit is contained in:
-27
@@ -1,27 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
|
||||
@file:Suppress("SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED")
|
||||
|
||||
fun takeUByte(u: UByte) = u.toByte()
|
||||
fun takeUShort(u: UShort) = u.toShort()
|
||||
fun takeUInt(u: UInt) = u.toInt()
|
||||
fun takeULong(u: ULong) = u.toLong()
|
||||
|
||||
fun box(): String {
|
||||
val b = takeUByte(200 + 55)
|
||||
if (b != (-1).toByte()) return "Fail 1: $b"
|
||||
|
||||
val s = takeUShort(123)
|
||||
if (s != 123.toShort()) return "Fail 2: $s"
|
||||
|
||||
val i = takeUInt(0xFFFF_FFFF)
|
||||
if (i != -1) return "Fail 3: $i"
|
||||
|
||||
val l = takeULong(0xFFFF_FFFF_FFFF)
|
||||
if (l != 0xFFFF_FFFF_FFFFL) return "Fail 4: $l"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
|
||||
fun takeUByte(u: UByte) = u.toByte()
|
||||
fun takeUShort(u: UShort) = u.toShort()
|
||||
fun takeUInt(u: UInt) = u.toInt()
|
||||
fun takeULong(u: ULong) = u.toLong()
|
||||
|
||||
fun box(): String {
|
||||
val b1 = takeUByte(127u)
|
||||
if (b1 != 127.toByte()) return "Fail byte: $b1"
|
||||
|
||||
val b2 = takeUByte(255u)
|
||||
if (b2 != (-1).toByte()) return "Fail byte negative: $b2"
|
||||
|
||||
val s1 = takeUShort(0x7FFFu)
|
||||
if (s1 != 0x7FFF.toShort()) return "Fail short: $s1"
|
||||
|
||||
val s2 = takeUShort(0xFFFFu)
|
||||
if (s2 != (-1).toShort()) return "Fail short negative: $s2"
|
||||
|
||||
val i1 = takeUInt(0x7FFF_FFFFu)
|
||||
if (i1 != 0x7FFF_FFFF) return "Fail int: $i1"
|
||||
|
||||
val i2 = takeUInt(0xFFFF_FFFFu)
|
||||
if (i2 != -1) return "Fail int negative: $i2"
|
||||
|
||||
val l1 = takeULong(0x7FFF_FFFF_FFFF_FFFFu)
|
||||
if (l1 != 0x7FFF_FFFF_FFFF_FFFF) return "Fail long: $l1"
|
||||
|
||||
val l2 = takeULong(0xFFFF_FFFF_FFFF_FFFFu)
|
||||
if (l2 != (-1).toLong()) return "Fail long negative: $l2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user