Make unary minus and unary plus return int for byte and short
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
data class A(val a: Byte)
|
||||
|
||||
fun box() : String {
|
||||
val v1 = A(-10.toByte()).hashCode()
|
||||
val v2 = (-10.toByte() as Byte?)!!.hashCode()
|
||||
val v1 = A(10.toByte()).hashCode()
|
||||
val v2 = (10.toByte() as Byte?)!!.hashCode()
|
||||
return if( v1 == v2 ) "OK" else "$v1 $v2"
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
data class A(val a: Short)
|
||||
|
||||
fun box() : String {
|
||||
val v1 = A(-10.toShort()).hashCode()
|
||||
val v2 = (-10.toShort() as Short?)!!.hashCode()
|
||||
val v1 = A(10.toShort()).hashCode()
|
||||
val v2 = (10.toShort() as Short?)!!.hashCode()
|
||||
return if( v1 == v2 ) "OK" else "$v1 $v2"
|
||||
}
|
||||
|
||||
@@ -14,23 +14,23 @@ fun box(): String {
|
||||
}
|
||||
|
||||
val list2 = ArrayList<Byte>()
|
||||
val range2 = 10.toByte()..-5.toByte()
|
||||
val range2 = 10.toByte()..(-5).toByte()
|
||||
for (i in range2) {
|
||||
list2.add(i)
|
||||
if (list2.size() > 23) break
|
||||
}
|
||||
if (list2 != listOf<Byte>()) {
|
||||
return "Wrong elements for 10.toByte()..-5.toByte(): $list2"
|
||||
return "Wrong elements for 10.toByte()..(-5).toByte(): $list2"
|
||||
}
|
||||
|
||||
val list3 = ArrayList<Short>()
|
||||
val range3 = 10.toShort()..-5.toShort()
|
||||
val range3 = 10.toShort()..(-5).toShort()
|
||||
for (i in range3) {
|
||||
list3.add(i)
|
||||
if (list3.size() > 23) break
|
||||
}
|
||||
if (list3 != listOf<Short>()) {
|
||||
return "Wrong elements for 10.toShort()..-5.toShort(): $list3"
|
||||
return "Wrong elements for 10.toShort()..(-5).toShort(): $list3"
|
||||
}
|
||||
|
||||
val list4 = ArrayList<Long>()
|
||||
|
||||
@@ -13,21 +13,21 @@ fun box(): String {
|
||||
}
|
||||
|
||||
val list2 = ArrayList<Byte>()
|
||||
for (i in 10.toByte()..-5.toByte()) {
|
||||
for (i in 10.toByte()..(-5).toByte()) {
|
||||
list2.add(i)
|
||||
if (list2.size() > 23) break
|
||||
}
|
||||
if (list2 != listOf<Byte>()) {
|
||||
return "Wrong elements for 10.toByte()..-5.toByte(): $list2"
|
||||
return "Wrong elements for 10.toByte()..(-5).toByte(): $list2"
|
||||
}
|
||||
|
||||
val list3 = ArrayList<Short>()
|
||||
for (i in 10.toShort()..-5.toShort()) {
|
||||
for (i in 10.toShort()..(-5).toShort()) {
|
||||
list3.add(i)
|
||||
if (list3.size() > 23) break
|
||||
}
|
||||
if (list3 != listOf<Short>()) {
|
||||
return "Wrong elements for 10.toShort()..-5.toShort(): $list3"
|
||||
return "Wrong elements for 10.toShort()..(-5).toShort(): $list3"
|
||||
}
|
||||
|
||||
val list4 = ArrayList<Long>()
|
||||
|
||||
Reference in New Issue
Block a user