Ensure that 'in/!in x until y' intrinsic works

This commit is contained in:
Dmitry Petrov
2017-06-30 18:03:33 +03:00
parent 05cad83c79
commit ec99fa2142
8 changed files with 72 additions and 1 deletions
@@ -0,0 +1,29 @@
// WITH_RUNTIME
fun box(): String {
if (!(1 in 0 until 10)) return "Fail 1 in"
if (1 !in 0 until 10) return "Fail 1 !in"
if (10 in 0 until 10) return "Fail 2 in"
if (!(10 !in 0 until 10)) return "Fail 2 !in"
if (!(1.toByte() in 0.toByte() until 10.toByte())) return "Fail 1 in Byte"
if (1.toByte() !in 0.toByte() until 10.toByte()) return "Fail 1 !in Byte"
if (10.toByte() in 0.toByte() until 10.toByte()) return "Fail 2 in Byte"
if (!(10.toByte() !in 0.toByte() until 10.toByte())) return "Fail 2 !in Byte"
if (!(1.toShort() in 0.toShort() until 10.toShort())) return "Fail 1 in Short"
if (1.toShort() !in 0.toShort() until 10.toShort()) return "Fail 1 !in Short"
if (10.toShort() in 0.toShort() until 10.toShort()) return "Fail 2 in Short"
if (!(10.toShort() !in 0.toShort() until 10.toShort())) return "Fail 2 !in Short"
if (!(1.toLong() in 0.toLong() until 10.toLong())) return "Fail 1 in Long"
if (1.toLong() !in 0.toLong() until 10.toLong()) return "Fail 1 !in Long"
if (10.toLong() in 0.toLong() until 10.toLong()) return "Fail 2 in Long"
if (!(10.toLong() !in 0.toLong() until 10.toLong())) return "Fail 2 !in Long"
return "OK"
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
fun testByte(a: Byte, x: Byte, y: Byte) = a in x until y
fun testShort(a: Short, x: Short, y: Short) = a in x until y
fun testInt(a: Int, x: Int, y: Int) = a in x until y
fun testLong(a: Long, x: Long, y: Long) = a in x until y
// 0 INVOKESTATIC kotlin/ranges/RangesKt.until
// 0 INVOKEVIRTUAL