Move some tests from boxWithStdlib/ to box/
Move those tests which do not require neither stdlib nor reflect
This commit is contained in:
committed by
Alexander Udalov
parent
54a615fcd3
commit
20e36438e2
@@ -0,0 +1,69 @@
|
||||
fun box(): String {
|
||||
val aByte: Array<Byte> = arrayOf<Byte>(1)
|
||||
val bByte: ByteArray = byteArrayOf(1)
|
||||
|
||||
val aShort: Array<Short> = arrayOf<Short>(1)
|
||||
val bShort: ShortArray = shortArrayOf(1)
|
||||
|
||||
val aInt: Array<Int> = arrayOf<Int>(1)
|
||||
val bInt: IntArray = intArrayOf(1)
|
||||
|
||||
val aLong: Array<Long> = arrayOf<Long>(1)
|
||||
val bLong: LongArray = longArrayOf(1)
|
||||
|
||||
val aFloat: Array<Float> = arrayOf<Float>(1.0f)
|
||||
val bFloat: FloatArray = floatArrayOf(1.0f)
|
||||
|
||||
val aDouble: Array<Double> = arrayOf<Double>(1.0)
|
||||
val bDouble: DoubleArray = doubleArrayOf(1.0)
|
||||
|
||||
aByte[0]--
|
||||
bByte[0]--
|
||||
if (aByte[0] != bByte[0]) return "Failed post-decrement Byte: ${aByte[0]} != ${bByte[0]}"
|
||||
|
||||
aByte[0]++
|
||||
bByte[0]++
|
||||
if (aByte[0] != bByte[0]) return "Failed post-increment Byte: ${aByte[0]} != ${bByte[0]}"
|
||||
|
||||
aShort[0]--
|
||||
bShort[0]--
|
||||
if (aShort[0] != bShort[0]) return "Failed post-decrement Short: ${aShort[0]} != ${bShort[0]}"
|
||||
|
||||
aShort[0]++
|
||||
bShort[0]++
|
||||
if (aShort[0] != bShort[0]) return "Failed post-increment Short: ${aShort[0]} != ${bShort[0]}"
|
||||
|
||||
aInt[0]--
|
||||
bInt[0]--
|
||||
if (aInt[0] != bInt[0]) return "Failed post-decrement Int: ${aInt[0]} != ${bInt[0]}"
|
||||
|
||||
aInt[0]++
|
||||
bInt[0]++
|
||||
if (aInt[0] != bInt[0]) return "Failed post-increment Int: ${aInt[0]} != ${bInt[0]}"
|
||||
|
||||
aLong[0]--
|
||||
bLong[0]--
|
||||
if (aLong[0] != bLong[0]) return "Failed post-decrement Long: ${aLong[0]} != ${bLong[0]}"
|
||||
|
||||
aLong[0]++
|
||||
bLong[0]++
|
||||
if (aLong[0] != bLong[0]) return "Failed post-increment Long: ${aLong[0]} != ${bLong[0]}"
|
||||
|
||||
aFloat[0]++
|
||||
bFloat[0]++
|
||||
if (aFloat[0] != bFloat[0]) return "Failed post-increment Float: ${aFloat[0]} != ${bFloat[0]}"
|
||||
|
||||
aFloat[0]--
|
||||
bFloat[0]--
|
||||
if (aFloat[0] != bFloat[0]) return "Failed post-decrement Float: ${aFloat[0]} != ${bFloat[0]}"
|
||||
|
||||
aDouble[0]++
|
||||
bDouble[0]++
|
||||
if (aDouble[0] != bDouble[0]) return "Failed post-increment Double: ${aDouble[0]} != ${bDouble[0]}"
|
||||
|
||||
aDouble[0]--
|
||||
bDouble[0]--
|
||||
if (aDouble[0] != bDouble[0]) return "Failed post-decrement Double: ${aDouble[0]} != ${bDouble[0]}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
object A {
|
||||
var x = 0
|
||||
|
||||
operator fun get(i1: Int, i2: Int, i3: Int): Int = x
|
||||
|
||||
operator fun set(i1: Int, i2: Int, i3: Int, value: Int) {
|
||||
x = value
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
A.x = 0
|
||||
val xx = A[1, 2, 3]++
|
||||
return if (xx != 0 || A.x != 1) "Failed" else "OK"
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
class AByte(var value: Byte) {
|
||||
operator fun get(i: Int) = value
|
||||
|
||||
operator fun set(i: Int, newValue: Byte) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
class AShort(var value: Short) {
|
||||
operator fun get(i: Int) = value
|
||||
|
||||
operator fun set(i: Int, newValue: Short) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
class AInt(var value: Int) {
|
||||
operator fun get(i: Int) = value
|
||||
|
||||
operator fun set(i: Int, newValue: Int) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
class ALong(var value: Long) {
|
||||
operator fun get(i: Int) = value
|
||||
|
||||
operator fun set(i: Int, newValue: Long) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
class AFloat(var value: Float) {
|
||||
operator fun get(i: Int) = value
|
||||
|
||||
operator fun set(i: Int, newValue: Float) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
class ADouble(var value: Double) {
|
||||
operator fun get(i: Int) = value
|
||||
|
||||
operator fun set(i: Int, newValue: Double) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val aByte = AByte(1)
|
||||
var bByte: Byte = 1
|
||||
|
||||
val aShort = AShort(1)
|
||||
var bShort: Short = 1
|
||||
|
||||
val aInt = AInt(1)
|
||||
var bInt: Int = 1
|
||||
|
||||
val aLong = ALong(1)
|
||||
var bLong: Long = 1
|
||||
|
||||
val aFloat = AFloat(1.0f)
|
||||
var bFloat: Float = 1.0f
|
||||
|
||||
val aDouble = ADouble(1.0)
|
||||
var bDouble: Double = 1.0
|
||||
|
||||
aByte[0]++
|
||||
bByte++
|
||||
if (aByte[0] != bByte) return "Failed post-increment Byte: ${aByte[0]} != $bByte"
|
||||
|
||||
aByte[0]--
|
||||
bByte--
|
||||
if (aByte[0] != bByte) return "Failed post-decrement Byte: ${aByte[0]} != $bByte"
|
||||
|
||||
aShort[0]++
|
||||
bShort++
|
||||
if (aShort[0] != bShort) return "Failed post-increment Short: ${aShort[0]} != $bShort"
|
||||
|
||||
aShort[0]--
|
||||
bShort--
|
||||
if (aShort[0] != bShort) return "Failed post-decrement Short: ${aShort[0]} != $bShort"
|
||||
|
||||
aInt[0]++
|
||||
bInt++
|
||||
if (aInt[0] != bInt) return "Failed post-increment Int: ${aInt[0]} != $bInt"
|
||||
|
||||
aInt[0]--
|
||||
bInt--
|
||||
if (aInt[0] != bInt) return "Failed post-decrement Int: ${aInt[0]} != $bInt"
|
||||
|
||||
aLong[0]++
|
||||
bLong++
|
||||
if (aLong[0] != bLong) return "Failed post-increment Long: ${aLong[0]} != $bLong"
|
||||
|
||||
aLong[0]--
|
||||
bLong--
|
||||
if (aLong[0] != bLong) return "Failed post-decrement Long: ${aLong[0]} != $bLong"
|
||||
|
||||
aFloat[0]++
|
||||
bFloat++
|
||||
if (aFloat[0] != bFloat) return "Failed post-increment Float: ${aFloat[0]} != $bFloat"
|
||||
|
||||
aFloat[0]--
|
||||
bFloat--
|
||||
if (aFloat[0] != bFloat) return "Failed post-decrement Float: ${aFloat[0]} != $bFloat"
|
||||
|
||||
aDouble[0]++
|
||||
bDouble++
|
||||
if (aDouble[0] != bDouble) return "Failed post-increment Double: ${aDouble[0]} != $bDouble"
|
||||
|
||||
aDouble[0]--
|
||||
bDouble--
|
||||
if (aDouble[0] != bDouble) return "Failed post-decrement Double: ${aDouble[0]} != $bDouble"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
operator fun Long.get(i: Int) = this
|
||||
operator fun Long.set(i: Int, newValue: Long) {}
|
||||
|
||||
fun box(): String {
|
||||
var x = 0L
|
||||
val y = x[0]++
|
||||
return if (y == 0L) "OK" else "Failed, y=$y"
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
class A<T>(var value: T) {
|
||||
operator fun get(i: Int) = value
|
||||
|
||||
operator fun set(i: Int, newValue: T) {
|
||||
value = newValue
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val aByte = A<Byte>(1)
|
||||
var bByte: Byte = 1
|
||||
|
||||
val aShort = A<Short>(1)
|
||||
var bShort: Short = 1
|
||||
|
||||
val aInt = A<Int>(1)
|
||||
var bInt: Int = 1
|
||||
|
||||
val aLong = A<Long>(1)
|
||||
var bLong: Long = 1
|
||||
|
||||
val aFloat = A<Float>(1.0f)
|
||||
var bFloat: Float = 1.0f
|
||||
|
||||
val aDouble = A<Double>(1.0)
|
||||
var bDouble: Double = 1.0
|
||||
|
||||
aByte[0]++
|
||||
bByte++
|
||||
if (aByte[0] != bByte) return "Failed post-increment Byte: ${aByte[0]} != $bByte"
|
||||
|
||||
aByte[0]--
|
||||
bByte--
|
||||
if (aByte[0] != bByte) return "Failed post-decrement Byte: ${aByte[0]} != $bByte"
|
||||
|
||||
aShort[0]++
|
||||
bShort++
|
||||
if (aShort[0] != bShort) return "Failed post-increment Short: ${aShort[0]} != $bShort"
|
||||
|
||||
aShort[0]--
|
||||
bShort--
|
||||
if (aShort[0] != bShort) return "Failed post-decrement Short: ${aShort[0]} != $bShort"
|
||||
|
||||
aInt[0]++
|
||||
bInt++
|
||||
if (aInt[0] != bInt) return "Failed post-increment Int: ${aInt[0]} != $bInt"
|
||||
|
||||
aInt[0]--
|
||||
bInt--
|
||||
if (aInt[0] != bInt) return "Failed post-decrement Int: ${aInt[0]} != $bInt"
|
||||
|
||||
aLong[0]++
|
||||
bLong++
|
||||
if (aLong[0] != bLong) return "Failed post-increment Long: ${aLong[0]} != $bLong"
|
||||
|
||||
aLong[0]--
|
||||
bLong--
|
||||
if (aLong[0] != bLong) return "Failed post-decrement Long: ${aLong[0]} != $bLong"
|
||||
|
||||
aFloat[0]++
|
||||
bFloat++
|
||||
if (aFloat[0] != bFloat) return "Failed post-increment Float: ${aFloat[0]} != $bFloat"
|
||||
|
||||
aFloat[0]--
|
||||
bFloat--
|
||||
if (aFloat[0] != bFloat) return "Failed post-decrement Float: ${aFloat[0]} != $bFloat"
|
||||
|
||||
aDouble[0]++
|
||||
bDouble++
|
||||
if (aDouble[0] != bDouble) return "Failed post-increment Double: ${aDouble[0]} != $bDouble"
|
||||
|
||||
aDouble[0]--
|
||||
bDouble--
|
||||
if (aDouble[0] != bDouble) return "Failed post-decrement Double: ${aDouble[0]} != $bDouble"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
fun box(): String {
|
||||
var aByte: Byte? = 0
|
||||
var bByte: Byte = 0
|
||||
|
||||
var aShort: Short? = 0
|
||||
var bShort: Short = 0
|
||||
|
||||
var aInt: Int? = 0
|
||||
var bInt: Int = 0
|
||||
|
||||
var aLong: Long? = 0
|
||||
var bLong: Long = 0
|
||||
|
||||
var aFloat: Float? = 0.0f
|
||||
var bFloat: Float = 0.0f
|
||||
|
||||
var aDouble: Double? = 0.0
|
||||
var bDouble: Double = 0.0
|
||||
|
||||
if (aByte != null) aByte--
|
||||
bByte--
|
||||
if (aByte != bByte) return "Failed post-decrement Byte: $aByte != $bByte"
|
||||
|
||||
if (aByte != null) aByte++
|
||||
bByte++
|
||||
if (aByte != bByte) return "Failed post-increment Byte: $aByte != $bByte"
|
||||
|
||||
if (aShort != null) aShort--
|
||||
bShort--
|
||||
if (aShort != bShort) return "Failed post-decrement Short: $aShort != $bShort"
|
||||
|
||||
if (aShort != null) aShort++
|
||||
bShort++
|
||||
if (aShort != bShort) return "Failed post-increment Short: $aShort != $bShort"
|
||||
|
||||
if (aInt != null) aInt--
|
||||
bInt--
|
||||
if (aInt != bInt) return "Failed post-decrement Int: $aInt != $bInt"
|
||||
|
||||
if (aInt != null) aInt++
|
||||
bInt++
|
||||
if (aInt != bInt) return "Failed post-increment Int: $aInt != $bInt"
|
||||
|
||||
if (aLong != null) aLong--
|
||||
bLong--
|
||||
if (aLong != bLong) return "Failed post-decrement Long: $aLong != $bLong"
|
||||
|
||||
if (aLong != null) aLong++
|
||||
bLong++
|
||||
if (aLong != bLong) return "Failed post-increment Long: $aLong != $bLong"
|
||||
|
||||
if (aFloat != null) aFloat--
|
||||
bFloat--
|
||||
if (aFloat != bFloat) return "Failed post-decrement Float: $aFloat != $bFloat"
|
||||
|
||||
if (aFloat != null) aFloat++
|
||||
bFloat++
|
||||
if (aFloat != bFloat) return "Failed post-increment Float: $aFloat != $bFloat"
|
||||
|
||||
if (aDouble != null) aDouble--
|
||||
bDouble--
|
||||
if (aDouble != bDouble) return "Failed post-decrement Double: $aDouble != $bDouble"
|
||||
|
||||
if (aDouble != null) aDouble++
|
||||
bDouble++
|
||||
if (aDouble != bDouble) return "Failed post-increment Double: $aDouble != $bDouble"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user