From 25da0378680fcc8bc7fe2eb5b5538424c3339b2d Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 29 Oct 2015 22:25:40 +0300 Subject: [PATCH] Update range iteration tests and regenerate test data. --- .../ranges/expression/emptyDownto.kt | 8 +-- .../ranges/expression/emptyRange.kt | 8 +-- .../expression/inexactDownToMinValue.kt | 8 +-- .../ranges/expression/inexactSteppedDownTo.kt | 8 +-- .../ranges/expression/inexactSteppedRange.kt | 8 +-- .../ranges/expression/inexactToMaxValue.kt | 8 +-- .../expression/maxValueMinusTwoToMaxValue.kt | 8 +-- .../ranges/expression/maxValueToMaxValue.kt | 8 +-- .../ranges/expression/maxValueToMinValue.kt | 8 +-- .../ranges/expression/oneElementDownTo.kt | 8 +-- .../ranges/expression/oneElementRange.kt | 8 +-- .../ranges/expression/openRange.kt | 8 +-- .../expression/progressionDownToMinValue.kt | 8 +-- .../progressionMaxValueMinusTwoToMaxValue.kt | 8 +-- .../progressionMaxValueToMaxValue.kt | 8 +-- .../progressionMaxValueToMinValue.kt | 8 +-- .../progressionMinValueToMinValue.kt | 8 +-- .../ranges/expression/reversedBackSequence.kt | 8 +-- .../expression/reversedEmptyBackSequence.kt | 8 +-- .../ranges/expression/reversedEmptyRange.kt | 8 +-- .../reversedInexactSteppedDownTo.kt | 8 +-- .../ranges/expression/reversedRange.kt | 50 ++++++------- .../expression/reversedSimpleSteppedRange.kt | 8 +-- .../ranges/expression/simpleDownTo.kt | 8 +-- .../ranges/expression/simpleRange.kt | 8 +-- .../simpleRangeWithNonConstantEnds.kt | 8 +-- .../ranges/expression/simpleSteppedDownTo.kt | 8 +-- .../ranges/expression/simpleSteppedRange.kt | 8 +-- .../ranges/literal/emptyDownto.kt | 8 +-- .../ranges/literal/emptyRange.kt | 8 +-- .../ranges/literal/inexactDownToMinValue.kt | 8 +-- .../ranges/literal/inexactSteppedDownTo.kt | 8 +-- .../ranges/literal/inexactSteppedRange.kt | 8 +-- .../ranges/literal/inexactToMaxValue.kt | 8 +-- .../literal/maxValueMinusTwoToMaxValue.kt | 8 +-- .../ranges/literal/maxValueToMaxValue.kt | 8 +-- .../ranges/literal/maxValueToMinValue.kt | 8 +-- .../ranges/literal/oneElementDownTo.kt | 8 +-- .../ranges/literal/oneElementRange.kt | 8 +-- .../boxWithStdlib/ranges/literal/openRange.kt | 8 +-- .../literal/progressionDownToMinValue.kt | 8 +-- .../progressionMaxValueMinusTwoToMaxValue.kt | 8 +-- .../literal/progressionMaxValueToMaxValue.kt | 8 +-- .../literal/progressionMaxValueToMinValue.kt | 8 +-- .../literal/progressionMinValueToMinValue.kt | 8 +-- .../ranges/literal/reversedBackSequence.kt | 8 +-- .../literal/reversedEmptyBackSequence.kt | 8 +-- .../ranges/literal/reversedEmptyRange.kt | 8 +-- .../literal/reversedInexactSteppedDownTo.kt | 8 +-- .../ranges/literal/reversedRange.kt | 49 ++++++------- .../literal/reversedSimpleSteppedRange.kt | 8 +-- .../ranges/literal/simpleDownTo.kt | 8 +-- .../ranges/literal/simpleRange.kt | 8 +-- .../literal/simpleRangeWithNonConstantEnds.kt | 8 +-- .../ranges/literal/simpleSteppedDownTo.kt | 8 +-- .../ranges/literal/simpleSteppedRange.kt | 8 +-- .../tests/GenerateRangesCodegenTestData.java | 7 +- .../test/language/RangeIterationJVMTest.kt | 40 +++++------ .../test/language/RangeIterationTest.kt | 72 +++++++++---------- libraries/stdlib/test/language/RangeTest.kt | 6 +- 60 files changed, 318 insertions(+), 338 deletions(-) diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt index f9adcee76dc..637c09177f1 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 5 downTo 10: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 5.toByte() downTo 10.toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for 5.toByte() downTo 10.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 5.toShort() downTo 10.toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for 5.toShort() downTo 10.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt index 50cbfbd0dcb..7549218361b 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 10..5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 10.toByte()..(-5).toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for 10.toByte()..(-5).toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 10.toShort()..(-5).toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for 10.toShort()..(-5).toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt index 4ed6d550031..740fd42a6b6 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactDownToMinValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for (MinI + 5) downTo MinI step 3: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (MinB + 5).toByte() downTo MinB step 3 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MinB + 5).toByte(), (MinB + 2).toByte())) { + if (list2 != listOf((MinB + 5).toInt(), (MinB + 2).toInt())) { return "Wrong elements for (MinB + 5).toByte() downTo MinB step 3: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (MinS + 5).toShort() downTo MinS step 3 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MinS + 5).toShort(), (MinS + 2).toShort())) { + if (list3 != listOf((MinS + 5).toInt(), (MinS + 2).toInt())) { return "Wrong elements for (MinS + 5).toShort() downTo MinS step 3: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt index 394f917c912..9b07f4bd9df 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 8 downTo 3 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 8.toByte() downTo 3.toByte() step 2 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(8, 6, 4)) { + if (list2 != listOf(8, 6, 4)) { return "Wrong elements for 8.toByte() downTo 3.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 8.toShort() downTo 3.toShort() step 2 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(8, 6, 4)) { + if (list3 != listOf(8, 6, 4)) { return "Wrong elements for 8.toShort() downTo 3.toShort() step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt index 405bb3b4319..fb1d2abb0f2 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 3..8 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 3.toByte()..8.toByte() step 2 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 5, 7)) { + if (list2 != listOf(3, 5, 7)) { return "Wrong elements for 3.toByte()..8.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 3.toShort()..8.toShort() step 2 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 5, 7)) { + if (list3 != listOf(3, 5, 7)) { return "Wrong elements for 3.toShort()..8.toShort() step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt index a8ca4cb6884..d0f9d59d35b 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactToMaxValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for (MaxI - 5)..MaxI step 3: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (MaxB - 5).toByte()..MaxB step 3 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MaxB - 5).toByte(), (MaxB - 2).toByte())) { + if (list2 != listOf((MaxB - 5).toInt(), (MaxB - 2).toInt())) { return "Wrong elements for (MaxB - 5).toByte()..MaxB step 3: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (MaxS - 5).toShort()..MaxS step 3 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MaxS - 5).toShort(), (MaxS - 2).toShort())) { + if (list3 != listOf((MaxS - 5).toInt(), (MaxS - 2).toInt())) { return "Wrong elements for (MaxS - 5).toShort()..MaxS step 3: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt index 669d851579b..9de7a0aa15c 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for (MaxI - 2)..MaxI: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (MaxB - 2).toByte()..MaxB for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MaxB - 2).toByte(), (MaxB - 1).toByte(), MaxB)) { + if (list2 != listOf((MaxB - 2).toInt(), (MaxB - 1).toInt(), MaxB.toInt())) { return "Wrong elements for (MaxB - 2).toByte()..MaxB: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (MaxS - 2).toShort()..MaxS for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MaxS - 2).toShort(), (MaxS - 1).toShort(), MaxS)) { + if (list3 != listOf((MaxS - 2).toInt(), (MaxS - 1).toInt(), MaxS.toInt())) { return "Wrong elements for (MaxS - 2).toShort()..MaxS: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMaxValue.kt index 2a5c2a7e6e4..e3f134fdff7 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMaxValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for MaxI..MaxI: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = MaxB..MaxB for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(MaxB)) { + if (list2 != listOf(MaxB.toInt())) { return "Wrong elements for MaxB..MaxB: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = MaxS..MaxS for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(MaxS)) { + if (list3 != listOf(MaxS.toInt())) { return "Wrong elements for MaxS..MaxS: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMinValue.kt index 3d3c9672c7f..bcccb05d702 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueToMinValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for MaxI..MinI: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = MaxB..MinB for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for MaxB..MinB: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = MaxS..MinS for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for MaxS..MinS: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt index 6a83e45ef2f..abf9a992895 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 5 downTo 5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 5.toByte() downTo 5.toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(5.toByte())) { + if (list2 != listOf(5)) { return "Wrong elements for 5.toByte() downTo 5.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 5.toShort() downTo 5.toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(5.toShort())) { + if (list3 != listOf(5)) { return "Wrong elements for 5.toShort() downTo 5.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt index b3aef7205ed..750eba6d150 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 5..5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 5.toByte()..5.toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(5.toByte())) { + if (list2 != listOf(5)) { return "Wrong elements for 5.toByte()..5.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 5.toShort()..5.toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(5.toShort())) { + if (list3 != listOf(5)) { return "Wrong elements for 5.toShort()..5.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/openRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/openRange.kt index d89edd60435..566db585bab 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/openRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/openRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 1 until 5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 1.toByte() until 5.toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(1, 2, 3, 4)) { + if (list2 != listOf(1, 2, 3, 4)) { return "Wrong elements for 1.toByte() until 5.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 1.toShort() until 5.toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(1, 2, 3, 4)) { + if (list3 != listOf(1, 2, 3, 4)) { return "Wrong elements for 1.toShort() until 5.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt index e7e5927b7e0..af49d2370e3 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionDownToMinValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for (MinI + 2) downTo MinI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (MinB + 2).toByte() downTo MinB step 1 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MinB + 2).toByte(), (MinB + 1).toByte(), MinB)) { + if (list2 != listOf((MinB + 2).toInt(), (MinB + 1).toInt(), MinB.toInt())) { return "Wrong elements for (MinB + 2).toByte() downTo MinB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (MinS + 2).toShort() downTo MinS step 1 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MinS + 2).toShort(), (MinS + 1).toShort(), MinS)) { + if (list3 != listOf((MinS + 2).toInt(), (MinS + 1).toInt(), MinS.toInt())) { return "Wrong elements for (MinS + 2).toShort() downTo MinS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt index f97b407a714..dbbae7a1001 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for (MaxI - 2)..MaxI step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (MaxB - 2).toByte()..MaxB step 2 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MaxB - 2).toByte(), MaxB)) { + if (list2 != listOf((MaxB - 2).toInt(), MaxB.toInt())) { return "Wrong elements for (MaxB - 2).toByte()..MaxB step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (MaxS - 2).toShort()..MaxS step 2 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MaxS - 2).toShort(), MaxS)) { + if (list3 != listOf((MaxS - 2).toInt(), MaxS.toInt())) { return "Wrong elements for (MaxS - 2).toShort()..MaxS step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMaxValue.kt index 427154cd798..c5d0ffe5016 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMaxValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for MaxI..MaxI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = MaxB..MaxB step 1 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(MaxB)) { + if (list2 != listOf(MaxB.toInt())) { return "Wrong elements for MaxB..MaxB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = MaxS..MaxS step 1 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(MaxS)) { + if (list3 != listOf(MaxS.toInt())) { return "Wrong elements for MaxS..MaxS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMinValue.kt index 1e613013174..6a65378c225 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMaxValueToMinValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for MaxI..MinI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = MaxB..MinB step 1 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for MaxB..MinB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = MaxS..MinS step 1 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for MaxS..MinS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMinValueToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMinValueToMinValue.kt index 2717c0dda96..69e74095195 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMinValueToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/progressionMinValueToMinValue.kt @@ -23,23 +23,23 @@ fun box(): String { return "Wrong elements for MinI..MinI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = MinB..MinB step 1 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(MinB)) { + if (list2 != listOf(MinB.toInt())) { return "Wrong elements for MinB..MinB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = MinS..MinS step 1 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(MinS)) { + if (list3 != listOf(MinS.toInt())) { return "Wrong elements for MinS..MinS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt index c4b5826c7a0..f0349e65ce5 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for (5 downTo 3).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (5.toByte() downTo 3.toByte()).reversed() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 4, 5)) { + if (list2 != listOf(3, 4, 5)) { return "Wrong elements for (5.toByte() downTo 3.toByte()).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (5.toShort() downTo 3.toShort()).reversed() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 4, 5)) { + if (list3 != listOf(3, 4, 5)) { return "Wrong elements for (5.toShort() downTo 3.toShort()).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt index c2d404693be..b61d3da2b38 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for (3 downTo 5).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (3.toByte() downTo 5.toByte()).reversed() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for (3.toByte() downTo 5.toByte()).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (3.toShort() downTo 5.toShort()).reversed() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for (3.toShort() downTo 5.toShort()).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt index 24d64f2d559..b6efbc34be7 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for (5..3).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (5.toByte()..3.toByte()).reversed() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for (5.toByte()..3.toByte()).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (5.toShort()..3.toShort()).reversed() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for (5.toShort()..3.toShort()).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedInexactSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedInexactSteppedDownTo.kt index c978600e86a..88c80796961 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedInexactSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedInexactSteppedDownTo.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for (8 downTo 3 step 2).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (8.toByte() downTo 3.toByte() step 2).reversed() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 5, 7)) { + if (list2 != listOf(3, 5, 7)) { return "Wrong elements for (8.toByte() downTo 3.toByte() step 2).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (8.toShort() downTo 3.toShort() step 2).reversed() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 5, 7)) { + if (list3 != listOf(3, 5, 7)) { return "Wrong elements for (8.toShort() downTo 3.toShort() step 2).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt index 5354a46ada4..57a87bcdb48 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt @@ -12,64 +12,54 @@ fun box(): String { return "Wrong elements for (3..5).reversed(): $list1" } - val list2 = ArrayList() - val range2 = (3.toByte()..5.toByte()).reversed() + val list2 = ArrayList() + val range2 = (3.toShort()..5.toShort()).reversed() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(5, 4, 3)) { - return "Wrong elements for (3.toByte()..5.toByte()).reversed(): $list2" + if (list2 != listOf(5, 4, 3)) { + return "Wrong elements for (3.toShort()..5.toShort()).reversed(): $list2" } - val list3 = ArrayList() - val range3 = (3.toShort()..5.toShort()).reversed() + val list3 = ArrayList() + val range3 = (3.toLong()..5.toLong()).reversed() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(5, 4, 3)) { - return "Wrong elements for (3.toShort()..5.toShort()).reversed(): $list3" + if (list3 != listOf(5, 4, 3)) { + return "Wrong elements for (3.toLong()..5.toLong()).reversed(): $list3" } - val list4 = ArrayList() - val range4 = (3.toLong()..5.toLong()).reversed() + val list4 = ArrayList() + val range4 = ('a'..'c').reversed() for (i in range4) { list4.add(i) if (list4.size() > 23) break } - if (list4 != listOf(5, 4, 3)) { - return "Wrong elements for (3.toLong()..5.toLong()).reversed(): $list4" + if (list4 != listOf('c', 'b', 'a')) { + return "Wrong elements for ('a'..'c').reversed(): $list4" } - val list5 = ArrayList() - val range5 = ('a'..'c').reversed() + val list5 = ArrayList() + val range5 = (3.0..5.0).reversed() for (i in range5) { list5.add(i) if (list5.size() > 23) break } - if (list5 != listOf('c', 'b', 'a')) { - return "Wrong elements for ('a'..'c').reversed(): $list5" + if (list5 != listOf(5.0, 4.0, 3.0)) { + return "Wrong elements for (3.0..5.0).reversed(): $list5" } - val list6 = ArrayList() - val range6 = (3.0..5.0).reversed() + val list6 = ArrayList() + val range6 = (3.0.toFloat()..5.0.toFloat()).reversed() for (i in range6) { list6.add(i) if (list6.size() > 23) break } - if (list6 != listOf(5.0, 4.0, 3.0)) { - return "Wrong elements for (3.0..5.0).reversed(): $list6" - } - - val list7 = ArrayList() - val range7 = (3.0.toFloat()..5.0.toFloat()).reversed() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) { - return "Wrong elements for (3.0.toFloat()..5.0.toFloat()).reversed(): $list7" + if (list6 != listOf(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) { + return "Wrong elements for (3.0.toFloat()..5.0.toFloat()).reversed(): $list6" } return "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedSimpleSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedSimpleSteppedRange.kt index 2cfc2563a57..30e122e374a 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedSimpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedSimpleSteppedRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for (3..9 step 2).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (3.toByte()..9.toByte() step 2).reversed() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(9, 7, 5, 3)) { + if (list2 != listOf(9, 7, 5, 3)) { return "Wrong elements for (3.toByte()..9.toByte() step 2).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (3.toShort()..9.toShort() step 2).reversed() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(9, 7, 5, 3)) { + if (list3 != listOf(9, 7, 5, 3)) { return "Wrong elements for (3.toShort()..9.toShort() step 2).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt index e7bea87bb83..f0a29bd586a 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 9 downTo 3: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 9.toByte() downTo 3.toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(9, 8, 7, 6, 5, 4, 3)) { + if (list2 != listOf(9, 8, 7, 6, 5, 4, 3)) { return "Wrong elements for 9.toByte() downTo 3.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 9.toShort() downTo 3.toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(9, 8, 7, 6, 5, 4, 3)) { + if (list3 != listOf(9, 8, 7, 6, 5, 4, 3)) { return "Wrong elements for 9.toShort() downTo 3.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt index 76ca8d67a44..5cfc11b85db 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 3..9: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 3.toByte()..9.toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for 3.toByte()..9.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 3.toShort()..9.toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for 3.toShort()..9.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt index eab200b697e..b8bb43b8b25 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for (1 + 2)..(10 - 1): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte() for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort() for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt index 051adb337d4..2c648718ab1 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 9 downTo 3 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 9.toByte() downTo 3.toByte() step 2 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(9, 7, 5, 3)) { + if (list2 != listOf(9, 7, 5, 3)) { return "Wrong elements for 9.toByte() downTo 3.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 9.toShort() downTo 3.toShort() step 2 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(9, 7, 5, 3)) { + if (list3 != listOf(9, 7, 5, 3)) { return "Wrong elements for 9.toShort() downTo 3.toShort() step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt index 3c6e368e37b..cec06e72f0e 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt @@ -12,23 +12,23 @@ fun box(): String { return "Wrong elements for 3..9 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() val range2 = 3.toByte()..9.toByte() step 2 for (i in range2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 5, 7, 9)) { + if (list2 != listOf(3, 5, 7, 9)) { return "Wrong elements for 3.toByte()..9.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() val range3 = 3.toShort()..9.toShort() step 2 for (i in range3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 5, 7, 9)) { + if (list3 != listOf(3, 5, 7, 9)) { return "Wrong elements for 3.toShort()..9.toShort() step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt index 3d08f8ba9a3..c13e2e10e6f 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 5 downTo 10: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 5.toByte() downTo 10.toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for 5.toByte() downTo 10.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 5.toShort() downTo 10.toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for 5.toShort() downTo 10.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt index b6b4f6c9b88..22caea4311d 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 10..5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 10.toByte()..(-5).toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for 10.toByte()..(-5).toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 10.toShort()..(-5).toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for 10.toShort()..(-5).toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt index 3305e36037f..6c65bf4852d 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactDownToMinValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for (MinI + 5) downTo MinI step 3: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (MinB + 5).toByte() downTo MinB step 3) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MinB + 5).toByte(), (MinB + 2).toByte())) { + if (list2 != listOf((MinB + 5).toInt(), (MinB + 2).toInt())) { return "Wrong elements for (MinB + 5).toByte() downTo MinB step 3: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (MinS + 5).toShort() downTo MinS step 3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MinS + 5).toShort(), (MinS + 2).toShort())) { + if (list3 != listOf((MinS + 5).toInt(), (MinS + 2).toInt())) { return "Wrong elements for (MinS + 5).toShort() downTo MinS step 3: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt index 8e83a2eb977..6b7476edb8a 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 8 downTo 3 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 8.toByte() downTo 3.toByte() step 2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(8, 6, 4)) { + if (list2 != listOf(8, 6, 4)) { return "Wrong elements for 8.toByte() downTo 3.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 8.toShort() downTo 3.toShort() step 2) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(8, 6, 4)) { + if (list3 != listOf(8, 6, 4)) { return "Wrong elements for 8.toShort() downTo 3.toShort() step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt index f384e0fce8b..3e49bb2a685 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 3..8 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 3.toByte()..8.toByte() step 2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 5, 7)) { + if (list2 != listOf(3, 5, 7)) { return "Wrong elements for 3.toByte()..8.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 3.toShort()..8.toShort() step 2) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 5, 7)) { + if (list3 != listOf(3, 5, 7)) { return "Wrong elements for 3.toShort()..8.toShort() step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt index a76bec48e96..eca8fea6bb0 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactToMaxValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for (MaxI - 5)..MaxI step 3: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (MaxB - 5).toByte()..MaxB step 3) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MaxB - 5).toByte(), (MaxB - 2).toByte())) { + if (list2 != listOf((MaxB - 5).toInt(), (MaxB - 2).toInt())) { return "Wrong elements for (MaxB - 5).toByte()..MaxB step 3: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (MaxS - 5).toShort()..MaxS step 3) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MaxS - 5).toShort(), (MaxS - 2).toShort())) { + if (list3 != listOf((MaxS - 5).toInt(), (MaxS - 2).toInt())) { return "Wrong elements for (MaxS - 5).toShort()..MaxS step 3: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt index 669b031a4db..e800248bbb2 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for (MaxI - 2)..MaxI: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (MaxB - 2).toByte()..MaxB) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MaxB - 2).toByte(), (MaxB - 1).toByte(), MaxB)) { + if (list2 != listOf((MaxB - 2).toInt(), (MaxB - 1).toInt(), MaxB.toInt())) { return "Wrong elements for (MaxB - 2).toByte()..MaxB: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (MaxS - 2).toShort()..MaxS) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MaxS - 2).toShort(), (MaxS - 1).toShort(), MaxS)) { + if (list3 != listOf((MaxS - 2).toInt(), (MaxS - 1).toInt(), MaxS.toInt())) { return "Wrong elements for (MaxS - 2).toShort()..MaxS: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMaxValue.kt index 30caebd8074..9649e40335a 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMaxValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for MaxI..MaxI: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in MaxB..MaxB) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(MaxB)) { + if (list2 != listOf(MaxB.toInt())) { return "Wrong elements for MaxB..MaxB: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in MaxS..MaxS) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(MaxS)) { + if (list3 != listOf(MaxS.toInt())) { return "Wrong elements for MaxS..MaxS: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMinValue.kt index 4236c2de0e1..0e0fdc506d2 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueToMinValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for MaxI..MinI: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in MaxB..MinB) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for MaxB..MinB: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in MaxS..MinS) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for MaxS..MinS: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt index db2040ad363..10618967b4b 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 5 downTo 5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 5.toByte() downTo 5.toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(5.toByte())) { + if (list2 != listOf(5)) { return "Wrong elements for 5.toByte() downTo 5.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 5.toShort() downTo 5.toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(5.toShort())) { + if (list3 != listOf(5)) { return "Wrong elements for 5.toShort() downTo 5.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt index 6b6debd18ee..7af5b40fe28 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 5..5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 5.toByte()..5.toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(5.toByte())) { + if (list2 != listOf(5)) { return "Wrong elements for 5.toByte()..5.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 5.toShort()..5.toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(5.toShort())) { + if (list3 != listOf(5)) { return "Wrong elements for 5.toShort()..5.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/openRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/openRange.kt index ca1e1eaf198..526107234c6 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/openRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/openRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 1 until 5: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 1.toByte() until 5.toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(1, 2, 3, 4)) { + if (list2 != listOf(1, 2, 3, 4)) { return "Wrong elements for 1.toByte() until 5.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 1.toShort() until 5.toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(1, 2, 3, 4)) { + if (list3 != listOf(1, 2, 3, 4)) { return "Wrong elements for 1.toShort() until 5.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt index 65d446db81e..05d0d6338ec 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionDownToMinValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for (MinI + 2) downTo MinI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (MinB + 2).toByte() downTo MinB step 1) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MinB + 2).toByte(), (MinB + 1).toByte(), MinB)) { + if (list2 != listOf((MinB + 2).toInt(), (MinB + 1).toInt(), MinB.toInt())) { return "Wrong elements for (MinB + 2).toByte() downTo MinB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (MinS + 2).toShort() downTo MinS step 1) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MinS + 2).toShort(), (MinS + 1).toShort(), MinS)) { + if (list3 != listOf((MinS + 2).toInt(), (MinS + 1).toInt(), MinS.toInt())) { return "Wrong elements for (MinS + 2).toShort() downTo MinS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt index 9670a4201b8..6110e5aafc2 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for (MaxI - 2)..MaxI step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (MaxB - 2).toByte()..MaxB step 2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf((MaxB - 2).toByte(), MaxB)) { + if (list2 != listOf((MaxB - 2).toInt(), MaxB.toInt())) { return "Wrong elements for (MaxB - 2).toByte()..MaxB step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (MaxS - 2).toShort()..MaxS step 2) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf((MaxS - 2).toShort(), MaxS)) { + if (list3 != listOf((MaxS - 2).toInt(), MaxS.toInt())) { return "Wrong elements for (MaxS - 2).toShort()..MaxS step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMaxValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMaxValue.kt index ccae1f689ce..19ae4c1ba50 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMaxValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMaxValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for MaxI..MaxI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in MaxB..MaxB step 1) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(MaxB)) { + if (list2 != listOf(MaxB.toInt())) { return "Wrong elements for MaxB..MaxB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in MaxS..MaxS step 1) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(MaxS)) { + if (list3 != listOf(MaxS.toInt())) { return "Wrong elements for MaxS..MaxS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMinValue.kt index 0b006e73bd6..b1aa729c2c5 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMaxValueToMinValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for MaxI..MinI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in MaxB..MinB step 1) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for MaxB..MinB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in MaxS..MinS step 1) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for MaxS..MinS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMinValueToMinValue.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMinValueToMinValue.kt index 785c4081de8..c9cfbb89fa4 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMinValueToMinValue.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/progressionMinValueToMinValue.kt @@ -22,21 +22,21 @@ fun box(): String { return "Wrong elements for MinI..MinI step 1: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in MinB..MinB step 1) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(MinB)) { + if (list2 != listOf(MinB.toInt())) { return "Wrong elements for MinB..MinB step 1: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in MinS..MinS step 1) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(MinS)) { + if (list3 != listOf(MinS.toInt())) { return "Wrong elements for MinS..MinS step 1: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt index f28a59998a6..3472111e290 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for (5 downTo 3).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (5.toByte() downTo 3.toByte()).reversed()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 4, 5)) { + if (list2 != listOf(3, 4, 5)) { return "Wrong elements for (5.toByte() downTo 3.toByte()).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (5.toShort() downTo 3.toShort()).reversed()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 4, 5)) { + if (list3 != listOf(3, 4, 5)) { return "Wrong elements for (5.toShort() downTo 3.toShort()).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt index f5d5645eac8..bbd47b6f985 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for (3 downTo 5).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (3.toByte() downTo 5.toByte()).reversed()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for (3.toByte() downTo 5.toByte()).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (3.toShort() downTo 5.toShort()).reversed()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for (3.toShort() downTo 5.toShort()).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt index 57f0d25eb19..d18c7f0f9e9 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for (5..3).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (5.toByte()..3.toByte()).reversed()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf()) { + if (list2 != listOf()) { return "Wrong elements for (5.toByte()..3.toByte()).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (5.toShort()..3.toShort()).reversed()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf()) { + if (list3 != listOf()) { return "Wrong elements for (5.toShort()..3.toShort()).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedInexactSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedInexactSteppedDownTo.kt index b38dd572bd7..7ceb7c77eac 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedInexactSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedInexactSteppedDownTo.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for (8 downTo 3 step 2).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (8.toByte() downTo 3.toByte() step 2).reversed()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 5, 7)) { + if (list2 != listOf(3, 5, 7)) { return "Wrong elements for (8.toByte() downTo 3.toByte() step 2).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (8.toShort() downTo 3.toShort() step 2).reversed()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 5, 7)) { + if (list3 != listOf(3, 5, 7)) { return "Wrong elements for (8.toShort() downTo 3.toShort() step 2).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt index b5c775dc5ca..87b2f1e3660 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt @@ -11,58 +11,49 @@ fun box(): String { return "Wrong elements for (3..5).reversed(): $list1" } - val list2 = ArrayList() - for (i in (3.toByte()..5.toByte()).reversed()) { + val list2 = ArrayList() + for (i in (3.toShort()..5.toShort()).reversed()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(5, 4, 3)) { - return "Wrong elements for (3.toByte()..5.toByte()).reversed(): $list2" + if (list2 != listOf(5, 4, 3)) { + return "Wrong elements for (3.toShort()..5.toShort()).reversed(): $list2" } - val list3 = ArrayList() - for (i in (3.toShort()..5.toShort()).reversed()) { + val list3 = ArrayList() + for (i in (3.toLong()..5.toLong()).reversed()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(5, 4, 3)) { - return "Wrong elements for (3.toShort()..5.toShort()).reversed(): $list3" + if (list3 != listOf(5, 4, 3)) { + return "Wrong elements for (3.toLong()..5.toLong()).reversed(): $list3" } - val list4 = ArrayList() - for (i in (3.toLong()..5.toLong()).reversed()) { + val list4 = ArrayList() + for (i in ('a'..'c').reversed()) { list4.add(i) if (list4.size() > 23) break } - if (list4 != listOf(5, 4, 3)) { - return "Wrong elements for (3.toLong()..5.toLong()).reversed(): $list4" + if (list4 != listOf('c', 'b', 'a')) { + return "Wrong elements for ('a'..'c').reversed(): $list4" } - val list5 = ArrayList() - for (i in ('a'..'c').reversed()) { + val list5 = ArrayList() + for (i in (3.0..5.0).reversed()) { list5.add(i) if (list5.size() > 23) break } - if (list5 != listOf('c', 'b', 'a')) { - return "Wrong elements for ('a'..'c').reversed(): $list5" + if (list5 != listOf(5.0, 4.0, 3.0)) { + return "Wrong elements for (3.0..5.0).reversed(): $list5" } - val list6 = ArrayList() - for (i in (3.0..5.0).reversed()) { + val list6 = ArrayList() + for (i in (3.0.toFloat()..5.0.toFloat()).reversed()) { list6.add(i) if (list6.size() > 23) break } - if (list6 != listOf(5.0, 4.0, 3.0)) { - return "Wrong elements for (3.0..5.0).reversed(): $list6" - } - - val list7 = ArrayList() - for (i in (3.0.toFloat()..5.0.toFloat()).reversed()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) { - return "Wrong elements for (3.0.toFloat()..5.0.toFloat()).reversed(): $list7" + if (list6 != listOf(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) { + return "Wrong elements for (3.0.toFloat()..5.0.toFloat()).reversed(): $list6" } return "OK" diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedSimpleSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedSimpleSteppedRange.kt index ec8fc03216d..f9dc5399440 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedSimpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedSimpleSteppedRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for (3..9 step 2).reversed(): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (3.toByte()..9.toByte() step 2).reversed()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(9, 7, 5, 3)) { + if (list2 != listOf(9, 7, 5, 3)) { return "Wrong elements for (3.toByte()..9.toByte() step 2).reversed(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (3.toShort()..9.toShort() step 2).reversed()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(9, 7, 5, 3)) { + if (list3 != listOf(9, 7, 5, 3)) { return "Wrong elements for (3.toShort()..9.toShort() step 2).reversed(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt index cc6682f1806..b4882be67b2 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 9 downTo 3: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 9.toByte() downTo 3.toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(9, 8, 7, 6, 5, 4, 3)) { + if (list2 != listOf(9, 8, 7, 6, 5, 4, 3)) { return "Wrong elements for 9.toByte() downTo 3.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 9.toShort() downTo 3.toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(9, 8, 7, 6, 5, 4, 3)) { + if (list3 != listOf(9, 8, 7, 6, 5, 4, 3)) { return "Wrong elements for 9.toShort() downTo 3.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt index 7af98396411..dbb44a36836 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 3..9: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 3.toByte()..9.toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for 3.toByte()..9.toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 3.toShort()..9.toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for 3.toShort()..9.toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt index 8c471b921c0..1ee00f49dba 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for (1 + 2)..(10 - 1): $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte()) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list2 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for (1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte(): $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort()) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { + if (list3 != listOf(3, 4, 5, 6, 7, 8, 9)) { return "Wrong elements for (1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort(): $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt index 326681cdaeb..5e6eb9065f4 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 9 downTo 3 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 9.toByte() downTo 3.toByte() step 2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(9, 7, 5, 3)) { + if (list2 != listOf(9, 7, 5, 3)) { return "Wrong elements for 9.toByte() downTo 3.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 9.toShort() downTo 3.toShort() step 2) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(9, 7, 5, 3)) { + if (list3 != listOf(9, 7, 5, 3)) { return "Wrong elements for 9.toShort() downTo 3.toShort() step 2: $list3" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt index 00728eb8f24..6abcb773afd 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt @@ -11,21 +11,21 @@ fun box(): String { return "Wrong elements for 3..9 step 2: $list1" } - val list2 = ArrayList() + val list2 = ArrayList() for (i in 3.toByte()..9.toByte() step 2) { list2.add(i) if (list2.size() > 23) break } - if (list2 != listOf(3, 5, 7, 9)) { + if (list2 != listOf(3, 5, 7, 9)) { return "Wrong elements for 3.toByte()..9.toByte() step 2: $list2" } - val list3 = ArrayList() + val list3 = ArrayList() for (i in 3.toShort()..9.toShort() step 2) { list3.add(i) if (list3.size() > 23) break } - if (list3 != listOf(3, 5, 7, 9)) { + if (list3 != listOf(3, 5, 7, 9)) { return "Wrong elements for 3.toShort()..9.toShort() step 2: $list3" } diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java index cd3423b7b33..9620690217b 100644 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java @@ -70,10 +70,6 @@ public class GenerateRangesCodegenTestData { .put("\"", "Char") .put("Float.NaN", "Float") .put("Double.NaN", "Double") - .put("MaxB", "Byte") - .put("MinB", "Byte") - .put("MaxS", "Short") - .put("MinS", "Short") .put("MaxL", "Long") .put("MinL", "Long") .put("MaxC", "Char") @@ -83,7 +79,8 @@ public class GenerateRangesCodegenTestData { private static String detectElementType(String rangeExpression) { Matcher matcher = Pattern.compile("\\.to(\\w+)").matcher(rangeExpression); if (matcher.find()) { - return matcher.group(1); + String elementType = matcher.group(1); + return elementType.equals("Byte") || elementType.equals("Short") ? "Int" : elementType; } if (Pattern.compile("\\d\\.\\d").matcher(rangeExpression).find()) { return "Double"; diff --git a/libraries/stdlib/test/language/RangeIterationJVMTest.kt b/libraries/stdlib/test/language/RangeIterationJVMTest.kt index b8d02d3159a..d4dc9702be9 100644 --- a/libraries/stdlib/test/language/RangeIterationJVMTest.kt +++ b/libraries/stdlib/test/language/RangeIterationJVMTest.kt @@ -61,8 +61,8 @@ public class RangeIterationJVMTest { @test fun maxValueToMaxValue() { doTest(MaxI..MaxI, MaxI, MaxI, 1, listOf(MaxI)) - doTest(MaxB..MaxB, MaxB, MaxB, 1, listOf(MaxB)) - doTest(MaxS..MaxS, MaxS, MaxS, 1, listOf(MaxS)) + doTest(MaxB..MaxB, MaxB.toInt(), MaxB.toInt(), 1, listOf(MaxB.toInt())) + doTest(MaxS..MaxS, MaxS.toInt(), MaxS.toInt(), 1, listOf(MaxS.toInt())) doTest(MaxL..MaxL, MaxL, MaxL, 1.toLong(), listOf(MaxL)) doTest(MaxC..MaxC, MaxC, MaxC, 1, listOf(MaxC)) @@ -70,8 +70,8 @@ public class RangeIterationJVMTest { @test fun maxValueMinusTwoToMaxValue() { doTest((MaxI - 2)..MaxI, MaxI - 2, MaxI, 1, listOf(MaxI - 2, MaxI - 1, MaxI)) - doTest((MaxB - 2).toByte()..MaxB, (MaxB - 2).toByte(), MaxB, 1, listOf((MaxB - 2).toByte(), (MaxB - 1).toByte(), MaxB)) - doTest((MaxS - 2).toShort()..MaxS, (MaxS - 2).toShort(), MaxS, 1, listOf((MaxS - 2).toShort(), (MaxS - 1).toShort(), MaxS)) + doTest((MaxB - 2).toByte()..MaxB, (MaxB - 2).toInt(), MaxB.toInt(), 1, listOf((MaxB - 2).toInt(), (MaxB - 1).toInt(), MaxB.toInt())) + doTest((MaxS - 2).toShort()..MaxS, (MaxS - 2).toInt(), MaxS.toInt(), 1, listOf((MaxS - 2).toInt(), (MaxS - 1).toInt(), MaxS.toInt())) doTest((MaxL - 2).toLong()..MaxL, (MaxL - 2).toLong(), MaxL, 1.toLong(), listOf((MaxL - 2).toLong(), (MaxL - 1).toLong(), MaxL)) doTest((MaxC - 2)..MaxC, (MaxC - 2), MaxC, 1, listOf((MaxC - 2), (MaxC - 1), MaxC)) @@ -79,8 +79,8 @@ public class RangeIterationJVMTest { @test fun maxValueToMinValue() { doTest(MaxI..MinI, MaxI, MinI, 1, listOf()) - doTest(MaxB..MinB, MaxB, MinB, 1, listOf()) - doTest(MaxS..MinS, MaxS, MinS, 1, listOf()) + doTest(MaxB..MinB, MaxB.toInt(), MinB.toInt(), 1, listOf()) + doTest(MaxS..MinS, MaxS.toInt(), MinS.toInt(), 1, listOf()) doTest(MaxL..MinL, MaxL, MinL, 1.toLong(), listOf()) doTest(MaxC..MinC, MaxC, MinC, 1, listOf()) @@ -88,8 +88,8 @@ public class RangeIterationJVMTest { @test fun progressionMaxValueToMaxValue() { doTest(MaxI..MaxI step 1, MaxI, MaxI, 1, listOf(MaxI)) - doTest(MaxB..MaxB step 1, MaxB, MaxB, 1, listOf(MaxB)) - doTest(MaxS..MaxS step 1, MaxS, MaxS, 1, listOf(MaxS)) + doTest(MaxB..MaxB step 1, MaxB.toInt(), MaxB.toInt(), 1, listOf(MaxB.toInt())) + doTest(MaxS..MaxS step 1, MaxS.toInt(), MaxS.toInt(), 1, listOf(MaxS.toInt())) doTest(MaxL..MaxL step 1, MaxL, MaxL, 1.toLong(), listOf(MaxL)) doTest(MaxC..MaxC step 1, MaxC, MaxC, 1, listOf(MaxC)) @@ -97,8 +97,8 @@ public class RangeIterationJVMTest { @test fun progressionMaxValueMinusTwoToMaxValue() { doTest((MaxI - 2)..MaxI step 2, MaxI - 2, MaxI, 2, listOf(MaxI - 2, MaxI)) - doTest((MaxB - 2).toByte()..MaxB step 2, (MaxB - 2).toByte(), MaxB, 2, listOf((MaxB - 2).toByte(), MaxB)) - doTest((MaxS - 2).toShort()..MaxS step 2, (MaxS - 2).toShort(), MaxS, 2, listOf((MaxS - 2).toShort(), MaxS)) + doTest((MaxB - 2).toByte()..MaxB step 2, (MaxB - 2).toInt(), MaxB.toInt(), 2, listOf((MaxB - 2).toInt(), MaxB.toInt())) + doTest((MaxS - 2).toShort()..MaxS step 2, (MaxS - 2).toInt(), MaxS.toInt(), 2, listOf((MaxS - 2).toInt(), MaxS.toInt())) doTest((MaxL - 2).toLong()..MaxL step 2, (MaxL - 2).toLong(), MaxL, 2.toLong(), listOf((MaxL - 2).toLong(), MaxL)) doTest((MaxC - 2)..MaxC step 2, (MaxC - 2), MaxC, 2, listOf((MaxC - 2), MaxC)) @@ -106,8 +106,8 @@ public class RangeIterationJVMTest { @test fun progressionMaxValueToMinValue() { doTest(MaxI..MinI step 1, MaxI, MinI, 1, listOf()) - doTest(MaxB..MinB step 1, MaxB, MinB, 1, listOf()) - doTest(MaxS..MinS step 1, MaxS, MinS, 1, listOf()) + doTest(MaxB..MinB step 1, MaxB.toInt(), MinB.toInt(), 1, listOf()) + doTest(MaxS..MinS step 1, MaxS.toInt(), MinS.toInt(), 1, listOf()) doTest(MaxL..MinL step 1, MaxL, MinL, 1.toLong(), listOf()) doTest(MaxC..MinC step 1, MaxC, MinC, 1, listOf()) @@ -115,8 +115,8 @@ public class RangeIterationJVMTest { @test fun progressionMinValueToMinValue() { doTest(MinI..MinI step 1, MinI, MinI, 1, listOf(MinI)) - doTest(MinB..MinB step 1, MinB, MinB, 1, listOf(MinB)) - doTest(MinS..MinS step 1, MinS, MinS, 1, listOf(MinS)) + doTest(MinB..MinB step 1, MinB.toInt(), MinB.toInt(), 1, listOf(MinB.toInt())) + doTest(MinS..MinS step 1, MinS.toInt(), MinS.toInt(), 1, listOf(MinS.toInt())) doTest(MinL..MinL step 1, MinL, MinL, 1.toLong(), listOf(MinL)) doTest(MinC..MinC step 1, MinC, MinC, 1, listOf(MinC)) @@ -124,8 +124,8 @@ public class RangeIterationJVMTest { @test fun inexactToMaxValue() { doTest((MaxI - 5)..MaxI step 3, MaxI - 5, MaxI, 3, listOf(MaxI - 5, MaxI - 2)) - doTest((MaxB - 5).toByte()..MaxB step 3, (MaxB - 5).toByte(), MaxB, 3, listOf((MaxB - 5).toByte(), (MaxB - 2).toByte())) - doTest((MaxS - 5).toShort()..MaxS step 3, (MaxS - 5).toShort(), MaxS, 3, listOf((MaxS - 5).toShort(), (MaxS - 2).toShort())) + doTest((MaxB - 5).toByte()..MaxB step 3, (MaxB - 5).toInt(), MaxB.toInt(), 3, listOf((MaxB - 5).toInt(), (MaxB - 2).toInt())) + doTest((MaxS - 5).toShort()..MaxS step 3, (MaxS - 5).toInt(), MaxS.toInt(), 3, listOf((MaxS - 5).toInt(), (MaxS - 2).toInt())) doTest((MaxL - 5).toLong()..MaxL step 3, (MaxL - 5).toLong(), MaxL, 3.toLong(), listOf((MaxL - 5).toLong(), (MaxL - 2).toLong())) doTest((MaxC - 5)..MaxC step 3, (MaxC - 5), MaxC, 3, listOf((MaxC - 5), (MaxC - 2))) @@ -133,8 +133,8 @@ public class RangeIterationJVMTest { @test fun progressionDownToMinValue() { doTest((MinI + 2) downTo MinI step 1, MinI + 2, MinI, -1, listOf(MinI + 2, MinI + 1, MinI)) - doTest((MinB + 2).toByte() downTo MinB step 1, (MinB + 2).toByte(), MinB, -1, listOf((MinB + 2).toByte(), (MinB + 1).toByte(), MinB)) - doTest((MinS + 2).toShort() downTo MinS step 1, (MinS + 2).toShort(), MinS, -1, listOf((MinS + 2).toShort(), (MinS + 1).toShort(), MinS)) + doTest((MinB + 2).toByte() downTo MinB step 1, (MinB + 2).toInt(), MinB.toInt(), -1, listOf((MinB + 2).toInt(), (MinB + 1).toInt(), MinB.toInt())) + doTest((MinS + 2).toShort() downTo MinS step 1, (MinS + 2).toInt(), MinS.toInt(), -1, listOf((MinS + 2).toInt(), (MinS + 1).toInt(), MinS.toInt())) doTest((MinL + 2).toLong() downTo MinL step 1, (MinL + 2).toLong(), MinL, -1.toLong(), listOf((MinL + 2).toLong(), (MinL + 1).toLong(), MinL)) doTest((MinC + 2) downTo MinC step 1, (MinC + 2), MinC, -1, listOf((MinC + 2), (MinC + 1), MinC)) @@ -142,8 +142,8 @@ public class RangeIterationJVMTest { @test fun inexactDownToMinValue() { doTest((MinI + 5) downTo MinI step 3, MinI + 5, MinI, -3, listOf(MinI + 5, MinI + 2)) - doTest((MinB + 5).toByte() downTo MinB step 3, (MinB + 5).toByte(), MinB, -3, listOf((MinB + 5).toByte(), (MinB + 2).toByte())) - doTest((MinS + 5).toShort() downTo MinS step 3, (MinS + 5).toShort(), MinS, -3, listOf((MinS + 5).toShort(), (MinS + 2).toShort())) + doTest((MinB + 5).toByte() downTo MinB step 3, (MinB + 5).toInt(), MinB.toInt(), -3, listOf((MinB + 5).toInt(), (MinB + 2).toInt())) + doTest((MinS + 5).toShort() downTo MinS step 3, (MinS + 5).toInt(), MinS.toInt(), -3, listOf((MinS + 5).toInt(), (MinS + 2).toInt())) doTest((MinL + 5).toLong() downTo MinL step 3, (MinL + 5).toLong(), MinL, -3.toLong(), listOf((MinL + 5).toLong(), (MinL + 2).toLong())) doTest((MinC + 5) downTo MinC step 3, (MinC + 5), MinC, -3, listOf((MinC + 5), (MinC + 2))) diff --git a/libraries/stdlib/test/language/RangeIterationTest.kt b/libraries/stdlib/test/language/RangeIterationTest.kt index 223a8b71f85..4c6b64d2c89 100644 --- a/libraries/stdlib/test/language/RangeIterationTest.kt +++ b/libraries/stdlib/test/language/RangeIterationTest.kt @@ -37,8 +37,8 @@ public class RangeIterationTest { @test fun emptyRange() { doTest(10..5, 10, 5, 1, listOf()) - doTest(10.toByte()..(-5).toByte(), 10.toByte(), (-5).toByte(), 1, listOf()) - doTest(10.toShort()..(-5).toShort(), 10.toShort(), (-5).toShort(), 1, listOf()) + doTest(10.toByte()..(-5).toByte(), 10, (-5), 1, listOf()) + doTest(10.toShort()..(-5).toShort(), 10, (-5), 1, listOf()) doTest(10.toLong()..-5.toLong(), 10.toLong(), -5.toLong(), 1.toLong(), listOf()) doTest('z'..'a', 'z', 'a', 1, listOf()) @@ -49,8 +49,8 @@ public class RangeIterationTest { @test fun oneElementRange() { doTest(5..5, 5, 5, 1, listOf(5)) - doTest(5.toByte()..5.toByte(), 5.toByte(), 5.toByte(), 1, listOf(5.toByte())) - doTest(5.toShort()..5.toShort(), 5.toShort(), 5.toShort(), 1, listOf(5.toShort())) + doTest(5.toByte()..5.toByte(), 5, 5, 1, listOf(5)) + doTest(5.toShort()..5.toShort(), 5, 5, 1, listOf(5)) doTest(5.toLong()..5.toLong(), 5.toLong(), 5.toLong(), 1.toLong(), listOf(5.toLong())) doTest('k'..'k', 'k', 'k', 1, listOf('k')) @@ -61,8 +61,8 @@ public class RangeIterationTest { @test fun simpleRange() { doTest(3..9, 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) - doTest(3.toByte()..9.toByte(), 3.toByte(), 9.toByte(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) - doTest(3.toShort()..9.toShort(), 3.toShort(), 9.toShort(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) + doTest(3.toByte()..9.toByte(), 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) + doTest(3.toShort()..9.toShort(), 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) doTest(3.toLong()..9.toLong(), 3.toLong(), 9.toLong(), 1.toLong(), listOf(3, 4, 5, 6, 7, 8, 9)) doTest('c'..'g', 'c', 'g', 1, listOf('c', 'd', 'e', 'f', 'g')) @@ -75,8 +75,8 @@ public class RangeIterationTest { @test fun simpleRangeWithNonConstantEnds() { doTest((1 + 2)..(10 - 1), 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) - doTest((1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte(), 3.toByte(), 9.toByte(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) - doTest((1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort(), 3.toShort(), 9.toShort(), 1, listOf(3, 4, 5, 6, 7, 8, 9)) + doTest((1.toByte() + 2.toByte()).toByte()..(10.toByte() - 1.toByte()).toByte(), 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) + doTest((1.toShort() + 2.toShort()).toShort()..(10.toShort() - 1.toShort()).toShort(), 3, 9, 1, listOf(3, 4, 5, 6, 7, 8, 9)) doTest((1.toLong() + 2.toLong())..(10.toLong() - 1.toLong()), 3.toLong(), 9.toLong(), 1.toLong(), listOf(3, 4, 5, 6, 7, 8, 9)) doTest(("ace"[1])..("age"[1]), 'c', 'g', 1, listOf('c', 'd', 'e', 'f', 'g')) @@ -88,8 +88,8 @@ public class RangeIterationTest { @test fun openRange() { doTest(1 until 5, 1, 4, 1, listOf(1, 2, 3, 4)) - doTest(1.toByte() until 5.toByte(), 1.toByte(), 4.toByte(), 1, listOf(1, 2, 3, 4)) - doTest(1.toShort() until 5.toShort(), 1.toShort(), 4.toShort(), 1, listOf(1, 2, 3, 4)) + doTest(1.toByte() until 5.toByte(), 1, 4, 1, listOf(1, 2, 3, 4)) + doTest(1.toShort() until 5.toShort(), 1, 4, 1, listOf(1, 2, 3, 4)) doTest(1.toLong() until 5.toLong(), 1L, 4L, 1L, listOf(1, 2, 3, 4)) doTest('a' until 'd', 'a', 'c', 1, listOf('a', 'b', 'c')) } @@ -97,8 +97,8 @@ public class RangeIterationTest { @test fun emptyDownto() { doTest(5 downTo 10, 5, 10, -1, listOf()) - doTest(5.toByte() downTo 10.toByte(), 5.toByte(), 10.toByte(), -1, listOf()) - doTest(5.toShort() downTo 10.toShort(), 5.toShort(), 10.toShort(), -1, listOf()) + doTest(5.toByte() downTo 10.toByte(), 5, 10, -1, listOf()) + doTest(5.toShort() downTo 10.toShort(), 5, 10, -1, listOf()) doTest(5.toLong() downTo 10.toLong(), 5.toLong(), 10.toLong(), -1.toLong(), listOf()) doTest('a' downTo 'z', 'a', 'z', -1, listOf()) @@ -109,8 +109,8 @@ public class RangeIterationTest { @test fun oneElementDownTo() { doTest(5 downTo 5, 5, 5, -1, listOf(5)) - doTest(5.toByte() downTo 5.toByte(), 5.toByte(), 5.toByte(), -1, listOf(5.toByte())) - doTest(5.toShort() downTo 5.toShort(), 5.toShort(), 5.toShort(), -1, listOf(5.toShort())) + doTest(5.toByte() downTo 5.toByte(), 5, 5, -1, listOf(5)) + doTest(5.toShort() downTo 5.toShort(), 5, 5, -1, listOf(5)) doTest(5.toLong() downTo 5.toLong(), 5.toLong(), 5.toLong(), -1.toLong(), listOf(5.toLong())) doTest('k' downTo 'k', 'k', 'k', -1, listOf('k')) @@ -121,8 +121,8 @@ public class RangeIterationTest { @test fun simpleDownTo() { doTest(9 downTo 3, 9, 3, -1, listOf(9, 8, 7, 6, 5, 4, 3)) - doTest(9.toByte() downTo 3.toByte(), 9.toByte(), 3.toByte(), -1, listOf(9, 8, 7, 6, 5, 4, 3)) - doTest(9.toShort() downTo 3.toShort(), 9.toShort(), 3.toShort(), -1, listOf(9, 8, 7, 6, 5, 4, 3)) + doTest(9.toByte() downTo 3.toByte(), 9, 3, -1, listOf(9, 8, 7, 6, 5, 4, 3)) + doTest(9.toShort() downTo 3.toShort(), 9, 3, -1, listOf(9, 8, 7, 6, 5, 4, 3)) doTest(9.toLong() downTo 3.toLong(), 9.toLong(), 3.toLong(), -1.toLong(), listOf(9, 8, 7, 6, 5, 4, 3)) doTest('g' downTo 'c', 'g', 'c', -1, listOf('g', 'f', 'e', 'd', 'c')) @@ -135,8 +135,8 @@ public class RangeIterationTest { @test fun simpleSteppedRange() { doTest(3..9 step 2, 3, 9, 2, listOf(3, 5, 7, 9)) - doTest(3.toByte()..9.toByte() step 2, 3.toByte(), 9.toByte(), 2, listOf(3, 5, 7, 9)) - doTest(3.toShort()..9.toShort() step 2, 3.toShort(), 9.toShort(), 2, listOf(3, 5, 7, 9)) + doTest(3.toByte()..9.toByte() step 2, 3, 9, 2, listOf(3, 5, 7, 9)) + doTest(3.toShort()..9.toShort() step 2, 3, 9, 2, listOf(3, 5, 7, 9)) doTest(3.toLong()..9.toLong() step 2.toLong(), 3.toLong(), 9.toLong(), 2.toLong(), listOf(3, 5, 7, 9)) doTest('c'..'g' step 2, 'c', 'g', 2, listOf('c', 'e', 'g')) @@ -148,8 +148,8 @@ public class RangeIterationTest { @test fun simpleSteppedDownTo() { doTest(9 downTo 3 step 2, 9, 3, -2, listOf(9, 7, 5, 3)) - doTest(9.toByte() downTo 3.toByte() step 2, 9.toByte(), 3.toByte(), -2, listOf(9, 7, 5, 3)) - doTest(9.toShort() downTo 3.toShort() step 2, 9.toShort(), 3.toShort(), -2, listOf(9, 7, 5, 3)) + doTest(9.toByte() downTo 3.toByte() step 2, 9, 3, -2, listOf(9, 7, 5, 3)) + doTest(9.toShort() downTo 3.toShort() step 2, 9, 3, -2, listOf(9, 7, 5, 3)) doTest(9.toLong() downTo 3.toLong() step 2.toLong(), 9.toLong(), 3.toLong(), -2.toLong(), listOf(9, 7, 5, 3)) doTest('g' downTo 'c' step 2, 'g', 'c', -2, listOf('g', 'e', 'c')) @@ -163,8 +163,8 @@ public class RangeIterationTest { // 'inexact' means last element is not equal to sequence end @test fun inexactSteppedRange() { doTest(3..8 step 2, 3, 8, 2, listOf(3, 5, 7)) - doTest(3.toByte()..8.toByte() step 2, 3.toByte(), 8.toByte(), 2, listOf(3, 5, 7)) - doTest(3.toShort()..8.toShort() step 2, 3.toShort(), 8.toShort(), 2, listOf(3, 5, 7)) + doTest(3.toByte()..8.toByte() step 2, 3, 8, 2, listOf(3, 5, 7)) + doTest(3.toShort()..8.toShort() step 2, 3, 8, 2, listOf(3, 5, 7)) doTest(3.toLong()..8.toLong() step 2.toLong(), 3.toLong(), 8.toLong(), 2.toLong(), listOf(3, 5, 7)) doTest('a'..'d' step 2, 'a', 'd', 2, listOf('a', 'c')) @@ -177,8 +177,8 @@ public class RangeIterationTest { // 'inexact' means last element is not equal to sequence end @test fun inexactSteppedDownTo() { doTest(8 downTo 3 step 2, 8, 3, -2, listOf(8, 6, 4)) - doTest(8.toByte() downTo 3.toByte() step 2, 8.toByte(), 3.toByte(), -2, listOf(8, 6, 4)) - doTest(8.toShort() downTo 3.toShort() step 2, 8.toShort(), 3.toShort(), -2, listOf(8, 6, 4)) + doTest(8.toByte() downTo 3.toByte() step 2, 8, 3, -2, listOf(8, 6, 4)) + doTest(8.toShort() downTo 3.toShort() step 2, 8, 3, -2, listOf(8, 6, 4)) doTest(8.toLong() downTo 3.toLong() step 2.toLong(), 8.toLong(), 3.toLong(), -2.toLong(), listOf(8, 6, 4)) doTest('d' downTo 'a' step 2, 'd', 'a', -2, listOf('d', 'b')) @@ -191,8 +191,8 @@ public class RangeIterationTest { @test fun reversedEmptyRange() { doTest((5..3).reversed(), 3, 5, -1, listOf()) - doTest((5.toByte()..3.toByte()).reversed(), 3.toByte(), 5.toByte(), -1, listOf()) - doTest((5.toShort()..3.toShort()).reversed(), 3.toShort(), 5.toShort(), -1, listOf()) + doTest((5.toByte()..3.toByte()).reversed(), 3, 5, -1, listOf()) + doTest((5.toShort()..3.toShort()).reversed(), 3, 5, -1, listOf()) doTest((5.toLong()..3.toLong()).reversed(), 3.toLong(), 5.toLong(), -1.toLong(), listOf()) doTest(('c'..'a').reversed(), 'a', 'c', -1, listOf()) @@ -203,8 +203,8 @@ public class RangeIterationTest { @test fun reversedEmptyBackSequence() { doTest((3 downTo 5).reversed(), 5, 3, 1, listOf()) - doTest((3.toByte() downTo 5.toByte()).reversed(), 5.toByte(), 3.toByte(), 1, listOf()) - doTest((3.toShort() downTo 5.toShort()).reversed(), 5.toShort(), 3.toShort(), 1, listOf()) + doTest((3.toByte() downTo 5.toByte()).reversed(), 5, 3, 1, listOf()) + doTest((3.toShort() downTo 5.toShort()).reversed(), 5, 3, 1, listOf()) doTest((3.toLong() downTo 5.toLong()).reversed(), 5.toLong(), 3.toLong(), 1.toLong(), listOf()) doTest(('a' downTo 'c').reversed(), 'c', 'a', 1, listOf()) @@ -215,8 +215,8 @@ public class RangeIterationTest { @test fun reversedRange() { doTest((3..5).reversed(), 5, 3, -1, listOf(5, 4, 3)) - doTest((3.toByte()..5.toByte()).reversed(), 5.toByte(), 3.toByte(), -1, listOf(5, 4, 3)) - doTest((3.toShort()..5.toShort()).reversed(), 5.toShort(), 3.toShort(), -1, listOf(5, 4, 3)) + doTest((3.toByte()..5.toByte()).reversed(),5, 3, -1, listOf(5, 4, 3)) + doTest((3.toShort()..5.toShort()).reversed(), 5, 3, -1, listOf(5, 4, 3)) doTest((3.toLong()..5.toLong()).reversed(), 5.toLong(), 3.toLong(), -1.toLong(), listOf(5, 4, 3)) doTest(('a'..'c').reversed(), 'c', 'a', -1, listOf('c', 'b', 'a')) @@ -228,8 +228,8 @@ public class RangeIterationTest { @test fun reversedBackSequence() { doTest((5 downTo 3).reversed(), 3, 5, 1, listOf(3, 4, 5)) - doTest((5.toByte() downTo 3.toByte()).reversed(), 3.toByte(), 5.toByte(), 1, listOf(3, 4, 5)) - doTest((5.toShort() downTo 3.toShort()).reversed(), 3.toShort(), 5.toShort(), 1, listOf(3, 4, 5)) + doTest((5.toByte() downTo 3.toByte()).reversed(), 3, 5, 1, listOf(3, 4, 5)) + doTest((5.toShort() downTo 3.toShort()).reversed(), 3, 5, 1, listOf(3, 4, 5)) doTest((5.toLong() downTo 3.toLong()).reversed(), 3.toLong(), 5.toLong(), 1.toLong(), listOf(3, 4, 5)) doTest(('c' downTo 'a').reversed(), 'a', 'c', 1, listOf('a', 'b', 'c')) @@ -241,8 +241,8 @@ public class RangeIterationTest { @test fun reversedSimpleSteppedRange() { doTest((3..9 step 2).reversed(), 9, 3, -2, listOf(9, 7, 5, 3)) - doTest((3.toByte()..9.toByte() step 2).reversed(), 9.toByte(), 3.toByte(), -2, listOf(9, 7, 5, 3)) - doTest((3.toShort()..9.toShort() step 2).reversed(), 9.toShort(), 3.toShort(), -2, listOf(9, 7, 5, 3)) + doTest((3.toByte()..9.toByte() step 2).reversed(), 9, 3, -2, listOf(9, 7, 5, 3)) + doTest((3.toShort()..9.toShort() step 2).reversed(), 9, 3, -2, listOf(9, 7, 5, 3)) doTest((3.toLong()..9.toLong() step 2.toLong()).reversed(), 9.toLong(), 3.toLong(), -2.toLong(), listOf(9, 7, 5, 3)) doTest(('c'..'g' step 2).reversed(), 'g', 'c', -2, listOf('g', 'e', 'c')) @@ -255,8 +255,8 @@ public class RangeIterationTest { // 'inexact' means last element is not equal to sequence end @test fun reversedInexactSteppedDownTo() { doTest((8 downTo 3 step 2).reversed(), 3, 8, 2, listOf(3, 5, 7)) - doTest((8.toByte() downTo 3.toByte() step 2).reversed(), 3.toByte(), 8.toByte(), 2, listOf(3, 5, 7)) - doTest((8.toShort() downTo 3.toShort() step 2).reversed(), 3.toShort(), 8.toShort(), 2, listOf(3, 5, 7)) + doTest((8.toByte() downTo 3.toByte() step 2).reversed(), 3, 8, 2, listOf(3, 5, 7)) + doTest((8.toShort() downTo 3.toShort() step 2).reversed(), 3, 8, 2, listOf(3, 5, 7)) doTest((8.toLong() downTo 3.toLong() step 2.toLong()).reversed(), 3.toLong(), 8.toLong(), 2.toLong(), listOf(3, 5, 7)) doTest(('d' downTo 'a' step 2).reversed(), 'a', 'd', 2, listOf('a', 'c')) diff --git a/libraries/stdlib/test/language/RangeTest.kt b/libraries/stdlib/test/language/RangeTest.kt index 85da2472048..23be1805a16 100644 --- a/libraries/stdlib/test/language/RangeTest.kt +++ b/libraries/stdlib/test/language/RangeTest.kt @@ -67,7 +67,8 @@ public class RangeTest { assertTrue(9.toByte() in openRange) assertFalse(10.toByte() in openRange) - assertTrue(assertFails { 0.toByte() until Byte.MIN_VALUE } is IllegalArgumentException) + // byte arguments now construct IntRange so no overflow here + // assertTrue(assertFails { 0.toByte() until Byte.MIN_VALUE } is IllegalArgumentException) } @@ -100,7 +101,8 @@ public class RangeTest { assertTrue(9.toShort() in openRange) assertFalse(10.toShort() in openRange) - assertTrue(assertFails { 0.toShort() until Short.MIN_VALUE } is IllegalArgumentException) + // short arguments now construct IntRange so no overflow here + // assertTrue(assertFails { 0.toShort() until Short.MIN_VALUE } is IllegalArgumentException) } @test fun longRange() {