diff --git a/compiler/testData/codegen/box/ranges/expression/emptyDownto.kt b/compiler/testData/codegen/box/ranges/expression/emptyDownto.kt index f583daba798..78d71e249bb 100644 --- a/compiler/testData/codegen/box/ranges/expression/emptyDownto.kt +++ b/compiler/testData/codegen/box/ranges/expression/emptyDownto.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'a' downTo 'z': $list5" } + val list6 = ArrayList() + val range6 = 5u downTo 10u + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for 5u downTo 10u: $list6" + } + + val list7 = ArrayList() + val range7 = 5u.toUByte() downTo 10u.toUByte() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for 5u.toUByte() downTo 10u.toUByte(): $list7" + } + + val list8 = ArrayList() + val range8 = 5u.toUShort() downTo 10u.toUShort() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for 5u.toUShort() downTo 10u.toUShort(): $list8" + } + + val list9 = ArrayList() + val range9 = 5uL downTo 10uL + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for 5uL downTo 10uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/inexactDownToMinValue.kt b/compiler/testData/codegen/box/ranges/expression/inexactDownToMinValue.kt index 79ba651fb3b..9b9f1ac4e3c 100644 --- a/compiler/testData/codegen/box/ranges/expression/inexactDownToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/inexactDownToMinValue.kt @@ -10,6 +10,10 @@ const val MinB = Byte.MIN_VALUE const val MinS = Short.MIN_VALUE const val MinL = Long.MIN_VALUE const val MinC = Char.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUB = UByte.MIN_VALUE +const val MinUS = UShort.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -62,5 +66,45 @@ fun box(): String { return "Wrong elements for (MinC + 5) downTo MinC step 3: $list5" } + val list6 = ArrayList() + val range6 = (MinUI + 5u) downTo MinUI step 3 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MinUI + 5u, MinUI + 2u)) { + return "Wrong elements for (MinUI + 5u) downTo MinUI step 3: $list6" + } + + val list7 = ArrayList() + val range7 = (MinUB + 5u).toUByte() downTo MinUB step 3 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MinUB + 5u).toUInt(), (MinUB + 2u).toUInt())) { + return "Wrong elements for (MinUB + 5u).toUByte() downTo MinUB step 3: $list7" + } + + val list8 = ArrayList() + val range8 = (MinUS + 5u).toUShort() downTo MinUS step 3 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MinUS + 5u).toUInt(), (MinUS + 2u).toUInt())) { + return "Wrong elements for (MinUS + 5u).toUShort() downTo MinUS step 3: $list8" + } + + val list9 = ArrayList() + val range9 = MinUL + 5u downTo MinUL step 3 + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf((MinUL + 5u), (MinUL + 2u))) { + return "Wrong elements for MinUL + 5u downTo MinUL step 3: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/inexactSteppedDownTo.kt b/compiler/testData/codegen/box/ranges/expression/inexactSteppedDownTo.kt index c00690bc629..511ac1e6994 100644 --- a/compiler/testData/codegen/box/ranges/expression/inexactSteppedDownTo.kt +++ b/compiler/testData/codegen/box/ranges/expression/inexactSteppedDownTo.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'd' downTo 'a' step 2: $list5" } + val list6 = ArrayList() + val range6 = 8u downTo 3u step 2 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8u downTo 3u step 2: $list6" + } + + val list7 = ArrayList() + val range7 = 8u.toUByte() downTo 3u.toUByte() step 2 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8u.toUByte() downTo 3u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + val range8 = 8u.toUShort() downTo 3u.toUShort() step 2 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8u.toUShort() downTo 3u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + val range9 = 8uL downTo 3uL step 2L + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8uL downTo 3uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/inexactSteppedRange.kt b/compiler/testData/codegen/box/ranges/expression/inexactSteppedRange.kt index 1ec8fad9fd3..4eb0d644fcd 100644 --- a/compiler/testData/codegen/box/ranges/expression/inexactSteppedRange.kt +++ b/compiler/testData/codegen/box/ranges/expression/inexactSteppedRange.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'a'..'d' step 2: $list5" } + val list6 = ArrayList() + val range6 = 3u..8u step 2 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3u..8u step 2: $list6" + } + + val list7 = ArrayList() + val range7 = 3u.toUByte()..8u.toUByte() step 2 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3u.toUByte()..8u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + val range8 = 3u.toUShort()..8u.toUShort() step 2 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3u.toUShort()..8u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + val range9 = 3uL..8uL step 2L + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3uL..8uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/inexactToMaxValue.kt b/compiler/testData/codegen/box/ranges/expression/inexactToMaxValue.kt index 3fd404fe696..8bfb27c8ec1 100644 --- a/compiler/testData/codegen/box/ranges/expression/inexactToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/inexactToMaxValue.kt @@ -10,6 +10,10 @@ const val MaxB = Byte.MAX_VALUE const val MaxS = Short.MAX_VALUE const val MaxL = Long.MAX_VALUE const val MaxC = Char.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUB = UByte.MAX_VALUE +const val MaxUS = UShort.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -62,5 +66,45 @@ fun box(): String { return "Wrong elements for (MaxC - 5)..MaxC step 3: $list5" } + val list6 = ArrayList() + val range6 = (MaxUI - 5u)..MaxUI step 3 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MaxUI - 5u, MaxUI - 2u)) { + return "Wrong elements for (MaxUI - 5u)..MaxUI step 3: $list6" + } + + val list7 = ArrayList() + val range7 = (MaxUB - 5u).toUByte()..MaxUB step 3 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MaxUB - 5u).toUInt(), (MaxUB - 2u).toUInt())) { + return "Wrong elements for (MaxUB - 5u).toUByte()..MaxUB step 3: $list7" + } + + val list8 = ArrayList() + val range8 = (MaxUS - 5u).toUShort()..MaxUS step 3 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MaxUS - 5u).toUInt(), (MaxUS - 2u).toUInt())) { + return "Wrong elements for (MaxUS - 5u).toUShort()..MaxUS step 3: $list8" + } + + val list9 = ArrayList() + val range9 = (MaxUL - 5u)..MaxUL step 3 + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf((MaxUL - 5u), (MaxUL - 2u))) { + return "Wrong elements for (MaxUL - 5u)..MaxUL step 3: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/oneElementDownTo.kt b/compiler/testData/codegen/box/ranges/expression/oneElementDownTo.kt index 975a33f0a8c..544e1d7432e 100644 --- a/compiler/testData/codegen/box/ranges/expression/oneElementDownTo.kt +++ b/compiler/testData/codegen/box/ranges/expression/oneElementDownTo.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'k' downTo 'k': $list5" } + val list6 = ArrayList() + val range6 = 5u downTo 5u + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(5u)) { + return "Wrong elements for 5u downTo 5u: $list6" + } + + val list7 = ArrayList() + val range7 = 5u.toUByte() downTo 5u.toUByte() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(5u)) { + return "Wrong elements for 5u.toUByte() downTo 5u.toUByte(): $list7" + } + + val list8 = ArrayList() + val range8 = 5u.toUShort() downTo 5u.toUShort() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(5u)) { + return "Wrong elements for 5u.toUShort() downTo 5u.toUShort(): $list8" + } + + val list9 = ArrayList() + val range9 = 5uL downTo 5uL + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(5uL)) { + return "Wrong elements for 5uL downTo 5uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/openRange.kt b/compiler/testData/codegen/box/ranges/expression/openRange.kt index 50f862552af..f877d95010f 100644 --- a/compiler/testData/codegen/box/ranges/expression/openRange.kt +++ b/compiler/testData/codegen/box/ranges/expression/openRange.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'a' until 'd': $list5" } + val list6 = ArrayList() + val range6 = 1u until 5u + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1u until 5u: $list6" + } + + val list7 = ArrayList() + val range7 = 1u.toUByte() until 5u.toUByte() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1u.toUByte() until 5u.toUByte(): $list7" + } + + val list8 = ArrayList() + val range8 = 1u.toUShort() until 5u.toUShort() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1u.toUShort() until 5u.toUShort(): $list8" + } + + val list9 = ArrayList() + val range9 = 1uL until 5uL + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1uL until 5uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/overflowZeroDownToMaxValue.kt b/compiler/testData/codegen/box/ranges/expression/overflowZeroDownToMaxValue.kt index 40fcbe2e2ab..1e1d855cec6 100644 --- a/compiler/testData/codegen/box/ranges/expression/overflowZeroDownToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/overflowZeroDownToMaxValue.kt @@ -7,6 +7,8 @@ const val MaxI = Int.MAX_VALUE const val MaxL = Long.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -29,5 +31,25 @@ fun box(): String { return "Wrong elements for 0 downTo MaxL step 3: $list2" } + val list3 = ArrayList() + val range3 = 0u downTo MaxUI step 3 + for (i in range3) { + list3.add(i) + if (list3.size > 23) break + } + if (list3 != listOf()) { + return "Wrong elements for 0u downTo MaxUI step 3: $list3" + } + + val list4 = ArrayList() + val range4 = 0uL downTo MaxUL step 3 + for (i in range4) { + list4.add(i) + if (list4.size > 23) break + } + if (list4 != listOf()) { + return "Wrong elements for 0uL downTo MaxUL step 3: $list4" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/overflowZeroToMinValue.kt b/compiler/testData/codegen/box/ranges/expression/overflowZeroToMinValue.kt index 99f01e4e741..b21e2754b3c 100644 --- a/compiler/testData/codegen/box/ranges/expression/overflowZeroToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/overflowZeroToMinValue.kt @@ -7,6 +7,8 @@ const val MinI = Int.MIN_VALUE const val MinL = Long.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -29,5 +31,25 @@ fun box(): String { return "Wrong elements for 0L..MinL step 3: $list2" } + val list3 = ArrayList() + val range3 = 1u..MinUI step 3 + for (i in range3) { + list3.add(i) + if (list3.size > 23) break + } + if (list3 != listOf()) { + return "Wrong elements for 1u..MinUI step 3: $list3" + } + + val list4 = ArrayList() + val range4 = 1uL..MinUL step 3 + for (i in range4) { + list4.add(i) + if (list4.size > 23) break + } + if (list4 != listOf()) { + return "Wrong elements for 1uL..MinUL step 3: $list4" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/progressionDownToMinValue.kt b/compiler/testData/codegen/box/ranges/expression/progressionDownToMinValue.kt index 7d701ce34d1..99b48a8cb3d 100644 --- a/compiler/testData/codegen/box/ranges/expression/progressionDownToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/progressionDownToMinValue.kt @@ -10,6 +10,10 @@ const val MinB = Byte.MIN_VALUE const val MinS = Short.MIN_VALUE const val MinL = Long.MIN_VALUE const val MinC = Char.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUB = UByte.MIN_VALUE +const val MinUS = UShort.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -62,5 +66,45 @@ fun box(): String { return "Wrong elements for (MinC + 2) downTo MinC step 1: $list5" } + val list6 = ArrayList() + val range6 = (MinUI + 2u) downTo MinUI step 1 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MinUI + 2u, MinUI + 1u, MinUI)) { + return "Wrong elements for (MinUI + 2u) downTo MinUI step 1: $list6" + } + + val list7 = ArrayList() + val range7 = (MinUB + 2u).toUByte() downTo MinUB step 1 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MinUB + 2u).toUInt(), (MinUB + 1u).toUInt(), MinUB.toUInt())) { + return "Wrong elements for (MinUB + 2u).toUByte() downTo MinUB step 1: $list7" + } + + val list8 = ArrayList() + val range8 = (MinUS + 2u).toUShort() downTo MinUS step 1 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MinUS + 2u).toUInt(), (MinUS + 1u).toUInt(), MinUS.toUInt())) { + return "Wrong elements for (MinUS + 2u).toUShort() downTo MinUS step 1: $list8" + } + + val list9 = ArrayList() + val range9 = (MinUL + 2u) downTo MinUL step 1 + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf((MinUL + 2u), (MinUL + 1u), MinUL)) { + return "Wrong elements for (MinUL + 2u) downTo MinUL step 1: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt index b02badbaeb0..124c9bf859c 100644 --- a/compiler/testData/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/progressionMaxValueMinusTwoToMaxValue.kt @@ -10,6 +10,10 @@ const val MaxB = Byte.MAX_VALUE const val MaxS = Short.MAX_VALUE const val MaxL = Long.MAX_VALUE const val MaxC = Char.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUB = UByte.MAX_VALUE +const val MaxUS = UShort.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -62,5 +66,45 @@ fun box(): String { return "Wrong elements for (MaxC - 2)..MaxC step 2: $list5" } + val list6 = ArrayList() + val range6 = (MaxUI - 2u)..MaxUI step 2 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MaxUI - 2u, MaxUI)) { + return "Wrong elements for (MaxUI - 2u)..MaxUI step 2: $list6" + } + + val list7 = ArrayList() + val range7 = (MaxUB - 2u).toUByte()..MaxUB step 2 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MaxUB - 2u).toUInt(), MaxUB.toUInt())) { + return "Wrong elements for (MaxUB - 2u).toUByte()..MaxUB step 2: $list7" + } + + val list8 = ArrayList() + val range8 = (MaxUS - 2u).toUShort()..MaxUS step 2 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MaxUS - 2u).toUInt(), MaxUS.toUInt())) { + return "Wrong elements for (MaxUS - 2u).toUShort()..MaxUS step 2: $list8" + } + + val list9 = ArrayList() + val range9 = MaxUL - 2u..MaxUL step 2 + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(MaxUL - 2u, MaxUL)) { + return "Wrong elements for MaxUL - 2u..MaxUL step 2: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt b/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt index 7e537aed6f8..8961195adcf 100644 --- a/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMaxValue.kt @@ -10,6 +10,8 @@ const val MaxB = Byte.MAX_VALUE const val MaxS = Short.MAX_VALUE const val MaxL = Long.MAX_VALUE const val MaxC = Char.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -62,5 +64,25 @@ fun box(): String { return "Wrong elements for MaxC..MaxC step 1: $list5" } + val list6 = ArrayList() + val range6 = MaxUI..MaxUI step 1 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MaxUI)) { + return "Wrong elements for MaxUI..MaxUI step 1: $list6" + } + + val list7 = ArrayList() + val range7 = MaxUL..MaxUL step 1 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(MaxUL)) { + return "Wrong elements for MaxUL..MaxUL step 1: $list7" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt b/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt index 8ae9c9e874d..3d636e34668 100644 --- a/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/progressionMaxValueToMinValue.kt @@ -15,6 +15,14 @@ const val MaxL = Long.MAX_VALUE const val MinL = Long.MIN_VALUE const val MaxC = Char.MAX_VALUE const val MinC = Char.MIN_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MinUI = UInt.MIN_VALUE +const val MaxUB = UByte.MAX_VALUE +const val MinUB = UByte.MIN_VALUE +const val MaxUS = UShort.MAX_VALUE +const val MinUS = UShort.MIN_VALUE +const val MaxUL = ULong.MAX_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -67,5 +75,45 @@ fun box(): String { return "Wrong elements for MaxC..MinC step 1: $list5" } + val list6 = ArrayList() + val range6 = MaxUI..MinUI step 1 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for MaxUI..MinUI step 1: $list6" + } + + val list7 = ArrayList() + val range7 = MaxUB..MinUB step 1 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for MaxUB..MinUB step 1: $list7" + } + + val list8 = ArrayList() + val range8 = MaxUS..MinUS step 1 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for MaxUS..MinUS step 1: $list8" + } + + val list9 = ArrayList() + val range9 = MaxUL..MinUL step 1 + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for MaxUL..MinUL step 1: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/progressionMinValueToMinValue.kt b/compiler/testData/codegen/box/ranges/expression/progressionMinValueToMinValue.kt index 7609130c065..5fd3aebd699 100644 --- a/compiler/testData/codegen/box/ranges/expression/progressionMinValueToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/expression/progressionMinValueToMinValue.kt @@ -10,6 +10,10 @@ const val MinB = Byte.MIN_VALUE const val MinS = Short.MIN_VALUE const val MinL = Long.MIN_VALUE const val MinC = Char.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUB = UByte.MIN_VALUE +const val MinUS = UShort.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -62,5 +66,45 @@ fun box(): String { return "Wrong elements for MinC..MinC step 1: $list5" } + val list6 = ArrayList() + val range6 = MinUI..MinUI step 1 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MinUI)) { + return "Wrong elements for MinUI..MinUI step 1: $list6" + } + + val list7 = ArrayList() + val range7 = MinUB..MinUB step 1 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(MinUB.toUInt())) { + return "Wrong elements for MinUB..MinUB step 1: $list7" + } + + val list8 = ArrayList() + val range8 = MinUS..MinUS step 1 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(MinUS.toUInt())) { + return "Wrong elements for MinUS..MinUS step 1: $list8" + } + + val list9 = ArrayList() + val range9 = MinUL..MinUL step 1 + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(MinUL)) { + return "Wrong elements for MinUL..MinUL step 1: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/reversedBackSequence.kt b/compiler/testData/codegen/box/ranges/expression/reversedBackSequence.kt index c4bdbb80547..7662bd4139d 100644 --- a/compiler/testData/codegen/box/ranges/expression/reversedBackSequence.kt +++ b/compiler/testData/codegen/box/ranges/expression/reversedBackSequence.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for ('c' downTo 'a').reversed(): $list5" } + val list6 = ArrayList() + val range6 = (5u downTo 3u).reversed() + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5u downTo 3u).reversed(): $list6" + } + + val list7 = ArrayList() + val range7 = (5u.toUByte() downTo 3u.toUByte()).reversed() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5u.toUByte() downTo 3u.toUByte()).reversed(): $list7" + } + + val list8 = ArrayList() + val range8 = (5u.toUShort() downTo 3u.toUShort()).reversed() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5u.toUShort() downTo 3u.toUShort()).reversed(): $list8" + } + + val list9 = ArrayList() + val range9 = (5uL downTo 3uL).reversed() + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5uL downTo 3uL).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/reversedEmptyBackSequence.kt b/compiler/testData/codegen/box/ranges/expression/reversedEmptyBackSequence.kt index 444023dd38d..bf6e04188fe 100644 --- a/compiler/testData/codegen/box/ranges/expression/reversedEmptyBackSequence.kt +++ b/compiler/testData/codegen/box/ranges/expression/reversedEmptyBackSequence.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for ('a' downTo 'c').reversed(): $list5" } + val list6 = ArrayList() + val range6 = (3u downTo 5u).reversed() + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for (3u downTo 5u).reversed(): $list6" + } + + val list7 = ArrayList() + val range7 = (3u.toUByte() downTo 5u.toUByte()).reversed() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for (3u.toUByte() downTo 5u.toUByte()).reversed(): $list7" + } + + val list8 = ArrayList() + val range8 = (3u.toUShort() downTo 5u.toUShort()).reversed() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for (3u.toUShort() downTo 5u.toUShort()).reversed(): $list8" + } + + val list9 = ArrayList() + val range9 = (3uL downTo 5uL).reversed() + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for (3uL downTo 5uL).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/reversedEmptyRange.kt b/compiler/testData/codegen/box/ranges/expression/reversedEmptyRange.kt index c9371d31c64..aad563b1ed5 100644 --- a/compiler/testData/codegen/box/ranges/expression/reversedEmptyRange.kt +++ b/compiler/testData/codegen/box/ranges/expression/reversedEmptyRange.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for ('c'..'a').reversed(): $list5" } + val list6 = ArrayList() + val range6 = (5u..3u).reversed() + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for (5u..3u).reversed(): $list6" + } + + val list7 = ArrayList() + val range7 = (5u.toUByte()..3u.toUByte()).reversed() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for (5u.toUByte()..3u.toUByte()).reversed(): $list7" + } + + val list8 = ArrayList() + val range8 = (5u.toUShort()..3u.toUShort()).reversed() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for (5u.toUShort()..3u.toUShort()).reversed(): $list8" + } + + val list9 = ArrayList() + val range9 = (5uL..3uL).reversed() + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for (5uL..3uL).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/reversedInexactSteppedDownTo.kt b/compiler/testData/codegen/box/ranges/expression/reversedInexactSteppedDownTo.kt index a60f721fa12..ff636cce3f6 100644 --- a/compiler/testData/codegen/box/ranges/expression/reversedInexactSteppedDownTo.kt +++ b/compiler/testData/codegen/box/ranges/expression/reversedInexactSteppedDownTo.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for ('d' downTo 'a' step 2).reversed(): $list5" } + val list6 = ArrayList() + val range6 = (8u downTo 3u step 2).reversed() + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8u downTo 3u step 2).reversed(): $list6" + } + + val list7 = ArrayList() + val range7 = (8u.toUByte() downTo 3u.toUByte() step 2).reversed() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8u.toUByte() downTo 3u.toUByte() step 2).reversed(): $list7" + } + + val list8 = ArrayList() + val range8 = (8u.toUShort() downTo 3u.toUShort() step 2).reversed() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8u.toUShort() downTo 3u.toUShort() step 2).reversed(): $list8" + } + + val list9 = ArrayList() + val range9 = (8uL downTo 3uL step 2L).reversed() + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8uL downTo 3uL step 2L).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/reversedRange.kt b/compiler/testData/codegen/box/ranges/expression/reversedRange.kt index 6a4633971f2..e49db2a6d2e 100644 --- a/compiler/testData/codegen/box/ranges/expression/reversedRange.kt +++ b/compiler/testData/codegen/box/ranges/expression/reversedRange.kt @@ -47,5 +47,35 @@ fun box(): String { return "Wrong elements for ('a'..'c').reversed(): $list4" } + val list5 = ArrayList() + val range5 = (3u..5u).reversed() + for (i in range5) { + list5.add(i) + if (list5.size > 23) break + } + if (list5 != listOf(5u, 4u, 3u)) { + return "Wrong elements for (3u..5u).reversed(): $list5" + } + + val list6 = ArrayList() + val range6 = (3u.toUShort()..5u.toUShort()).reversed() + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(5u, 4u, 3u)) { + return "Wrong elements for (3u.toUShort()..5u.toUShort()).reversed(): $list6" + } + + val list7 = ArrayList() + val range7 = (3uL..5uL).reversed() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(5u, 4u, 3u)) { + return "Wrong elements for (3uL..5uL).reversed(): $list7" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/reversedSimpleSteppedRange.kt b/compiler/testData/codegen/box/ranges/expression/reversedSimpleSteppedRange.kt index 12858695900..1241ee35a15 100644 --- a/compiler/testData/codegen/box/ranges/expression/reversedSimpleSteppedRange.kt +++ b/compiler/testData/codegen/box/ranges/expression/reversedSimpleSteppedRange.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for ('c'..'g' step 2).reversed(): $list5" } + val list6 = ArrayList() + val range6 = (3u..9u step 2).reversed() + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3u..9u step 2).reversed(): $list6" + } + + val list7 = ArrayList() + val range7 = (3u.toUByte()..9u.toUByte() step 2).reversed() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3u.toUByte()..9u.toUByte() step 2).reversed(): $list7" + } + + val list8 = ArrayList() + val range8 = (3u.toUShort()..9u.toUShort() step 2).reversed() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3u.toUShort()..9u.toUShort() step 2).reversed(): $list8" + } + + val list9 = ArrayList() + val range9 = (3uL..9uL step 2L).reversed() + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3uL..9uL step 2L).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/simpleDownTo.kt b/compiler/testData/codegen/box/ranges/expression/simpleDownTo.kt index 84129e09fd5..efc7846b708 100644 --- a/compiler/testData/codegen/box/ranges/expression/simpleDownTo.kt +++ b/compiler/testData/codegen/box/ranges/expression/simpleDownTo.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c': $list5" } + val list6 = ArrayList() + val range6 = 5u downTo 3u + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5u downTo 3u: $list6" + } + + val list7 = ArrayList() + val range7 = 5u.toUByte() downTo 3u.toUByte() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5u.toUByte() downTo 3u.toUByte(): $list7" + } + + val list8 = ArrayList() + val range8 = 5u.toUShort() downTo 3u.toUShort() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5u.toUShort() downTo 3u.toUShort(): $list8" + } + + val list9 = ArrayList() + val range9 = 5uL downTo 3uL + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5uL downTo 3uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt index 0b2e4bd072a..c361b6d2d9f 100644 --- a/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/box/ranges/expression/simpleRangeWithNonConstantEnds.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for (\"ace\"[1])..(\"age\"[1]): $list5" } + val list6 = ArrayList() + val range6 = (1u + 2u)..(6u - 1u) + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1u + 2u)..(6u - 1u): $list6" + } + + val list7 = ArrayList() + val range7 = (1u.toUByte() + 2u.toUByte()).toUByte()..(6u.toUByte() - 1u.toUByte()).toUByte() + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1u.toUByte() + 2u.toUByte()).toUByte()..(6u.toUByte() - 1u.toUByte()).toUByte(): $list7" + } + + val list8 = ArrayList() + val range8 = (1u.toUShort() + 2u.toUShort()).toUShort()..(6u.toUShort() - 1u.toUShort()).toUShort() + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1u.toUShort() + 2u.toUShort()).toUShort()..(6u.toUShort() - 1u.toUShort()).toUShort(): $list8" + } + + val list9 = ArrayList() + val range9 = (1uL + 2uL)..(6uL - 1uL) + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1uL + 2uL)..(6uL - 1uL): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/simpleSteppedDownTo.kt b/compiler/testData/codegen/box/ranges/expression/simpleSteppedDownTo.kt index a98a8e82aa9..aadbefc78d5 100644 --- a/compiler/testData/codegen/box/ranges/expression/simpleSteppedDownTo.kt +++ b/compiler/testData/codegen/box/ranges/expression/simpleSteppedDownTo.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c' step 2: $list5" } + val list6 = ArrayList() + val range6 = 9u downTo 3u step 2 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9u downTo 3u step 2: $list6" + } + + val list7 = ArrayList() + val range7 = 9u.toUByte() downTo 3u.toUByte() step 2 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9u.toUByte() downTo 3u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + val range8 = 9u.toUShort() downTo 3u.toUShort() step 2 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9u.toUShort() downTo 3u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + val range9 = 9uL downTo 3uL step 2L + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9uL downTo 3uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/expression/simpleSteppedRange.kt b/compiler/testData/codegen/box/ranges/expression/simpleSteppedRange.kt index 08e7c3f9ca2..8a9af6ff1e5 100644 --- a/compiler/testData/codegen/box/ranges/expression/simpleSteppedRange.kt +++ b/compiler/testData/codegen/box/ranges/expression/simpleSteppedRange.kt @@ -57,5 +57,45 @@ fun box(): String { return "Wrong elements for 'c'..'g' step 2: $list5" } + val list6 = ArrayList() + val range6 = 3u..9u step 2 + for (i in range6) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3u..9u step 2: $list6" + } + + val list7 = ArrayList() + val range7 = 3u.toUByte()..9u.toUByte() step 2 + for (i in range7) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3u.toUByte()..9u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + val range8 = 3u.toUShort()..9u.toUShort() step 2 + for (i in range8) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3u.toUShort()..9u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + val range9 = 3uL..9uL step 2L + for (i in range9) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3uL..9uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/emptyDownto.kt b/compiler/testData/codegen/box/ranges/literal/emptyDownto.kt index 0736f140a45..a78e066eb92 100644 --- a/compiler/testData/codegen/box/ranges/literal/emptyDownto.kt +++ b/compiler/testData/codegen/box/ranges/literal/emptyDownto.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'a' downTo 'z': $list5" } + val list6 = ArrayList() + for (i in 5u downTo 10u) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for 5u downTo 10u: $list6" + } + + val list7 = ArrayList() + for (i in 5u.toUByte() downTo 10u.toUByte()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for 5u.toUByte() downTo 10u.toUByte(): $list7" + } + + val list8 = ArrayList() + for (i in 5u.toUShort() downTo 10u.toUShort()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for 5u.toUShort() downTo 10u.toUShort(): $list8" + } + + val list9 = ArrayList() + for (i in 5uL downTo 10uL) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for 5uL downTo 10uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/inexactDownToMinValue.kt b/compiler/testData/codegen/box/ranges/literal/inexactDownToMinValue.kt index b0398f00a44..b547ec59189 100644 --- a/compiler/testData/codegen/box/ranges/literal/inexactDownToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/inexactDownToMinValue.kt @@ -10,6 +10,10 @@ const val MinB = Byte.MIN_VALUE const val MinS = Short.MIN_VALUE const val MinL = Long.MIN_VALUE const val MinC = Char.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUB = UByte.MIN_VALUE +const val MinUS = UShort.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -57,5 +61,41 @@ fun box(): String { return "Wrong elements for (MinC + 5) downTo MinC step 3: $list5" } + val list6 = ArrayList() + for (i in (MinUI + 5u) downTo MinUI step 3) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MinUI + 5u, MinUI + 2u)) { + return "Wrong elements for (MinUI + 5u) downTo MinUI step 3: $list6" + } + + val list7 = ArrayList() + for (i in (MinUB + 5u).toUByte() downTo MinUB step 3) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MinUB + 5u).toUInt(), (MinUB + 2u).toUInt())) { + return "Wrong elements for (MinUB + 5u).toUByte() downTo MinUB step 3: $list7" + } + + val list8 = ArrayList() + for (i in (MinUS + 5u).toUShort() downTo MinUS step 3) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MinUS + 5u).toUInt(), (MinUS + 2u).toUInt())) { + return "Wrong elements for (MinUS + 5u).toUShort() downTo MinUS step 3: $list8" + } + + val list9 = ArrayList() + for (i in MinUL + 5u downTo MinUL step 3) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf((MinUL + 5u), (MinUL + 2u))) { + return "Wrong elements for MinUL + 5u downTo MinUL step 3: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/inexactSteppedDownTo.kt b/compiler/testData/codegen/box/ranges/literal/inexactSteppedDownTo.kt index f5f0f4291e2..00dd37af3f5 100644 --- a/compiler/testData/codegen/box/ranges/literal/inexactSteppedDownTo.kt +++ b/compiler/testData/codegen/box/ranges/literal/inexactSteppedDownTo.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'd' downTo 'a' step 2: $list5" } + val list6 = ArrayList() + for (i in 8u downTo 3u step 2) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8u downTo 3u step 2: $list6" + } + + val list7 = ArrayList() + for (i in 8u.toUByte() downTo 3u.toUByte() step 2) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8u.toUByte() downTo 3u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + for (i in 8u.toUShort() downTo 3u.toUShort() step 2) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8u.toUShort() downTo 3u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + for (i in 8uL downTo 3uL step 2L) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(8u, 6u, 4u)) { + return "Wrong elements for 8uL downTo 3uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/inexactSteppedRange.kt b/compiler/testData/codegen/box/ranges/literal/inexactSteppedRange.kt index 7eb6553bd16..329ceebec92 100644 --- a/compiler/testData/codegen/box/ranges/literal/inexactSteppedRange.kt +++ b/compiler/testData/codegen/box/ranges/literal/inexactSteppedRange.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'a'..'d' step 2: $list5" } + val list6 = ArrayList() + for (i in 3u..8u step 2) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3u..8u step 2: $list6" + } + + val list7 = ArrayList() + for (i in 3u.toUByte()..8u.toUByte() step 2) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3u.toUByte()..8u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + for (i in 3u.toUShort()..8u.toUShort() step 2) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3u.toUShort()..8u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + for (i in 3uL..8uL step 2L) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 5u, 7u)) { + return "Wrong elements for 3uL..8uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/inexactToMaxValue.kt b/compiler/testData/codegen/box/ranges/literal/inexactToMaxValue.kt index 27c415850db..ce873b8ec74 100644 --- a/compiler/testData/codegen/box/ranges/literal/inexactToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/inexactToMaxValue.kt @@ -10,6 +10,10 @@ const val MaxB = Byte.MAX_VALUE const val MaxS = Short.MAX_VALUE const val MaxL = Long.MAX_VALUE const val MaxC = Char.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUB = UByte.MAX_VALUE +const val MaxUS = UShort.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -57,5 +61,41 @@ fun box(): String { return "Wrong elements for (MaxC - 5)..MaxC step 3: $list5" } + val list6 = ArrayList() + for (i in (MaxUI - 5u)..MaxUI step 3) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MaxUI - 5u, MaxUI - 2u)) { + return "Wrong elements for (MaxUI - 5u)..MaxUI step 3: $list6" + } + + val list7 = ArrayList() + for (i in (MaxUB - 5u).toUByte()..MaxUB step 3) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MaxUB - 5u).toUInt(), (MaxUB - 2u).toUInt())) { + return "Wrong elements for (MaxUB - 5u).toUByte()..MaxUB step 3: $list7" + } + + val list8 = ArrayList() + for (i in (MaxUS - 5u).toUShort()..MaxUS step 3) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MaxUS - 5u).toUInt(), (MaxUS - 2u).toUInt())) { + return "Wrong elements for (MaxUS - 5u).toUShort()..MaxUS step 3: $list8" + } + + val list9 = ArrayList() + for (i in (MaxUL - 5u)..MaxUL step 3) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf((MaxUL - 5u), (MaxUL - 2u))) { + return "Wrong elements for (MaxUL - 5u)..MaxUL step 3: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/oneElementDownTo.kt b/compiler/testData/codegen/box/ranges/literal/oneElementDownTo.kt index c6329e2eec6..353db829d50 100644 --- a/compiler/testData/codegen/box/ranges/literal/oneElementDownTo.kt +++ b/compiler/testData/codegen/box/ranges/literal/oneElementDownTo.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'k' downTo 'k': $list5" } + val list6 = ArrayList() + for (i in 5u downTo 5u) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(5u)) { + return "Wrong elements for 5u downTo 5u: $list6" + } + + val list7 = ArrayList() + for (i in 5u.toUByte() downTo 5u.toUByte()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(5u)) { + return "Wrong elements for 5u.toUByte() downTo 5u.toUByte(): $list7" + } + + val list8 = ArrayList() + for (i in 5u.toUShort() downTo 5u.toUShort()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(5u)) { + return "Wrong elements for 5u.toUShort() downTo 5u.toUShort(): $list8" + } + + val list9 = ArrayList() + for (i in 5uL downTo 5uL) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(5uL)) { + return "Wrong elements for 5uL downTo 5uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/openRange.kt b/compiler/testData/codegen/box/ranges/literal/openRange.kt index d71fcfb5640..73f62c5b965 100644 --- a/compiler/testData/codegen/box/ranges/literal/openRange.kt +++ b/compiler/testData/codegen/box/ranges/literal/openRange.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'a' until 'd': $list5" } + val list6 = ArrayList() + for (i in 1u until 5u) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1u until 5u: $list6" + } + + val list7 = ArrayList() + for (i in 1u.toUByte() until 5u.toUByte()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1u.toUByte() until 5u.toUByte(): $list7" + } + + val list8 = ArrayList() + for (i in 1u.toUShort() until 5u.toUShort()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1u.toUShort() until 5u.toUShort(): $list8" + } + + val list9 = ArrayList() + for (i in 1uL until 5uL) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(1u, 2u, 3u, 4u)) { + return "Wrong elements for 1uL until 5uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/overflowZeroDownToMaxValue.kt b/compiler/testData/codegen/box/ranges/literal/overflowZeroDownToMaxValue.kt index fd456b5a9a9..33d07e35974 100644 --- a/compiler/testData/codegen/box/ranges/literal/overflowZeroDownToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/overflowZeroDownToMaxValue.kt @@ -7,6 +7,8 @@ const val MaxI = Int.MAX_VALUE const val MaxL = Long.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -27,5 +29,23 @@ fun box(): String { return "Wrong elements for 0 downTo MaxL step 3: $list2" } + val list3 = ArrayList() + for (i in 0u downTo MaxUI step 3) { + list3.add(i) + if (list3.size > 23) break + } + if (list3 != listOf()) { + return "Wrong elements for 0u downTo MaxUI step 3: $list3" + } + + val list4 = ArrayList() + for (i in 0uL downTo MaxUL step 3) { + list4.add(i) + if (list4.size > 23) break + } + if (list4 != listOf()) { + return "Wrong elements for 0uL downTo MaxUL step 3: $list4" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/overflowZeroToMinValue.kt b/compiler/testData/codegen/box/ranges/literal/overflowZeroToMinValue.kt index d0cd08f075f..4c28c429d79 100644 --- a/compiler/testData/codegen/box/ranges/literal/overflowZeroToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/overflowZeroToMinValue.kt @@ -7,6 +7,8 @@ const val MinI = Int.MIN_VALUE const val MinL = Long.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -27,5 +29,23 @@ fun box(): String { return "Wrong elements for 0L..MinL step 3: $list2" } + val list3 = ArrayList() + for (i in 1u..MinUI step 3) { + list3.add(i) + if (list3.size > 23) break + } + if (list3 != listOf()) { + return "Wrong elements for 1u..MinUI step 3: $list3" + } + + val list4 = ArrayList() + for (i in 1uL..MinUL step 3) { + list4.add(i) + if (list4.size > 23) break + } + if (list4 != listOf()) { + return "Wrong elements for 1uL..MinUL step 3: $list4" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/progressionDownToMinValue.kt b/compiler/testData/codegen/box/ranges/literal/progressionDownToMinValue.kt index a0694e497b2..4c223e371bd 100644 --- a/compiler/testData/codegen/box/ranges/literal/progressionDownToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/progressionDownToMinValue.kt @@ -10,6 +10,10 @@ const val MinB = Byte.MIN_VALUE const val MinS = Short.MIN_VALUE const val MinL = Long.MIN_VALUE const val MinC = Char.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUB = UByte.MIN_VALUE +const val MinUS = UShort.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -57,5 +61,41 @@ fun box(): String { return "Wrong elements for (MinC + 2) downTo MinC step 1: $list5" } + val list6 = ArrayList() + for (i in (MinUI + 2u) downTo MinUI step 1) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MinUI + 2u, MinUI + 1u, MinUI)) { + return "Wrong elements for (MinUI + 2u) downTo MinUI step 1: $list6" + } + + val list7 = ArrayList() + for (i in (MinUB + 2u).toUByte() downTo MinUB step 1) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MinUB + 2u).toUInt(), (MinUB + 1u).toUInt(), MinUB.toUInt())) { + return "Wrong elements for (MinUB + 2u).toUByte() downTo MinUB step 1: $list7" + } + + val list8 = ArrayList() + for (i in (MinUS + 2u).toUShort() downTo MinUS step 1) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MinUS + 2u).toUInt(), (MinUS + 1u).toUInt(), MinUS.toUInt())) { + return "Wrong elements for (MinUS + 2u).toUShort() downTo MinUS step 1: $list8" + } + + val list9 = ArrayList() + for (i in (MinUL + 2u) downTo MinUL step 1) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf((MinUL + 2u), (MinUL + 1u), MinUL)) { + return "Wrong elements for (MinUL + 2u) downTo MinUL step 1: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt b/compiler/testData/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt index cffc943742b..096e0429148 100644 --- a/compiler/testData/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/progressionMaxValueMinusTwoToMaxValue.kt @@ -10,6 +10,10 @@ const val MaxB = Byte.MAX_VALUE const val MaxS = Short.MAX_VALUE const val MaxL = Long.MAX_VALUE const val MaxC = Char.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUB = UByte.MAX_VALUE +const val MaxUS = UShort.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -57,5 +61,41 @@ fun box(): String { return "Wrong elements for (MaxC - 2)..MaxC step 2: $list5" } + val list6 = ArrayList() + for (i in (MaxUI - 2u)..MaxUI step 2) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MaxUI - 2u, MaxUI)) { + return "Wrong elements for (MaxUI - 2u)..MaxUI step 2: $list6" + } + + val list7 = ArrayList() + for (i in (MaxUB - 2u).toUByte()..MaxUB step 2) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf((MaxUB - 2u).toUInt(), MaxUB.toUInt())) { + return "Wrong elements for (MaxUB - 2u).toUByte()..MaxUB step 2: $list7" + } + + val list8 = ArrayList() + for (i in (MaxUS - 2u).toUShort()..MaxUS step 2) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf((MaxUS - 2u).toUInt(), MaxUS.toUInt())) { + return "Wrong elements for (MaxUS - 2u).toUShort()..MaxUS step 2: $list8" + } + + val list9 = ArrayList() + for (i in MaxUL - 2u..MaxUL step 2) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(MaxUL - 2u, MaxUL)) { + return "Wrong elements for MaxUL - 2u..MaxUL step 2: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt b/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt index edaed80b680..6887a943b32 100644 --- a/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMaxValue.kt @@ -10,6 +10,8 @@ const val MaxB = Byte.MAX_VALUE const val MaxS = Short.MAX_VALUE const val MaxL = Long.MAX_VALUE const val MaxC = Char.MAX_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MaxUL = ULong.MAX_VALUE fun box(): String { val list1 = ArrayList() @@ -57,5 +59,23 @@ fun box(): String { return "Wrong elements for MaxC..MaxC step 1: $list5" } + val list6 = ArrayList() + for (i in MaxUI..MaxUI step 1) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MaxUI)) { + return "Wrong elements for MaxUI..MaxUI step 1: $list6" + } + + val list7 = ArrayList() + for (i in MaxUL..MaxUL step 1) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(MaxUL)) { + return "Wrong elements for MaxUL..MaxUL step 1: $list7" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt b/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt index c3d0fd6299a..69707b704e7 100644 --- a/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/progressionMaxValueToMinValue.kt @@ -15,6 +15,14 @@ const val MaxL = Long.MAX_VALUE const val MinL = Long.MIN_VALUE const val MaxC = Char.MAX_VALUE const val MinC = Char.MIN_VALUE +const val MaxUI = UInt.MAX_VALUE +const val MinUI = UInt.MIN_VALUE +const val MaxUB = UByte.MAX_VALUE +const val MinUB = UByte.MIN_VALUE +const val MaxUS = UShort.MAX_VALUE +const val MinUS = UShort.MIN_VALUE +const val MaxUL = ULong.MAX_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -62,5 +70,41 @@ fun box(): String { return "Wrong elements for MaxC..MinC step 1: $list5" } + val list6 = ArrayList() + for (i in MaxUI..MinUI step 1) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for MaxUI..MinUI step 1: $list6" + } + + val list7 = ArrayList() + for (i in MaxUB..MinUB step 1) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for MaxUB..MinUB step 1: $list7" + } + + val list8 = ArrayList() + for (i in MaxUS..MinUS step 1) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for MaxUS..MinUS step 1: $list8" + } + + val list9 = ArrayList() + for (i in MaxUL..MinUL step 1) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for MaxUL..MinUL step 1: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/progressionMinValueToMinValue.kt b/compiler/testData/codegen/box/ranges/literal/progressionMinValueToMinValue.kt index 33d99174058..9f3be9760f8 100644 --- a/compiler/testData/codegen/box/ranges/literal/progressionMinValueToMinValue.kt +++ b/compiler/testData/codegen/box/ranges/literal/progressionMinValueToMinValue.kt @@ -10,6 +10,10 @@ const val MinB = Byte.MIN_VALUE const val MinS = Short.MIN_VALUE const val MinL = Long.MIN_VALUE const val MinC = Char.MIN_VALUE +const val MinUI = UInt.MIN_VALUE +const val MinUB = UByte.MIN_VALUE +const val MinUS = UShort.MIN_VALUE +const val MinUL = ULong.MIN_VALUE fun box(): String { val list1 = ArrayList() @@ -57,5 +61,41 @@ fun box(): String { return "Wrong elements for MinC..MinC step 1: $list5" } + val list6 = ArrayList() + for (i in MinUI..MinUI step 1) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(MinUI)) { + return "Wrong elements for MinUI..MinUI step 1: $list6" + } + + val list7 = ArrayList() + for (i in MinUB..MinUB step 1) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(MinUB.toUInt())) { + return "Wrong elements for MinUB..MinUB step 1: $list7" + } + + val list8 = ArrayList() + for (i in MinUS..MinUS step 1) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(MinUS.toUInt())) { + return "Wrong elements for MinUS..MinUS step 1: $list8" + } + + val list9 = ArrayList() + for (i in MinUL..MinUL step 1) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(MinUL)) { + return "Wrong elements for MinUL..MinUL step 1: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/reversedBackSequence.kt b/compiler/testData/codegen/box/ranges/literal/reversedBackSequence.kt index 4b6fad56847..f741b0a2a66 100644 --- a/compiler/testData/codegen/box/ranges/literal/reversedBackSequence.kt +++ b/compiler/testData/codegen/box/ranges/literal/reversedBackSequence.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for ('c' downTo 'a').reversed(): $list5" } + val list6 = ArrayList() + for (i in (5u downTo 3u).reversed()) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5u downTo 3u).reversed(): $list6" + } + + val list7 = ArrayList() + for (i in (5u.toUByte() downTo 3u.toUByte()).reversed()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5u.toUByte() downTo 3u.toUByte()).reversed(): $list7" + } + + val list8 = ArrayList() + for (i in (5u.toUShort() downTo 3u.toUShort()).reversed()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5u.toUShort() downTo 3u.toUShort()).reversed(): $list8" + } + + val list9 = ArrayList() + for (i in (5uL downTo 3uL).reversed()) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (5uL downTo 3uL).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/reversedEmptyBackSequence.kt b/compiler/testData/codegen/box/ranges/literal/reversedEmptyBackSequence.kt index f505cf5c68b..d06a9d53eb6 100644 --- a/compiler/testData/codegen/box/ranges/literal/reversedEmptyBackSequence.kt +++ b/compiler/testData/codegen/box/ranges/literal/reversedEmptyBackSequence.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for ('a' downTo 'c').reversed(): $list5" } + val list6 = ArrayList() + for (i in (3u downTo 5u).reversed()) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for (3u downTo 5u).reversed(): $list6" + } + + val list7 = ArrayList() + for (i in (3u.toUByte() downTo 5u.toUByte()).reversed()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for (3u.toUByte() downTo 5u.toUByte()).reversed(): $list7" + } + + val list8 = ArrayList() + for (i in (3u.toUShort() downTo 5u.toUShort()).reversed()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for (3u.toUShort() downTo 5u.toUShort()).reversed(): $list8" + } + + val list9 = ArrayList() + for (i in (3uL downTo 5uL).reversed()) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for (3uL downTo 5uL).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/reversedEmptyRange.kt b/compiler/testData/codegen/box/ranges/literal/reversedEmptyRange.kt index a34b00b7819..bb018f965fb 100644 --- a/compiler/testData/codegen/box/ranges/literal/reversedEmptyRange.kt +++ b/compiler/testData/codegen/box/ranges/literal/reversedEmptyRange.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for ('c'..'a').reversed(): $list5" } + val list6 = ArrayList() + for (i in (5u..3u).reversed()) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf()) { + return "Wrong elements for (5u..3u).reversed(): $list6" + } + + val list7 = ArrayList() + for (i in (5u.toUByte()..3u.toUByte()).reversed()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf()) { + return "Wrong elements for (5u.toUByte()..3u.toUByte()).reversed(): $list7" + } + + val list8 = ArrayList() + for (i in (5u.toUShort()..3u.toUShort()).reversed()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf()) { + return "Wrong elements for (5u.toUShort()..3u.toUShort()).reversed(): $list8" + } + + val list9 = ArrayList() + for (i in (5uL..3uL).reversed()) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf()) { + return "Wrong elements for (5uL..3uL).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/reversedInexactSteppedDownTo.kt b/compiler/testData/codegen/box/ranges/literal/reversedInexactSteppedDownTo.kt index 723977e3938..afd226096a8 100644 --- a/compiler/testData/codegen/box/ranges/literal/reversedInexactSteppedDownTo.kt +++ b/compiler/testData/codegen/box/ranges/literal/reversedInexactSteppedDownTo.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for ('d' downTo 'a' step 2).reversed(): $list5" } + val list6 = ArrayList() + for (i in (8u downTo 3u step 2).reversed()) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8u downTo 3u step 2).reversed(): $list6" + } + + val list7 = ArrayList() + for (i in (8u.toUByte() downTo 3u.toUByte() step 2).reversed()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8u.toUByte() downTo 3u.toUByte() step 2).reversed(): $list7" + } + + val list8 = ArrayList() + for (i in (8u.toUShort() downTo 3u.toUShort() step 2).reversed()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8u.toUShort() downTo 3u.toUShort() step 2).reversed(): $list8" + } + + val list9 = ArrayList() + for (i in (8uL downTo 3uL step 2L).reversed()) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(4u, 6u, 8u)) { + return "Wrong elements for (8uL downTo 3uL step 2L).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/reversedRange.kt b/compiler/testData/codegen/box/ranges/literal/reversedRange.kt index afab3b1e7b1..d3694619443 100644 --- a/compiler/testData/codegen/box/ranges/literal/reversedRange.kt +++ b/compiler/testData/codegen/box/ranges/literal/reversedRange.kt @@ -43,5 +43,32 @@ fun box(): String { return "Wrong elements for ('a'..'c').reversed(): $list4" } + val list5 = ArrayList() + for (i in (3u..5u).reversed()) { + list5.add(i) + if (list5.size > 23) break + } + if (list5 != listOf(5u, 4u, 3u)) { + return "Wrong elements for (3u..5u).reversed(): $list5" + } + + val list6 = ArrayList() + for (i in (3u.toUShort()..5u.toUShort()).reversed()) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(5u, 4u, 3u)) { + return "Wrong elements for (3u.toUShort()..5u.toUShort()).reversed(): $list6" + } + + val list7 = ArrayList() + for (i in (3uL..5uL).reversed()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(5u, 4u, 3u)) { + return "Wrong elements for (3uL..5uL).reversed(): $list7" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/reversedSimpleSteppedRange.kt b/compiler/testData/codegen/box/ranges/literal/reversedSimpleSteppedRange.kt index 8656f0beecf..bfb8897e875 100644 --- a/compiler/testData/codegen/box/ranges/literal/reversedSimpleSteppedRange.kt +++ b/compiler/testData/codegen/box/ranges/literal/reversedSimpleSteppedRange.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for ('c'..'g' step 2).reversed(): $list5" } + val list6 = ArrayList() + for (i in (3u..9u step 2).reversed()) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3u..9u step 2).reversed(): $list6" + } + + val list7 = ArrayList() + for (i in (3u.toUByte()..9u.toUByte() step 2).reversed()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3u.toUByte()..9u.toUByte() step 2).reversed(): $list7" + } + + val list8 = ArrayList() + for (i in (3u.toUShort()..9u.toUShort() step 2).reversed()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3u.toUShort()..9u.toUShort() step 2).reversed(): $list8" + } + + val list9 = ArrayList() + for (i in (3uL..9uL step 2L).reversed()) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for (3uL..9uL step 2L).reversed(): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/simpleDownTo.kt b/compiler/testData/codegen/box/ranges/literal/simpleDownTo.kt index 3064eaec6fa..13b2f0a5bca 100644 --- a/compiler/testData/codegen/box/ranges/literal/simpleDownTo.kt +++ b/compiler/testData/codegen/box/ranges/literal/simpleDownTo.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c': $list5" } + val list6 = ArrayList() + for (i in 5u downTo 3u) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5u downTo 3u: $list6" + } + + val list7 = ArrayList() + for (i in 5u.toUByte() downTo 3u.toUByte()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5u.toUByte() downTo 3u.toUByte(): $list7" + } + + val list8 = ArrayList() + for (i in 5u.toUShort() downTo 3u.toUShort()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5u.toUShort() downTo 3u.toUShort(): $list8" + } + + val list9 = ArrayList() + for (i in 5uL downTo 3uL) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(5u, 4u, 3u)) { + return "Wrong elements for 5uL downTo 3uL: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt index d2ef3da968f..b48fff633bd 100644 --- a/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/box/ranges/literal/simpleRangeWithNonConstantEnds.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for (\"ace\"[1])..(\"age\"[1]): $list5" } + val list6 = ArrayList() + for (i in (1u + 2u)..(6u - 1u)) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1u + 2u)..(6u - 1u): $list6" + } + + val list7 = ArrayList() + for (i in (1u.toUByte() + 2u.toUByte()).toUByte()..(6u.toUByte() - 1u.toUByte()).toUByte()) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1u.toUByte() + 2u.toUByte()).toUByte()..(6u.toUByte() - 1u.toUByte()).toUByte(): $list7" + } + + val list8 = ArrayList() + for (i in (1u.toUShort() + 2u.toUShort()).toUShort()..(6u.toUShort() - 1u.toUShort()).toUShort()) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1u.toUShort() + 2u.toUShort()).toUShort()..(6u.toUShort() - 1u.toUShort()).toUShort(): $list8" + } + + val list9 = ArrayList() + for (i in (1uL + 2uL)..(6uL - 1uL)) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 4u, 5u)) { + return "Wrong elements for (1uL + 2uL)..(6uL - 1uL): $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/simpleSteppedDownTo.kt b/compiler/testData/codegen/box/ranges/literal/simpleSteppedDownTo.kt index e84ebdb6820..e768b251211 100644 --- a/compiler/testData/codegen/box/ranges/literal/simpleSteppedDownTo.kt +++ b/compiler/testData/codegen/box/ranges/literal/simpleSteppedDownTo.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c' step 2: $list5" } + val list6 = ArrayList() + for (i in 9u downTo 3u step 2) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9u downTo 3u step 2: $list6" + } + + val list7 = ArrayList() + for (i in 9u.toUByte() downTo 3u.toUByte() step 2) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9u.toUByte() downTo 3u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + for (i in 9u.toUShort() downTo 3u.toUShort() step 2) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9u.toUShort() downTo 3u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + for (i in 9uL downTo 3uL step 2L) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(9u, 7u, 5u, 3u)) { + return "Wrong elements for 9uL downTo 3uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/testData/codegen/box/ranges/literal/simpleSteppedRange.kt b/compiler/testData/codegen/box/ranges/literal/simpleSteppedRange.kt index 40408f374bf..9ca857c3eb2 100644 --- a/compiler/testData/codegen/box/ranges/literal/simpleSteppedRange.kt +++ b/compiler/testData/codegen/box/ranges/literal/simpleSteppedRange.kt @@ -52,5 +52,41 @@ fun box(): String { return "Wrong elements for 'c'..'g' step 2: $list5" } + val list6 = ArrayList() + for (i in 3u..9u step 2) { + list6.add(i) + if (list6.size > 23) break + } + if (list6 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3u..9u step 2: $list6" + } + + val list7 = ArrayList() + for (i in 3u.toUByte()..9u.toUByte() step 2) { + list7.add(i) + if (list7.size > 23) break + } + if (list7 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3u.toUByte()..9u.toUByte() step 2: $list7" + } + + val list8 = ArrayList() + for (i in 3u.toUShort()..9u.toUShort() step 2) { + list8.add(i) + if (list8.size > 23) break + } + if (list8 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3u.toUShort()..9u.toUShort() step 2: $list8" + } + + val list9 = ArrayList() + for (i in 3uL..9uL step 2L) { + list9.add(i) + if (list9.size > 23) break + } + if (list9 != listOf(3u, 5u, 7u, 9u)) { + return "Wrong elements for 3uL..9uL step 2L: $list9" + } + return "OK" } diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java index 3cc5997830b..b1acfcbcc88 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateRangesCodegenTestData.java @@ -90,12 +90,12 @@ public class GenerateRangesCodegenTestData { return getResultingType(ELEMENT_TYPE_KNOWN_SUBSTRINGS.get(substring)); } } - if (Pattern.compile("\\dL").matcher(rangeExpression).find()) { - return "Long"; - } if (Pattern.compile("\\duL", Pattern.CASE_INSENSITIVE).matcher(rangeExpression).find()) { return "ULong"; } + if (Pattern.compile("\\dL").matcher(rangeExpression).find()) { + return "Long"; + } if (Pattern.compile("\\du", Pattern.CASE_INSENSITIVE).matcher(rangeExpression).find()) { return "UInt"; }