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:
@@ -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()
|
||||
}
|
||||
Reference in New Issue
Block a user