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
+4 -4
View File
@@ -73,7 +73,7 @@ public final class Byte : jet.Number, jet.Comparable<jet.Byte> {
public open override /*1*/ fun equals(/*0*/ other: jet.Any?): jet.Boolean
public open override /*1*/ fun hashCode(): jet.Int
public final fun inc(): jet.Byte
public final fun minus(): jet.Byte
public final fun minus(): jet.Int
public final fun minus(/*0*/ other: jet.Byte): jet.Int
public final fun minus(/*0*/ other: jet.Char): jet.Int
public final fun minus(/*0*/ other: jet.Double): jet.Double
@@ -88,7 +88,7 @@ public final class Byte : jet.Number, jet.Comparable<jet.Byte> {
public final fun mod(/*0*/ other: jet.Int): jet.Int
public final fun mod(/*0*/ other: jet.Long): jet.Long
public final fun mod(/*0*/ other: jet.Short): jet.Int
public final fun plus(): jet.Byte
public final fun plus(): jet.Int
public final fun plus(/*0*/ other: jet.Byte): jet.Int
public final fun plus(/*0*/ other: jet.Char): jet.Int
public final fun plus(/*0*/ other: jet.Double): jet.Double
@@ -1493,7 +1493,7 @@ public final class Short : jet.Number, jet.Comparable<jet.Short> {
public open override /*1*/ fun equals(/*0*/ other: jet.Any?): jet.Boolean
public open override /*1*/ fun hashCode(): jet.Int
public final fun inc(): jet.Short
public final fun minus(): jet.Short
public final fun minus(): jet.Int
public final fun minus(/*0*/ other: jet.Byte): jet.Int
public final fun minus(/*0*/ other: jet.Char): jet.Int
public final fun minus(/*0*/ other: jet.Double): jet.Double
@@ -1508,7 +1508,7 @@ public final class Short : jet.Number, jet.Comparable<jet.Short> {
public final fun mod(/*0*/ other: jet.Int): jet.Int
public final fun mod(/*0*/ other: jet.Long): jet.Long
public final fun mod(/*0*/ other: jet.Short): jet.Int
public final fun plus(): jet.Short
public final fun plus(): jet.Int
public final fun plus(/*0*/ other: jet.Byte): jet.Int
public final fun plus(/*0*/ other: jet.Char): jet.Int
public final fun plus(/*0*/ other: jet.Double): jet.Double
@@ -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>()
@@ -7,14 +7,15 @@ fun test() {
fooInt(-1)
fooInt(<!TYPE_MISMATCH!>-1111111111111111111<!>)
fooInt(-1.toInt())
fooInt(<!TYPE_MISMATCH!>-1.toByte()<!>)
fooInt(-1.toByte())
fooInt(<!TYPE_MISMATCH!>-1.toLong()<!>)
fooInt(<!TYPE_MISMATCH!>-1.toShort()<!>)
fooInt(-1.toShort())
fooByte(-1)
fooByte(<!TYPE_MISMATCH!>-1111111111111111111<!>)
fooByte(<!TYPE_MISMATCH!>-1.toInt()<!>)
fooByte(-1.toByte())
fooByte(<!TYPE_MISMATCH!>-1.toByte()<!>)
fooByte((-1).toByte())
fooByte(<!TYPE_MISMATCH!>-1.toLong()<!>)
fooByte(<!TYPE_MISMATCH!>-1.toShort()<!>)
@@ -30,5 +31,6 @@ fun test() {
fooShort(<!TYPE_MISMATCH!>-1.toInt()<!>)
fooShort(<!TYPE_MISMATCH!>-1.toByte()<!>)
fooShort(<!TYPE_MISMATCH!>-1.toLong()<!>)
fooShort(-1.toShort())
fooShort(<!TYPE_MISMATCH!>-1.toShort()<!>)
fooShort((-1).toShort())
}
@@ -1,8 +1,8 @@
val p1 = -1
val p2 = -1.toLong()
val p3 = -1.toByte()
val p3 = (-1).toByte()
val p4 = -1.toInt()
val p5 = -1.toShort()
val p5 = (-1).toShort()
val p6 = -1111111111111111111
fun fooInt(p: Int) = p
@@ -13,8 +13,8 @@ val l2: Byte = <!TYPE_MISMATCH!>-1.toLong()<!>
val l3: Int = <!TYPE_MISMATCH!>-1.toLong()<!>
val l4: Short = <!TYPE_MISMATCH!>-1.toLong()<!>
val b1: Byte = -1.toByte()
val b2: Int = <!TYPE_MISMATCH!>-1.toByte()<!>
val b1: Byte = <!TYPE_MISMATCH!>-1.toByte()<!>
val b2: Int = -1.toByte()
val b3: Long = <!TYPE_MISMATCH!>-1.toByte()<!>
val b4: Short = <!TYPE_MISMATCH!>-1.toByte()<!>
@@ -24,6 +24,6 @@ val i3: Long = <!TYPE_MISMATCH!>-1.toInt()<!>
val i4: Short = <!TYPE_MISMATCH!>-1.toInt()<!>
val s1: Byte = <!TYPE_MISMATCH!>-1.toShort()<!>
val s2: Int = <!TYPE_MISMATCH!>-1.toShort()<!>
val s2: Int = -1.toShort()
val s3: Long = <!TYPE_MISMATCH!>-1.toShort()<!>
val s4: Short = -1.toShort()
val s4: Short = <!TYPE_MISMATCH!>-1.toShort()<!>
@@ -7,10 +7,16 @@ val p1 = -1
val p2 = -1.toLong()
// val p3: -1.toByte()
val p3 = -1.toByte()
val p3 = (-1).toByte()
// val p3a: -1.toInt()
val p3a =-1.toByte()
// val p4: -1.toInt()
val p4 = -1.toInt()
// val p5: -1.toShort()
val p5 = -1.toShort()
val p5 = (-1).toShort()
// val p5a: -1.toInt()
val p5a = -1.toShort()
@@ -25,16 +25,16 @@ val l3: Int = -1.toLong()
val l4: Short = -1.toLong()
// val b1: -1.toByte()
// val b1: -1.toInt()
val b1: Byte = -1.toByte()
// val b2: -1.toByte()
// val b2: -1.toInt()
val b2: Int = -1.toByte()
// val b3: -1.toByte()
// val b3: -1.toInt()
val b3: Long = -1.toByte()
// val b4: -1.toByte()
// val b4: -1.toInt()
val b4: Short = -1.toByte()
@@ -50,14 +50,14 @@ val i3: Long = -1.toInt()
// val i4: -1.toInt()
val i4: Short = -1.toInt()
// val s1: -1.toShort()
// val s1: -1.toInt()
val s1: Byte = -1.toShort()
// val s2: -1.toShort()
// val s2: -1.toInt()
val s2: Int = -1.toShort()
// val s3: -1.toShort()
// val s3: -1.toInt()
val s3: Long = -1.toShort()
// val s4: -1.toShort()
// val s4: -1.toInt()
val s4: Short = -1.toShort()