Add 'until' function for unsigned arguments to interpreter test helpers #KT-52933

Required to evaluate rangeUntil members of unsigned types.
This commit is contained in:
Ilya Gorbunov
2022-08-12 20:54:43 +02:00
committed by Space
parent 800ff20fc7
commit baf7cbb3ac
+20
View File
@@ -65,4 +65,24 @@ public infix fun Byte.until(to: Short): IntRange {
}
public infix fun Short.until(to: Short): IntRange {
return this.toInt() .. (to.toInt() - 1).toInt()
}
public infix fun UByte.until(to: UByte): UIntRange {
if (to <= UByte.MIN_VALUE) return UIntRange.EMPTY
return this.toUInt() .. (to - 1u).toUInt()
}
public infix fun UInt.until(to: UInt): UIntRange {
if (to <= UInt.MIN_VALUE) return UIntRange.EMPTY
return this .. (to - 1u).toUInt()
}
public infix fun ULong.until(to: ULong): ULongRange {
if (to <= ULong.MIN_VALUE) return ULongRange.EMPTY
return this .. (to - 1u).toULong()
}
public infix fun UShort.until(to: UShort): UIntRange {
if (to <= UShort.MIN_VALUE) return UIntRange.EMPTY
return this.toUInt() .. (to - 1u).toUInt()
}