diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndices.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndices.kt index 8fae10a597e..22b6d3c0a02 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndices.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndices.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun test() { var sum = 0 for (i in arrayOf("", "", "", "").indices) { diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndicesIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndicesIR.kt deleted file mode 100644 index f9413cdc680..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndicesIR.kt +++ /dev/null @@ -1,19 +0,0 @@ -// TARGET_BACKEND: JVM_IR -fun test() { - var sum = 0 - for (i in arrayOf("", "", "", "").indices) { - sum += i - } -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 1 IF_ICMPGT -// 1 IF_ICMPLE -// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndices.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndices.kt index b3ace9719fc..2880b63cc07 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndices.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndices.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun test() { var sum = 0 for (i in intArrayOf(0, 0, 0, 0).indices) { @@ -14,5 +13,12 @@ fun test() { // 0 getEnd // 0 getFirst // 0 getLast + +// JVM_TEMPLATES // 1 IF_ICMPGE -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 1 IF_ICMPGT +// 1 IF_ICMPLE +// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndicesIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndicesIR.kt deleted file mode 100644 index 4c9359c7cd5..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndicesIR.kt +++ /dev/null @@ -1,19 +0,0 @@ -// TARGET_BACKEND: JVM_IR -fun test() { - var sum = 0 - for (i in intArrayOf(0, 0, 0, 0).indices) { - sum += i - } -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 1 IF_ICMPGT -// 1 IF_ICMPLE -// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConst.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConst.kt index 47c263ad6cf..e1c70c00dfb 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConst.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConst.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR const val N = 'Z' fun test(): Int { @@ -18,5 +17,10 @@ fun test(): Int { // 0 getFirst // 0 getLast // 0 getStep +// 1 IF + +// JVM_TEMPLATES // 1 IF_ICMPGT -// 1 IF \ No newline at end of file + +// JVM_IR_TEMPLATES +// 1 IF_ICMPLE \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConstIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConstIR.kt deleted file mode 100644 index 4733996e9be..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConstIR.kt +++ /dev/null @@ -1,22 +0,0 @@ -// TARGET_BACKEND: JVM_IR -const val N = 'Z' - -fun test(): Int { - var sum = 0 - for (i in 'A' .. N) { - sum += i.toInt() - } - return sum -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition). - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IF_ICMPLE -// 1 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConst.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConst.kt index bb07da6f11a..7b2d31d5bae 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConst.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConst.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR const val N = 42 fun test(): Int { @@ -18,5 +17,10 @@ fun test(): Int { // 0 getFirst // 0 getLast // 0 getStep +// 1 IF + +// JVM_TEMPLATES // 1 IF_ICMPGT -// 1 IF \ No newline at end of file + +// JVM_IR_TEMPLATES +// 1 IF_ICMPLE \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConstIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConstIR.kt deleted file mode 100644 index 9542bf8f770..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConstIR.kt +++ /dev/null @@ -1,22 +0,0 @@ -// TARGET_BACKEND: JVM_IR -const val N = 42 - -fun test(): Int { - var sum = 0 - for (i in 1 .. N) { - sum += i - } - return sum -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition). - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IF_ICMPLE -// 1 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConst.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConst.kt index 6fbfa6d2d7d..9f7e39a2beb 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConst.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConst.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR const val N = 42L fun test(): Long { @@ -18,8 +17,15 @@ fun test(): Long { // 0 getFirst // 0 getLast // 0 getStep -// 1 LCMP // 1 IFGT -// 1 IF // 0 L2I -// 0 I2L \ No newline at end of file +// 0 I2L + +// JVM_TEMPLATES +// 1 LCMP +// 1 IF + +// JVM_IR_TEMPLATES +// 2 LCMP +// 1 IFLE +// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConstIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConstIR.kt deleted file mode 100644 index 990f6579768..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConstIR.kt +++ /dev/null @@ -1,26 +0,0 @@ -// TARGET_BACKEND: JVM_IR -const val N = 42L - -fun test(): Long { - var sum = 0L - for (i in 1L .. N) { - sum += i - } - return sum -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 2 LCMP -// 1 IFGT -// 1 IFLE -// 2 IF -// 0 L2I -// 0 I2L \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt index e2424d670a5..ad1094e5ec6 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR object Host { const val M = 1 const val N = 4 @@ -21,5 +20,10 @@ fun test(): Int { // 0 getFirst // 0 getLast // 0 getStep +// 1 IF + +// JVM_TEMPLATES // 1 IF_ICMPGT -// 1 IF \ No newline at end of file + +// JVM_IR_TEMPLATES +// 1 IF_ICMPLE \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConstIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConstIR.kt deleted file mode 100644 index 402cdfc74d1..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConstIR.kt +++ /dev/null @@ -1,25 +0,0 @@ -// TARGET_BACKEND: JVM_IR -object Host { - const val M = 1 - const val N = 4 -} - -fun test(): Int { - var s = 0 - for (i in Host.M .. Host.N) { - s += i - } - return s -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition). - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IF_ICMPLE -// 1 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndices.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndices.kt index 57fc218c230..3313525e920 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndices.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndices.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR import kotlin.test.* fun box(): String { @@ -22,5 +21,12 @@ fun box(): String { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 1 IFLT -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 1 IF_ICMPGT +// 1 IF_ICMPLE +// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndicesIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndicesIR.kt deleted file mode 100644 index afabd225b71..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndicesIR.kt +++ /dev/null @@ -1,27 +0,0 @@ -// TARGET_BACKEND: JVM_IR -import kotlin.test.* - -fun box(): String { - val arr = intArrayOf(1, 1, 1, 1) - var sum = 0 - for (i in arr.indices.reversed()) { - sum = sum * 10 + i + arr[i] - } - assertEquals(4321, sum) - - return "OK" -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. - -// 0 reversed -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IF_ICMPGT -// 1 IF_ICMPLE -// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownTo.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownTo.kt index 7c413c816fc..137e2ec2f8a 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownTo.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownTo.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR import kotlin.test.* fun box(): String { @@ -33,7 +32,15 @@ fun box(): String { // 0 getFirst // 0 getLast // 0 getStep -// 2 IF_ICMPGT // 1 IFGT + +// JVM_TEMPLATES +// 2 IF_ICMPGT // 3 IF -// 1 LCMP \ No newline at end of file +// 1 LCMP + +// JVM_IR_TEMPLATES +// 2 IF_ICMPLE +// 1 IFLE +// 4 IF +// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownToIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownToIR.kt deleted file mode 100644 index 3f9cc896c2e..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownToIR.kt +++ /dev/null @@ -1,40 +0,0 @@ -// TARGET_BACKEND: JVM_IR -import kotlin.test.* - -fun box(): String { - var sum = 0 - for (i in (4 downTo 1).reversed()) { - sum = sum * 10 + i - } - assertEquals(1234, sum) - - var sumL = 0L - for (i in (4L downTo 1L).reversed()) { - sumL = sumL * 10 + i - } - assertEquals(1234L, sumL) - - var sumC = 0 - for (i in ('4' downTo '1').reversed()) { - sumC = sumC * 10 + i.toInt() - '0'.toInt() - } - assertEquals(1234, sumC) - - return "OK" -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition), except for Long. - -// 0 reversed -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 2 IF_ICMPLE -// 1 IFGT -// 1 IFLE -// 4 IF -// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteral.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteral.kt index 2c4ed6cda59..bcfb3376ca4 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteral.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteral.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR import kotlin.test.* fun box(): String { @@ -33,7 +32,16 @@ fun box(): String { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 2 IF_ICMPLT // 1 IFLT // 3 IF -// 1 LCMP \ No newline at end of file +// 1 LCMP + +// JVM_IR_TEMPLATES +// 2 IF_ICMPLE +// 1 IFGT +// 1 IFLE +// 4 IF +// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteralIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteralIR.kt deleted file mode 100644 index f428448ca5e..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteralIR.kt +++ /dev/null @@ -1,40 +0,0 @@ -// TARGET_BACKEND: JVM_IR -import kotlin.test.* - -fun box(): String { - var sum = 0 - for (i in (1 .. 4).reversed()) { - sum = sum * 10 + i - } - assertEquals(4321, sum) - - var sumL = 0L - for (i in (1L .. 4L).reversed()) { - sumL = sumL * 10 + i - } - assertEquals(4321L, sumL) - - var sumC = 0 - for (i in ('1' .. '4').reversed()) { - sumC = sumC * 10 + i.toInt() - '0'.toInt() - } - assertEquals(4321, sumC) - - return "OK" -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition), except for Long. - -// 0 reversed -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 2 IF_ICMPLE -// 1 IFGT -// 1 IFLE -// 4 IF -// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownTo.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownTo.kt index 8cb65b82f60..f157d325b33 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownTo.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownTo.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR import kotlin.test.* fun box(): String { @@ -33,7 +32,16 @@ fun box(): String { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 2 IF_ICMPLT // 1 IFLT // 3 IF -// 1 LCMP \ No newline at end of file +// 1 LCMP + +// JVM_IR_TEMPLATES +// 2 IF_ICMPLE +// 1 IFGT +// 1 IFLE +// 4 IF +// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownToIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownToIR.kt deleted file mode 100644 index 3322955e748..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownToIR.kt +++ /dev/null @@ -1,40 +0,0 @@ -// TARGET_BACKEND: JVM_IR -import kotlin.test.* - -fun box(): String { - var sum = 0 - for (i in (4 downTo 1).reversed().reversed()) { - sum = sum * 10 + i - } - assertEquals(1234, sum) - - var sumL = 0L - for (i in (4L downTo 1L).reversed().reversed()) { - sumL = sumL * 10 + i - } - assertEquals(1234L, sumL) - - var sumC = 0 - for (i in ('4' downTo '1').reversed().reversed()) { - sumC = sumC * 10 + i.toInt() - '0'.toInt() - } - assertEquals(1234, sumC) - - return "OK" -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition), except for Long. - -// 0 reversed -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 2 IF_ICMPLE -// 1 IFGT -// 1 IFLE -// 4 IF -// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntil.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntil.kt index 7cb02422f7a..b3a3740513a 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntil.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntil.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR import kotlin.test.* fun box(): String { @@ -30,7 +29,16 @@ fun box(): String { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 2 IF_ICMPGE // 1 IFGE // 3 IF -// 1 LCMP \ No newline at end of file +// 1 LCMP + +// JVM_IR_TEMPLATES +// 2 IF_ICMPLE +// 1 IFGT +// 1 IFLE +// 4 IF +// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntilIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntilIR.kt deleted file mode 100644 index ed009c4b4c0..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntilIR.kt +++ /dev/null @@ -1,37 +0,0 @@ -// TARGET_BACKEND: JVM_IR -import kotlin.test.* - -fun box(): String { - var sum = 0 - for (i in (1 until 5).reversed().reversed()) { - sum = sum * 10 + i - } - - var sumL = 0L - for (i in (1L until 5L).reversed().reversed()) { - sumL = sumL * 10 + i - } - - var sumC = 0 - for (i in ('1' until '5').reversed().reversed()) { - sumC = sumC * 10 + i.toInt() - '0'.toInt() - } - - return "OK" -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition), except for Long. - -// 0 reversed -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 2 IF_ICMPLE -// 1 IFGT -// 1 IFLE -// 4 IF -// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntil.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntil.kt index 4e335fd1478..a20da72c0d8 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntil.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntil.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR import kotlin.test.* fun box(): String { @@ -30,7 +29,16 @@ fun box(): String { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 2 IF_ICMPLT // 1 IFLT // 3 IF -// 1 LCMP \ No newline at end of file +// 1 LCMP + +// JVM_IR_TEMPLATES +// 2 IF_ICMPLE +// 1 IFGT +// 1 IFLE +// 4 IF +// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntilIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntilIR.kt deleted file mode 100644 index a33cc2541b3..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntilIR.kt +++ /dev/null @@ -1,37 +0,0 @@ -// TARGET_BACKEND: JVM_IR -import kotlin.test.* - -fun box(): String { - var sum = 0 - for (i in (1 until 5).reversed()) { - sum = sum * 10 + i - } - - var sumL = 0L - for (i in (1L until 5L).reversed()) { - sumL = sumL * 10 + i - } - - var sumC = 0 - for (i in ('1' until '5').reversed()) { - sumC = sumC * 10 + i.toInt() - '0'.toInt() - } - - return "OK" -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition), except for Long. - -// 0 reversed -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 2 IF_ICMPLE -// 1 IFGT -// 1 IFLE -// 4 IF -// 2 LCMP \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilChar.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilChar.kt index 70822f131f9..875a39f52ec 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilChar.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilChar.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun test(a: Char, b: Char): String { var s = "" for (i in a until b) { @@ -16,5 +15,13 @@ fun test(a: Char, b: Char): String { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 1 IF_ICMPGE -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 1 IFEQ +// 1 IF_ICMPGT +// 1 IF_ICMPLE +// 3 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharIR.kt deleted file mode 100644 index 42b70af688a..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharIR.kt +++ /dev/null @@ -1,22 +0,0 @@ -// TARGET_BACKEND: JVM_IR -fun test(a: Char, b: Char): String { - var s = "" - for (i in a until b) { - s += i - } - return s -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. In addition, for "until" progressions, there is a check that the range is not empty: upper bound != MIN_VALUE. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IFEQ -// 1 IF_ICMPGT -// 1 IF_ICMPLE -// 3 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValue.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValue.kt index f0908901f75..c0c6268dbc6 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValue.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValue.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR const val M = Char.MAX_VALUE fun f(a: Char): Int { @@ -18,5 +17,12 @@ fun f(a: Char): Int { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 1 IF_ICMPGE -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 1 IF_ICMPGT +// 1 IF_ICMPLE +// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValueIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValueIR.kt deleted file mode 100644 index f4585043343..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValueIR.kt +++ /dev/null @@ -1,23 +0,0 @@ -// TARGET_BACKEND: JVM_IR -const val M = Char.MAX_VALUE - -fun f(a: Char): Int { - var n = 0 - for (i in a until M) { - n++ - } - return n -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IF_ICMPGT -// 1 IF_ICMPLE -// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValueIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValue.kt similarity index 85% rename from compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValueIR.kt rename to compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValue.kt index 1a2c10f0bbc..808582c2be6 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValueIR.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValue.kt @@ -1,4 +1,3 @@ -// TARGET_BACKEND: JVM_IR const val M = Char.MIN_VALUE fun f(a: Char): Int { @@ -18,5 +17,10 @@ fun f(a: Char): Int { // 0 getFirst // 0 getLast // 0 getStep -// 0 IF -// 0 LINENUMBER 7 \ No newline at end of file +// 0 LINENUMBER 7 + +// JVM_TEMPLATES +// 1 IF + +// JVM_IR_TEMPLATES +// 0 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilInt.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilInt.kt index 43853e7fd4b..f48de2509b2 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilInt.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilInt.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun test(a: Int, b: Int): Int { var sum = 0 for (i in a until b) { @@ -16,5 +15,14 @@ fun test(a: Int, b: Int): Int { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 1 IF_ICMPGE -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 1 LDC -2147483648 +// 1 IF_ICMPEQ +// 1 IF_ICMPGT +// 1 IF_ICMPLE +// 3 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntIR.kt deleted file mode 100644 index 94920dd9f3c..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntIR.kt +++ /dev/null @@ -1,23 +0,0 @@ -// TARGET_BACKEND: JVM_IR -fun test(a: Int, b: Int): Int { - var sum = 0 - for (i in a until b) { - sum = sum * 10 + i - } - return sum -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. In addition, for "until" progressions, there is a check that the range is not empty: upper bound != MIN_VALUE. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 LDC -2147483648 -// 1 IF_ICMPEQ -// 1 IF_ICMPGT -// 1 IF_ICMPLE -// 3 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValue.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValue.kt index fb2a630b3e4..d5d4333f2d8 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValue.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValue.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR const val M = Int.MAX_VALUE fun f(a: Int): Int { @@ -18,5 +17,12 @@ fun f(a: Int): Int { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 1 IF_ICMPGE -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 1 IF_ICMPGT +// 1 IF_ICMPLE +// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValueIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValueIR.kt deleted file mode 100644 index 737347d6f4f..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValueIR.kt +++ /dev/null @@ -1,23 +0,0 @@ -// TARGET_BACKEND: JVM_IR -const val M = Int.MAX_VALUE - -fun f(a: Int): Int { - var n = 0 - for (i in a until M) { - n++ - } - return n -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IF_ICMPGT -// 1 IF_ICMPLE -// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValueIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValue.kt similarity index 85% rename from compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValueIR.kt rename to compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValue.kt index a51f01e502a..54e1d5cf10e 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValueIR.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValue.kt @@ -1,4 +1,3 @@ -// TARGET_BACKEND: JVM_IR const val M = Int.MIN_VALUE fun f(a: Int): Int { @@ -18,5 +17,10 @@ fun f(a: Int): Int { // 0 getFirst // 0 getLast // 0 getStep -// 0 IF -// 0 LINENUMBER 7 \ No newline at end of file +// 0 LINENUMBER 7 + +// JVM_TEMPLATES +// 1 IF + +// JVM_IR_TEMPLATES +// 0 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLong.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLong.kt index 789d8fedb8c..95ca727fe3a 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLong.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLong.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun test(a: Long, b: Long): Long { var sum = 0L for (i in a until b) { @@ -16,6 +15,16 @@ fun test(a: Long, b: Long): Long { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 1 LCMP // 1 IFGE -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 1 LDC -9223372036854775808 +// 3 LCMP +// 1 IFEQ +// 1 IFGT +// 1 IFLE +// 3 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongIR.kt deleted file mode 100644 index 117bb03bb18..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongIR.kt +++ /dev/null @@ -1,24 +0,0 @@ -// TARGET_BACKEND: JVM_IR -fun test(a: Long, b: Long): Long { - var sum = 0L - for (i in a until b) { - sum = sum * 10L + i - } - return sum -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. In addition, for "until" progressions, there is a check that the range is not empty: upper bound != MIN_VALUE. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 LDC -9223372036854775808 -// 3 LCMP -// 1 IFEQ -// 1 IFGT -// 1 IFLE -// 3 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValue.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValue.kt index feb6558d173..db5e5778da2 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValue.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValue.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR const val M = Long.MAX_VALUE fun f(a: Long): Int { @@ -18,6 +17,14 @@ fun f(a: Long): Int { // 0 getFirst // 0 getLast // 0 getStep + +// JVM_TEMPLATES // 1 LCMP // 1 IFGE -// 1 IF \ No newline at end of file +// 1 IF + +// JVM_IR_TEMPLATES +// 2 LCMP +// 1 IFGT +// 1 IFLE +// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValueIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValueIR.kt deleted file mode 100644 index efef772bfdd..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValueIR.kt +++ /dev/null @@ -1,24 +0,0 @@ -// TARGET_BACKEND: JVM_IR -const val M = Long.MAX_VALUE - -fun f(a: Long): Int { - var n = 0 - for (i in a until M) { - n++ - } - return n -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 2 LCMP -// 1 IFGT -// 1 IFLE -// 2 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValueIR.kt b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValue.kt similarity index 85% rename from compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValueIR.kt rename to compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValue.kt index 3a3063a3897..698e9735f93 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValueIR.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValue.kt @@ -1,4 +1,3 @@ -// TARGET_BACKEND: JVM_IR const val M = Long.MIN_VALUE fun f(a: Long): Int { @@ -18,5 +17,10 @@ fun f(a: Long): Int { // 0 getFirst // 0 getLast // 0 getStep -// 0 IF -// 0 LINENUMBER 7 \ No newline at end of file +// 0 LINENUMBER 7 + +// JVM_TEMPLATES +// 1 IF + +// JVM_IR_TEMPLATES +// 0 IF \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1.kt b/compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1.kt index 9a174007375..a4198855b28 100644 --- a/compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1.kt +++ b/compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR fun f() { for (i in 1..2) { } @@ -13,5 +12,10 @@ fun f() { // 0 getFirst // 0 getLast // 0 getStep +// 1 IF + +// JVM_TEMPLATES // 1 IF_ICMPGT -// 1 IF \ No newline at end of file + +// JVM_IR_TEMPLATES +// 1 IF_ICMPLE \ No newline at end of file diff --git a/compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1IR.kt b/compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1IR.kt deleted file mode 100644 index eb3978868d4..00000000000 --- a/compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1IR.kt +++ /dev/null @@ -1,17 +0,0 @@ -// TARGET_BACKEND: JVM_IR -fun f() { - for (i in 1..2) { - } -} - -// JVM non-IR uses while. -// JVM IR uses if + do-while. The surrounding "if" gets optimized in this test (constant condition). - -// 0 iterator -// 0 getStart -// 0 getEnd -// 0 getFirst -// 0 getLast -// 0 getStep -// 1 IF_ICMPLE -// 1 IF \ No newline at end of file diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt index 0cb92b0ed3d..1fa1164458e 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractBytecodeTextTest.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.codegen import com.intellij.openapi.util.text.StringUtil import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.InTextDirectivesUtils +import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TestJdkKind import org.junit.Assert import java.io.File @@ -30,7 +31,7 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() { } else { val expected = readExpectedOccurrences(wholeFile.path) val actual = generateToText("helpers/") - checkGeneratedTextAgainstExpectedOccurrences(actual, expected) + checkGeneratedTextAgainstExpectedOccurrences(actual, expected, getBackend()) } } @@ -45,25 +46,28 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() { assertTextWasGenerated(expectedOutputFile, generated) val generatedText = generated[expectedOutputFile]!! val expectedOccurrences = expectedOccurrencesByOutputFile[expectedOutputFile]!! - checkGeneratedTextAgainstExpectedOccurrences(generatedText, expectedOccurrences) + checkGeneratedTextAgainstExpectedOccurrences(generatedText, expectedOccurrences, getBackend()) } } protected fun readExpectedOccurrences(filename: String): List { val result = ArrayList() val lines = File(filename).readLines().dropLastWhile(String::isEmpty) - + var backend = TargetBackend.ANY for (line in lines) { + if (line.contains(JVM_TEMPLATES)) backend = TargetBackend.JVM + else if (line.contains(JVM_IR_TEMPLATES)) backend = TargetBackend.JVM_IR + val matcher = EXPECTED_OCCURRENCES_PATTERN.matcher(line) if (matcher.matches()) { - result.add(parseOccurrenceInfo(matcher)) + result.add(parseOccurrenceInfo(matcher, backend)) } } return result } - class OccurrenceInfo constructor(private val numberOfOccurrences: Int, private val needle: String) { + class OccurrenceInfo constructor(private val numberOfOccurrences: Int, private val needle: String, val backend: TargetBackend) { fun getActualOccurrence(text: String): String? { val actualCount = StringUtil.findMatches(text, Pattern.compile("($needle)")).size return "$actualCount $needle" @@ -88,13 +92,29 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() { return kotlinFiles > 1 } - fun checkGeneratedTextAgainstExpectedOccurrences(text: String, expectedOccurrences: List) { + fun checkGeneratedTextAgainstExpectedOccurrences(text: String, expectedOccurrences: List, currentBackend: TargetBackend) { val expected = StringBuilder() val actual = StringBuilder() - + var lastBackend = TargetBackend.ANY for (info in expectedOccurrences) { + if (lastBackend != info.backend) { + when (info.backend) { + TargetBackend.JVM -> JVM_TEMPLATES + TargetBackend.JVM_IR -> JVM_IR_TEMPLATES + else -> error("Common part should be first one: ${expectedOccurrences.joinToString("\n")}") + }.also { + actual.append("\n$it\n") + expected.append("\n$it\n") + } + lastBackend = info.backend + } + expected.append(info).append("\n") - actual.append(info.getActualOccurrence(text)).append("\n") + if (info.backend == TargetBackend.ANY || info.backend == currentBackend) { + actual.append(info.getActualOccurrence(text)).append("\n") + } else { + actual.append(info).append("\n") + } } try { @@ -117,9 +137,17 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() { } } + private const val JVM_TEMPLATES = "// JVM_TEMPLATES" + + private const val JVM_IR_TEMPLATES = "// JVM_IR_TEMPLATES" + private fun readExpectedOccurrencesForMultiFileTest(file: TestFile, occurrenceMap: MutableMap>) { var currentOccurrenceInfos: MutableList? = null + var backend = TargetBackend.ANY for (line in file.content.split("\n".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()) { + if (line.contains(JVM_TEMPLATES)) backend = TargetBackend.JVM + else if (line.contains(JVM_IR_TEMPLATES)) backend = TargetBackend.JVM_IR + val atOutputFileMatcher = AT_OUTPUT_FILE_PATTERN.matcher(line) if (atOutputFileMatcher.matches()) { val outputFileName = atOutputFileMatcher.group(1) @@ -135,16 +163,20 @@ abstract class AbstractBytecodeTextTest : CodegenTestCase() { if (currentOccurrenceInfos == null) { throw AssertionError("${file.name}: Should specify output file with '// @:' before expectations") } - val occurrenceInfo = parseOccurrenceInfo(expectedOccurrencesMatcher) + val occurrenceInfo = parseOccurrenceInfo(expectedOccurrencesMatcher, backend) currentOccurrenceInfos.add(occurrenceInfo) } } } - private fun parseOccurrenceInfo(matcher: Matcher): OccurrenceInfo { + private fun parseOccurrenceInfo(matcher: Matcher, backend: TargetBackend): OccurrenceInfo { val numberOfOccurrences = Integer.parseInt(matcher.group(1)) val needle = matcher.group(2) - return OccurrenceInfo(numberOfOccurrences, needle) + return OccurrenceInfo(numberOfOccurrences, needle, backend) } } + + protected open fun getBackend(): TargetBackend { + return TargetBackend.JVM + } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java index b531acccacf..991ff4f8370 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/AbstractTopLevelMembersInvocationTest.java @@ -23,10 +23,7 @@ import kotlin.sequences.SequencesKt; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles; import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment; -import org.jetbrains.kotlin.test.CompilerTestUtil; -import org.jetbrains.kotlin.test.ConfigurationKind; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.TestJdkKind; +import org.jetbrains.kotlin.test.*; import java.io.File; import java.util.Collections; @@ -62,6 +59,6 @@ public abstract class AbstractTopLevelMembersInvocationTest extends AbstractByte List expected = readExpectedOccurrences(KotlinTestUtils.getTestDataPathBase() + "/codegen/" + sourceFiles.get(0)); String actual = generateToText(); - Companion.checkGeneratedTextAgainstExpectedOccurrences(actual, expected); + Companion.checkGeneratedTextAgainstExpectedOccurrences(actual, expected, TargetBackend.ANY); } } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBytecodeTextTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBytecodeTextTest.kt index 90fb92200c8..ed07c4bc0d2 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBytecodeTextTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/codegen/ir/AbstractIrBytecodeTextTest.kt @@ -8,7 +8,12 @@ package org.jetbrains.kotlin.codegen.ir import org.jetbrains.kotlin.codegen.AbstractBytecodeTextTest import org.jetbrains.kotlin.config.CompilerConfiguration import org.jetbrains.kotlin.config.JVMConfigurationKeys +import org.jetbrains.kotlin.test.TargetBackend abstract class AbstractIrBytecodeTextTest : AbstractBytecodeTextTest() { override fun updateConfiguration(configuration: CompilerConfiguration) = configuration.put(JVMConfigurationKeys.IR, true) + + override fun getBackend(): TargetBackend { + return TargetBackend.JVM_IR + } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index 7d28e3aea50..869913f20ce 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -2082,6 +2082,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValue.kt"); } + @TestMetadata("forInUntilCharMinValue.kt") + public void testForInUntilCharMinValue() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValue.kt"); + } + @TestMetadata("forInUntilInt.kt") public void testForInUntilInt() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilInt.kt"); @@ -2092,6 +2097,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValue.kt"); } + @TestMetadata("forInUntilIntMinValue.kt") + public void testForInUntilIntMinValue() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValue.kt"); + } + @TestMetadata("forInUntilLong.kt") public void testForInUntilLong() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLong.kt"); @@ -2101,6 +2111,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { public void testForInUntilLongMaxValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValue.kt"); } + + @TestMetadata("forInUntilLongMinValue.kt") + public void testForInUntilLongMinValue() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValue.kt"); + } } } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index e2ff74f0e00..3bcbe847b0a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -1657,11 +1657,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConst.kt"); } - @TestMetadata("forInRangeToCharConstIR.kt") - public void testForInRangeToCharConstIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharConstIR.kt"); - } - @TestMetadata("forInRangeToCharMaxValue.kt") public void testForInRangeToCharMaxValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToCharMaxValue.kt"); @@ -1672,11 +1667,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConst.kt"); } - @TestMetadata("forInRangeToConstIR.kt") - public void testForInRangeToConstIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToConstIR.kt"); - } - @TestMetadata("forInRangeToIntMaxValue.kt") public void testForInRangeToIntMaxValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToIntMaxValue.kt"); @@ -1687,11 +1677,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConst.kt"); } - @TestMetadata("forInRangeToLongConstIR.kt") - public void testForInRangeToLongConstIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongConstIR.kt"); - } - @TestMetadata("forInRangeToLongMaxValue.kt") public void testForInRangeToLongMaxValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToLongMaxValue.kt"); @@ -1702,11 +1687,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConst.kt"); } - @TestMetadata("forInRangeToQualifiedConstIR.kt") - public void testForInRangeToQualifiedConstIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeToQualifiedConstIR.kt"); - } - @TestMetadata("forInRangeWithImplicitReceiver.kt") public void testForInRangeWithImplicitReceiver() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInRangeWithImplicitReceiver.kt"); @@ -1737,11 +1717,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1.kt"); } - @TestMetadata("primitiveLiteralRange1IR.kt") - public void testPrimitiveLiteralRange1IR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange1IR.kt"); - } - @TestMetadata("primitiveLiteralRange2.kt") public void testPrimitiveLiteralRange2() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/primitiveLiteralRange2.kt"); @@ -1875,20 +1850,10 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndices.kt"); } - @TestMetadata("forInObjectArrayIndicesIR.kt") - public void testForInObjectArrayIndicesIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInObjectArrayIndicesIR.kt"); - } - @TestMetadata("forInPrimitiveArrayIndices.kt") public void testForInPrimitiveArrayIndices() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndices.kt"); } - - @TestMetadata("forInPrimitiveArrayIndicesIR.kt") - public void testForInPrimitiveArrayIndicesIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInIndices/forInPrimitiveArrayIndicesIR.kt"); - } } @TestMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInIterableWithIndex") @@ -1946,11 +1911,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndices.kt"); } - @TestMetadata("forInReversedArrayIndicesIR.kt") - public void testForInReversedArrayIndicesIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedArrayIndicesIR.kt"); - } - @TestMetadata("forInReversedCharSequenceIndices.kt") public void testForInReversedCharSequenceIndices() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedCharSequenceIndices.kt"); @@ -1966,11 +1926,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownTo.kt"); } - @TestMetadata("forInReversedDownToIR.kt") - public void testForInReversedDownToIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedDownToIR.kt"); - } - @TestMetadata("forInReversedEmptyRangeLiteral.kt") public void testForInReversedEmptyRangeLiteral() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedEmptyRangeLiteral.kt"); @@ -1986,11 +1941,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteral.kt"); } - @TestMetadata("forInReversedRangeLiteralIR.kt") - public void testForInReversedRangeLiteralIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedRangeLiteralIR.kt"); - } - @TestMetadata("forInReversedReversedArrayIndices.kt") public void testForInReversedReversedArrayIndices() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedArrayIndices.kt"); @@ -2001,11 +1951,6 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownTo.kt"); } - @TestMetadata("forInReversedReversedDownToIR.kt") - public void testForInReversedReversedDownToIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedDownToIR.kt"); - } - @TestMetadata("ForInReversedReversedRange.kt") public void testForInReversedReversedRange() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/ForInReversedReversedRange.kt"); @@ -2021,20 +1966,10 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntil.kt"); } - @TestMetadata("forInReversedReversedUntilIR.kt") - public void testForInReversedReversedUntilIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedReversedUntilIR.kt"); - } - @TestMetadata("forInReversedUntil.kt") public void testForInReversedUntil() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntil.kt"); } - - @TestMetadata("forInReversedUntilIR.kt") - public void testForInReversedUntilIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInReversed/forInReversedUntilIR.kt"); - } } @TestMetadata("compiler/testData/codegen/bytecodeText/forLoop/forInSequenceWithIndex") @@ -2097,24 +2032,14 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilChar.kt"); } - @TestMetadata("forInUntilCharIR.kt") - public void testForInUntilCharIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharIR.kt"); - } - @TestMetadata("forInUntilCharMaxValue.kt") public void testForInUntilCharMaxValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValue.kt"); } - @TestMetadata("forInUntilCharMaxValueIR.kt") - public void testForInUntilCharMaxValueIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMaxValueIR.kt"); - } - - @TestMetadata("forInUntilCharMinValueIR.kt") - public void testForInUntilCharMinValueIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValueIR.kt"); + @TestMetadata("forInUntilCharMinValue.kt") + public void testForInUntilCharMinValue() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilCharMinValue.kt"); } @TestMetadata("forInUntilInt.kt") @@ -2122,24 +2047,14 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilInt.kt"); } - @TestMetadata("forInUntilIntIR.kt") - public void testForInUntilIntIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntIR.kt"); - } - @TestMetadata("forInUntilIntMaxValue.kt") public void testForInUntilIntMaxValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValue.kt"); } - @TestMetadata("forInUntilIntMaxValueIR.kt") - public void testForInUntilIntMaxValueIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMaxValueIR.kt"); - } - - @TestMetadata("forInUntilIntMinValueIR.kt") - public void testForInUntilIntMinValueIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValueIR.kt"); + @TestMetadata("forInUntilIntMinValue.kt") + public void testForInUntilIntMinValue() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilIntMinValue.kt"); } @TestMetadata("forInUntilLong.kt") @@ -2147,24 +2062,14 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLong.kt"); } - @TestMetadata("forInUntilLongIR.kt") - public void testForInUntilLongIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongIR.kt"); - } - @TestMetadata("forInUntilLongMaxValue.kt") public void testForInUntilLongMaxValue() throws Exception { runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValue.kt"); } - @TestMetadata("forInUntilLongMaxValueIR.kt") - public void testForInUntilLongMaxValueIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMaxValueIR.kt"); - } - - @TestMetadata("forInUntilLongMinValueIR.kt") - public void testForInUntilLongMinValueIR() throws Exception { - runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValueIR.kt"); + @TestMetadata("forInUntilLongMinValue.kt") + public void testForInUntilLongMinValue() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/forLoop/forInUntil/forInUntilLongMinValue.kt"); } @TestMetadata("forInUntilWithMixedTypeBoundsBoundCheckNeededForIntRangeIR.kt")