Tests for for-in optimization with unsigned ranges
This commit is contained in:
+53
@@ -0,0 +1,53 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
fun testUIntRangeLiteral(a: UInt, b: UInt): Int {
|
||||
var s = 0
|
||||
for (x in a .. b) {
|
||||
s += x.toInt()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun testULongRangeLiteral(a: ULong, b: ULong): Int {
|
||||
var s = 0
|
||||
for (x in a .. b) {
|
||||
s += x.toInt()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun testUIntUntil(a: UInt, b: UInt): Int {
|
||||
var s = 0
|
||||
for (x in a until b) {
|
||||
s += x.toInt()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun testULongUntil(a: ULong, b: ULong): Int {
|
||||
var s = 0
|
||||
for (x in a until b) {
|
||||
s += x.toInt()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun testUIntDownTo(a: UInt, b: UInt): Int {
|
||||
var s = 0
|
||||
for (x in a downTo b) {
|
||||
s += x.toInt()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
fun testULongDownTo(a: ULong, b: ULong): Int {
|
||||
var s = 0
|
||||
for (x in a downTo b) {
|
||||
s += x.toInt()
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// 0 iterator
|
||||
// 0 hasNext
|
||||
// 0 next
|
||||
@@ -1471,6 +1471,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInCharSequence.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInOptimizableUnsignedRange.kt")
|
||||
public void testForInOptimizableUnsignedRange() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInOptimizableUnsignedRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInRangeSpecializedToUntil.kt")
|
||||
public void testForInRangeSpecializedToUntil() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeSpecializedToUntil.kt");
|
||||
|
||||
@@ -1471,6 +1471,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
||||
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInCharSequence.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInOptimizableUnsignedRange.kt")
|
||||
public void testForInOptimizableUnsignedRange() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInOptimizableUnsignedRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("forInRangeSpecializedToUntil.kt")
|
||||
public void testForInRangeSpecializedToUntil() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeSpecializedToUntil.kt");
|
||||
|
||||
Reference in New Issue
Block a user