Make unary minus and unary plus return int for byte and short

This commit is contained in:
Natalia Ukhorskaya
2013-12-19 17:42:28 +04:00
parent 802c1b772f
commit 4329c42e3f
23 changed files with 76 additions and 68 deletions
@@ -6,8 +6,8 @@ fun box(): String {
val a5: Double = 1.0.minus()
val a6: Float = 1f.minus()
if (a1 != -1.toByte()) return "fail 1"
if (a2 != -1.toShort()) return "fail -1"
if (a1 != (-1).toByte()) return "fail 1"
if (a2 != (-1).toShort()) return "fail -1"
if (a3 != -1) return "fail 3"
if (a4 != -1L) return "fail 4"
if (a5 != -1.0) return "fail 5"
@@ -6,8 +6,8 @@ fun box(): String {
val a5: Double? = 1.0.minus()
val a6: Float? = 1f.minus()
if (a1!! != -1.toByte()) return "fail 1"
if (a2!! != -1.toShort()) return "fail 2"
if (a1!! != (-1).toByte()) return "fail 1"
if (a2!! != (-1).toShort()) return "fail 2"
if (a3!! != -1) return "fail 3"
if (a4!! != -1L) return "fail 4"
if (a5!! != -1.0) return "fail 5"
@@ -1,6 +1,6 @@
fun box(): String {
if (!foo(1.toByte())) return "fail 1"
if (!foo(-1.toByte())) return "fail 2"
if (!foo((1.toByte()).inc())) return "fail 2"
return "OK"
}
@@ -6,8 +6,8 @@ fun box(): String {
val a5: Double = -1.0
val a6: Float = -1f
if (a1 != -1.toByte()) return "fail 1"
if (a2 != -1.toShort()) return "fail 2"
if (a1 != (-1).toByte()) return "fail 1"
if (a2 != (-1).toShort()) return "fail 2"
if (a3 != -1) return "fail 3"
if (a4 != -1L) return "fail 4"
if (a5 != -1.0) return "fail 5"
@@ -6,8 +6,8 @@ fun box(): String {
val a5: Double? = -1.0
val a6: Float? = -1f
if (a1!! != -1.toByte()) return "fail 1"
if (a2!! != -1.toShort()) return "fail 2"
if (a1!! != (-1).toByte()) return "fail 1"
if (a2!! != (-1).toShort()) return "fail 2"
if (a3!! != -1) return "fail 3"
if (a4!! != -1L) return "fail 4"
if (a5!! != -1.0) return "fail 5"
@@ -7,11 +7,11 @@ fun box(): String {
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
if (ann == null) return "fail: cannot find Ann on MyClass}"
if (ann.i != -2) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.s != -2.toShort()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.s != (-2).toShort()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.f != -2.toFloat()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.d != -2.toDouble()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.l != -2.toLong()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.b != -2.toByte()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
if (ann.b != (-2).toByte()) return "fail: annotation parameter i should be -2, but was ${ann.i}"
return "OK"
}
@@ -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>()