diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt index 637c09177f1..64c7d0ca407 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyDownto.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'a' downTo 'z': $list5" } - val list6 = ArrayList() - val range6 = -1.0 downTo 5.0 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for -1.0 downTo 5.0: $list6" - } - - val list7 = ArrayList() - val range7 = -1.0.toFloat() downTo 5.0.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for -1.0.toFloat() downTo 5.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt index 7549218361b..4ed8e3a1f58 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/emptyRange.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'z'..'a': $list5" } - val list6 = ArrayList() - val range6 = 5.0..-1.0 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for 5.0..-1.0: $list6" - } - - val list7 = ArrayList() - val range7 = 5.0.toFloat()..-1.0.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for 5.0.toFloat()..-1.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt index 9b07f4bd9df..953b70cd779 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedDownTo.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'd' downTo 'a' step 2: $list5" } - val list6 = ArrayList() - val range6 = 5.5 downTo 3.7 step 0.5 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(5.5, 5.0, 4.5, 4.0)) { - return "Wrong elements for 5.5 downTo 3.7 step 0.5: $list6" - } - - val list7 = ArrayList() - val range7 = 5.5.toFloat() downTo 3.7.toFloat() step 0.5.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) { - return "Wrong elements for 5.5.toFloat() downTo 3.7.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt index fb1d2abb0f2..ecc3af34145 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/inexactSteppedRange.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'a'..'d' step 2: $list5" } - val list6 = ArrayList() - val range6 = 4.0..5.8 step 0.5 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(4.0, 4.5, 5.0, 5.5)) { - return "Wrong elements for 4.0..5.8 step 0.5: $list6" - } - - val list7 = ArrayList() - val range7 = 4.0.toFloat()..5.8.toFloat() step 0.5.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(4.0.toFloat(), 4.5.toFloat(), 5.0.toFloat(), 5.5.toFloat())) { - return "Wrong elements for 4.0.toFloat()..5.8.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/infiniteSteps.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/infiniteSteps.kt deleted file mode 100644 index 08727806e61..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/infiniteSteps.kt +++ /dev/null @@ -1,46 +0,0 @@ -// Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! -import java.util.ArrayList - -fun box(): String { - val list1 = ArrayList() - val range1 = 0.0..5.0 step java.lang.Double.POSITIVE_INFINITY - for (i in range1) { - list1.add(i) - if (list1.size() > 23) break - } - if (list1 != listOf(0.0)) { - return "Wrong elements for 0.0..5.0 step java.lang.Double.POSITIVE_INFINITY: $list1" - } - - val list2 = ArrayList() - val range2 = 0.0.toFloat()..5.0.toFloat() step java.lang.Float.POSITIVE_INFINITY - for (i in range2) { - list2.add(i) - if (list2.size() > 23) break - } - if (list2 != listOf(0.0.toFloat())) { - return "Wrong elements for 0.0.toFloat()..5.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list2" - } - - val list3 = ArrayList() - val range3 = 5.0 downTo 0.0 step java.lang.Double.POSITIVE_INFINITY - for (i in range3) { - list3.add(i) - if (list3.size() > 23) break - } - if (list3 != listOf(5.0)) { - return "Wrong elements for 5.0 downTo 0.0 step java.lang.Double.POSITIVE_INFINITY: $list3" - } - - val list4 = ArrayList() - val range4 = 5.0.toFloat() downTo 0.0.toFloat() step java.lang.Float.POSITIVE_INFINITY - for (i in range4) { - list4.add(i) - if (list4.size() > 23) break - } - if (list4 != listOf(5.0.toFloat())) { - return "Wrong elements for 5.0.toFloat() downTo 0.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list4" - } - - return "OK" -} diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/nanEnds.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/nanEnds.kt deleted file mode 100644 index dfdafbad7df..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/nanEnds.kt +++ /dev/null @@ -1,126 +0,0 @@ -// Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! -import java.util.ArrayList - -fun box(): String { - val list1 = ArrayList() - val range1 = java.lang.Double.NaN..5.0 - for (i in range1) { - list1.add(i) - if (list1.size() > 23) break - } - if (list1 != listOf()) { - return "Wrong elements for java.lang.Double.NaN..5.0: $list1" - } - - val list2 = ArrayList() - val range2 = java.lang.Float.NaN.toFloat()..5.0.toFloat() - for (i in range2) { - list2.add(i) - if (list2.size() > 23) break - } - if (list2 != listOf()) { - return "Wrong elements for java.lang.Float.NaN.toFloat()..5.0.toFloat(): $list2" - } - - val list3 = ArrayList() - val range3 = java.lang.Double.NaN downTo 0.0 - for (i in range3) { - list3.add(i) - if (list3.size() > 23) break - } - if (list3 != listOf()) { - return "Wrong elements for java.lang.Double.NaN downTo 0.0: $list3" - } - - val list4 = ArrayList() - val range4 = java.lang.Float.NaN.toFloat() downTo 0.0.toFloat() - for (i in range4) { - list4.add(i) - if (list4.size() > 23) break - } - if (list4 != listOf()) { - return "Wrong elements for java.lang.Float.NaN.toFloat() downTo 0.0.toFloat(): $list4" - } - - val list5 = ArrayList() - val range5 = 0.0..java.lang.Double.NaN - for (i in range5) { - list5.add(i) - if (list5.size() > 23) break - } - if (list5 != listOf()) { - return "Wrong elements for 0.0..java.lang.Double.NaN: $list5" - } - - val list6 = ArrayList() - val range6 = 0.0.toFloat()..java.lang.Float.NaN - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for 0.0.toFloat()..java.lang.Float.NaN: $list6" - } - - val list7 = ArrayList() - val range7 = 5.0 downTo java.lang.Double.NaN - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for 5.0 downTo java.lang.Double.NaN: $list7" - } - - val list8 = ArrayList() - val range8 = 5.0.toFloat() downTo java.lang.Float.NaN - for (i in range8) { - list8.add(i) - if (list8.size() > 23) break - } - if (list8 != listOf()) { - return "Wrong elements for 5.0.toFloat() downTo java.lang.Float.NaN: $list8" - } - - val list9 = ArrayList() - val range9 = java.lang.Double.NaN..java.lang.Double.NaN - for (i in range9) { - list9.add(i) - if (list9.size() > 23) break - } - if (list9 != listOf()) { - return "Wrong elements for java.lang.Double.NaN..java.lang.Double.NaN: $list9" - } - - val list10 = ArrayList() - val range10 = java.lang.Float.NaN..java.lang.Float.NaN - for (i in range10) { - list10.add(i) - if (list10.size() > 23) break - } - if (list10 != listOf()) { - return "Wrong elements for java.lang.Float.NaN..java.lang.Float.NaN: $list10" - } - - val list11 = ArrayList() - val range11 = java.lang.Double.NaN downTo java.lang.Double.NaN - for (i in range11) { - list11.add(i) - if (list11.size() > 23) break - } - if (list11 != listOf()) { - return "Wrong elements for java.lang.Double.NaN downTo java.lang.Double.NaN: $list11" - } - - val list12 = ArrayList() - val range12 = java.lang.Float.NaN downTo java.lang.Float.NaN - for (i in range12) { - list12.add(i) - if (list12.size() > 23) break - } - if (list12 != listOf()) { - return "Wrong elements for java.lang.Float.NaN downTo java.lang.Float.NaN: $list12" - } - - return "OK" -} diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt index abf9a992895..fdae704411a 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'k' downTo 'k': $list5" } - val list6 = ArrayList() - val range6 = 5.0 downTo 5.0 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(5.0)) { - return "Wrong elements for 5.0 downTo 5.0: $list6" - } - - val list7 = ArrayList() - val range7 = 5.0.toFloat() downTo 5.0.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.0.toFloat())) { - return "Wrong elements for 5.0.toFloat() downTo 5.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt index 750eba6d150..89932cd5169 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementRange.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'k'..'k': $list5" } - val list6 = ArrayList() - val range6 = 5.0..5.0 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(5.0)) { - return "Wrong elements for 5.0..5.0: $list6" - } - - val list7 = ArrayList() - val range7 = 5.0.toFloat()..5.0.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.0.toFloat())) { - return "Wrong elements for 5.0.toFloat()..5.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt index f0349e65ce5..668d6b6a26e 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedBackSequence.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for ('c' downTo 'a').reversed(): $list5" } - val list6 = ArrayList() - val range6 = (5.0 downTo 3.0).reversed() - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(3.0, 4.0, 5.0)) { - return "Wrong elements for (5.0 downTo 3.0).reversed(): $list6" - } - - val list7 = ArrayList() - val range7 = (5.0.toFloat() downTo 3.0.toFloat()).reversed() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat())) { - return "Wrong elements for (5.0.toFloat() downTo 3.0.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt index b61d3da2b38..3416b706d66 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyBackSequence.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for ('a' downTo 'c').reversed(): $list5" } - val list6 = ArrayList() - val range6 = (3.0 downTo 5.0).reversed() - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for (3.0 downTo 5.0).reversed(): $list6" - } - - val list7 = ArrayList() - val range7 = (3.0.toFloat() downTo 5.0.toFloat()).reversed() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for (3.0.toFloat() downTo 5.0.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt index b6efbc34be7..1b902d81203 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedEmptyRange.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for ('c'..'a').reversed(): $list5" } - val list6 = ArrayList() - val range6 = (5.0..3.0).reversed() - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for (5.0..3.0).reversed(): $list6" - } - - val list7 = ArrayList() - val range7 = (5.0.toFloat()..3.0.toFloat()).reversed() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for (5.0.toFloat()..3.0.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt index 57a87bcdb48..9d53637b608 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedRange.kt @@ -42,25 +42,5 @@ fun box(): String { return "Wrong elements for ('a'..'c').reversed(): $list4" } - 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(5.0, 4.0, 3.0)) { - return "Wrong elements for (3.0..5.0).reversed(): $list5" - } - - 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.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 30e122e374a..94352c1e7bc 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedSimpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/reversedSimpleSteppedRange.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for ('c'..'g' step 2).reversed(): $list5" } - val list6 = ArrayList() - val range6 = (4.0..6.0 step 0.5).reversed() - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(6.0, 5.5, 5.0, 4.5, 4.0)) { - return "Wrong elements for (4.0..6.0 step 0.5).reversed(): $list6" - } - - val list7 = ArrayList() - val range7 = (4.0.toFloat()..6.0.toFloat() step 0.5.toFloat()).reversed() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(6.0.toFloat(), 5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) { - return "Wrong elements for (4.0.toFloat()..6.0.toFloat() step 0.5.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt index f0a29bd586a..6c8b2999184 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleDownTo.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c': $list5" } - val list6 = ArrayList() - val range6 = 9.0 downTo 3.0 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0)) { - return "Wrong elements for 9.0 downTo 3.0: $list6" - } - - val list7 = ArrayList() - val range7 = 9.0.toFloat() downTo 3.0.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(9.0.toFloat(), 8.0.toFloat(), 7.0.toFloat(), 6.0.toFloat(), 5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) { - return "Wrong elements for 9.0.toFloat() downTo 3.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt index 5cfc11b85db..4ad830d6734 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRange.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'c'..'g': $list5" } - val list6 = ArrayList() - val range6 = 3.0..9.0 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) { - return "Wrong elements for 3.0..9.0: $list6" - } - - val list7 = ArrayList() - val range7 = 3.0.toFloat()..9.0.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat(), 6.0.toFloat(), 7.0.toFloat(), 8.0.toFloat(), 9.0.toFloat())) { - return "Wrong elements for 3.0.toFloat()..9.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt index b8bb43b8b25..424f1dcbda4 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleRangeWithNonConstantEnds.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for (\"ace\"[1])..(\"age\"[1]): $list5" } - val list6 = ArrayList() - val range6 = (1.5 * 2)..(3.0 * 3.0) - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) { - return "Wrong elements for (1.5 * 2)..(3.0 * 3.0): $list6" - } - - val list7 = ArrayList() - val range7 = (1.5.toFloat() * 2.toFloat())..(3.0.toFloat() * 3.0.toFloat()) - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat(), 6.0.toFloat(), 7.0.toFloat(), 8.0.toFloat(), 9.0.toFloat())) { - return "Wrong elements for (1.5.toFloat() * 2.toFloat())..(3.0.toFloat() * 3.0.toFloat()): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt index 2c648718ab1..758c58fbdc6 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedDownTo.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c' step 2: $list5" } - val list6 = ArrayList() - val range6 = 6.0 downTo 4.0 step 0.5 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(6.0, 5.5, 5.0, 4.5, 4.0)) { - return "Wrong elements for 6.0 downTo 4.0 step 0.5: $list6" - } - - val list7 = ArrayList() - val range7 = 6.0.toFloat() downTo 4.0.toFloat() step 0.5.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(6.0.toFloat(), 5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) { - return "Wrong elements for 6.0.toFloat() downTo 4.0.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt index cec06e72f0e..bcde73c9298 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/expression/simpleSteppedRange.kt @@ -52,25 +52,5 @@ fun box(): String { return "Wrong elements for 'c'..'g' step 2: $list5" } - val list6 = ArrayList() - val range6 = 4.0..6.0 step 0.5 - for (i in range6) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(4.0, 4.5, 5.0, 5.5, 6.0)) { - return "Wrong elements for 4.0..6.0 step 0.5: $list6" - } - - val list7 = ArrayList() - val range7 = 4.0.toFloat()..6.0.toFloat() step 0.5.toFloat() - for (i in range7) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(4.0.toFloat(), 4.5.toFloat(), 5.0.toFloat(), 5.5.toFloat(), 6.0.toFloat())) { - return "Wrong elements for 4.0.toFloat()..6.0.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt index c13e2e10e6f..deaff5263ac 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyDownto.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'a' downTo 'z': $list5" } - val list6 = ArrayList() - for (i in -1.0 downTo 5.0) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for -1.0 downTo 5.0: $list6" - } - - val list7 = ArrayList() - for (i in -1.0.toFloat() downTo 5.0.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for -1.0.toFloat() downTo 5.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt index 22caea4311d..4e7e844738e 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/emptyRange.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'z'..'a': $list5" } - val list6 = ArrayList() - for (i in 5.0..-1.0) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for 5.0..-1.0: $list6" - } - - val list7 = ArrayList() - for (i in 5.0.toFloat()..-1.0.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for 5.0.toFloat()..-1.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt index 6b7476edb8a..2aafcb5b741 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedDownTo.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'd' downTo 'a' step 2: $list5" } - val list6 = ArrayList() - for (i in 5.5 downTo 3.7 step 0.5) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(5.5, 5.0, 4.5, 4.0)) { - return "Wrong elements for 5.5 downTo 3.7 step 0.5: $list6" - } - - val list7 = ArrayList() - for (i in 5.5.toFloat() downTo 3.7.toFloat() step 0.5.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) { - return "Wrong elements for 5.5.toFloat() downTo 3.7.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt index 3e49bb2a685..59942cd2f7e 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/inexactSteppedRange.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'a'..'d' step 2: $list5" } - val list6 = ArrayList() - for (i in 4.0..5.8 step 0.5) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(4.0, 4.5, 5.0, 5.5)) { - return "Wrong elements for 4.0..5.8 step 0.5: $list6" - } - - val list7 = ArrayList() - for (i in 4.0.toFloat()..5.8.toFloat() step 0.5.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(4.0.toFloat(), 4.5.toFloat(), 5.0.toFloat(), 5.5.toFloat())) { - return "Wrong elements for 4.0.toFloat()..5.8.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/infiniteSteps.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/infiniteSteps.kt deleted file mode 100644 index e3c50449324..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/infiniteSteps.kt +++ /dev/null @@ -1,42 +0,0 @@ -// Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! -import java.util.ArrayList - -fun box(): String { - val list1 = ArrayList() - for (i in 0.0..5.0 step java.lang.Double.POSITIVE_INFINITY) { - list1.add(i) - if (list1.size() > 23) break - } - if (list1 != listOf(0.0)) { - return "Wrong elements for 0.0..5.0 step java.lang.Double.POSITIVE_INFINITY: $list1" - } - - val list2 = ArrayList() - for (i in 0.0.toFloat()..5.0.toFloat() step java.lang.Float.POSITIVE_INFINITY) { - list2.add(i) - if (list2.size() > 23) break - } - if (list2 != listOf(0.0.toFloat())) { - return "Wrong elements for 0.0.toFloat()..5.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list2" - } - - val list3 = ArrayList() - for (i in 5.0 downTo 0.0 step java.lang.Double.POSITIVE_INFINITY) { - list3.add(i) - if (list3.size() > 23) break - } - if (list3 != listOf(5.0)) { - return "Wrong elements for 5.0 downTo 0.0 step java.lang.Double.POSITIVE_INFINITY: $list3" - } - - val list4 = ArrayList() - for (i in 5.0.toFloat() downTo 0.0.toFloat() step java.lang.Float.POSITIVE_INFINITY) { - list4.add(i) - if (list4.size() > 23) break - } - if (list4 != listOf(5.0.toFloat())) { - return "Wrong elements for 5.0.toFloat() downTo 0.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list4" - } - - return "OK" -} diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/nanEnds.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/nanEnds.kt deleted file mode 100644 index 7943ad700b6..00000000000 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/nanEnds.kt +++ /dev/null @@ -1,114 +0,0 @@ -// Auto-generated by org.jetbrains.kotlin.generators.tests.GenerateRangesCodegenTestData. DO NOT EDIT! -import java.util.ArrayList - -fun box(): String { - val list1 = ArrayList() - for (i in java.lang.Double.NaN..5.0) { - list1.add(i) - if (list1.size() > 23) break - } - if (list1 != listOf()) { - return "Wrong elements for java.lang.Double.NaN..5.0: $list1" - } - - val list2 = ArrayList() - for (i in java.lang.Float.NaN.toFloat()..5.0.toFloat()) { - list2.add(i) - if (list2.size() > 23) break - } - if (list2 != listOf()) { - return "Wrong elements for java.lang.Float.NaN.toFloat()..5.0.toFloat(): $list2" - } - - val list3 = ArrayList() - for (i in java.lang.Double.NaN downTo 0.0) { - list3.add(i) - if (list3.size() > 23) break - } - if (list3 != listOf()) { - return "Wrong elements for java.lang.Double.NaN downTo 0.0: $list3" - } - - val list4 = ArrayList() - for (i in java.lang.Float.NaN.toFloat() downTo 0.0.toFloat()) { - list4.add(i) - if (list4.size() > 23) break - } - if (list4 != listOf()) { - return "Wrong elements for java.lang.Float.NaN.toFloat() downTo 0.0.toFloat(): $list4" - } - - val list5 = ArrayList() - for (i in 0.0..java.lang.Double.NaN) { - list5.add(i) - if (list5.size() > 23) break - } - if (list5 != listOf()) { - return "Wrong elements for 0.0..java.lang.Double.NaN: $list5" - } - - val list6 = ArrayList() - for (i in 0.0.toFloat()..java.lang.Float.NaN) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for 0.0.toFloat()..java.lang.Float.NaN: $list6" - } - - val list7 = ArrayList() - for (i in 5.0 downTo java.lang.Double.NaN) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for 5.0 downTo java.lang.Double.NaN: $list7" - } - - val list8 = ArrayList() - for (i in 5.0.toFloat() downTo java.lang.Float.NaN) { - list8.add(i) - if (list8.size() > 23) break - } - if (list8 != listOf()) { - return "Wrong elements for 5.0.toFloat() downTo java.lang.Float.NaN: $list8" - } - - val list9 = ArrayList() - for (i in java.lang.Double.NaN..java.lang.Double.NaN) { - list9.add(i) - if (list9.size() > 23) break - } - if (list9 != listOf()) { - return "Wrong elements for java.lang.Double.NaN..java.lang.Double.NaN: $list9" - } - - val list10 = ArrayList() - for (i in java.lang.Float.NaN..java.lang.Float.NaN) { - list10.add(i) - if (list10.size() > 23) break - } - if (list10 != listOf()) { - return "Wrong elements for java.lang.Float.NaN..java.lang.Float.NaN: $list10" - } - - val list11 = ArrayList() - for (i in java.lang.Double.NaN downTo java.lang.Double.NaN) { - list11.add(i) - if (list11.size() > 23) break - } - if (list11 != listOf()) { - return "Wrong elements for java.lang.Double.NaN downTo java.lang.Double.NaN: $list11" - } - - val list12 = ArrayList() - for (i in java.lang.Float.NaN downTo java.lang.Float.NaN) { - list12.add(i) - if (list12.size() > 23) break - } - if (list12 != listOf()) { - return "Wrong elements for java.lang.Float.NaN downTo java.lang.Float.NaN: $list12" - } - - return "OK" -} diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt index 10618967b4b..5c2ba8e430d 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'k' downTo 'k': $list5" } - val list6 = ArrayList() - for (i in 5.0 downTo 5.0) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(5.0)) { - return "Wrong elements for 5.0 downTo 5.0: $list6" - } - - val list7 = ArrayList() - for (i in 5.0.toFloat() downTo 5.0.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.0.toFloat())) { - return "Wrong elements for 5.0.toFloat() downTo 5.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt index 7af5b40fe28..b2cd270f997 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementRange.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'k'..'k': $list5" } - val list6 = ArrayList() - for (i in 5.0..5.0) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(5.0)) { - return "Wrong elements for 5.0..5.0: $list6" - } - - val list7 = ArrayList() - for (i in 5.0.toFloat()..5.0.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(5.0.toFloat())) { - return "Wrong elements for 5.0.toFloat()..5.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt index 3472111e290..9df58a580f9 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedBackSequence.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for ('c' downTo 'a').reversed(): $list5" } - val list6 = ArrayList() - for (i in (5.0 downTo 3.0).reversed()) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(3.0, 4.0, 5.0)) { - return "Wrong elements for (5.0 downTo 3.0).reversed(): $list6" - } - - val list7 = ArrayList() - for (i in (5.0.toFloat() downTo 3.0.toFloat()).reversed()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat())) { - return "Wrong elements for (5.0.toFloat() downTo 3.0.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt index bbd47b6f985..87a568cf051 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyBackSequence.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for ('a' downTo 'c').reversed(): $list5" } - val list6 = ArrayList() - for (i in (3.0 downTo 5.0).reversed()) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for (3.0 downTo 5.0).reversed(): $list6" - } - - val list7 = ArrayList() - for (i in (3.0.toFloat() downTo 5.0.toFloat()).reversed()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for (3.0.toFloat() downTo 5.0.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt index d18c7f0f9e9..a7f5afe958d 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedEmptyRange.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for ('c'..'a').reversed(): $list5" } - val list6 = ArrayList() - for (i in (5.0..3.0).reversed()) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf()) { - return "Wrong elements for (5.0..3.0).reversed(): $list6" - } - - val list7 = ArrayList() - for (i in (5.0.toFloat()..3.0.toFloat()).reversed()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf()) { - return "Wrong elements for (5.0.toFloat()..3.0.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt index 87b2f1e3660..9323c13ca49 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedRange.kt @@ -38,23 +38,5 @@ fun box(): String { return "Wrong elements for ('a'..'c').reversed(): $list4" } - val list5 = ArrayList() - for (i in (3.0..5.0).reversed()) { - list5.add(i) - if (list5.size() > 23) break - } - 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.toFloat()..5.0.toFloat()).reversed()) { - list6.add(i) - if (list6.size() > 23) break - } - 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 f9dc5399440..910c72d8c67 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedSimpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/reversedSimpleSteppedRange.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for ('c'..'g' step 2).reversed(): $list5" } - val list6 = ArrayList() - for (i in (4.0..6.0 step 0.5).reversed()) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(6.0, 5.5, 5.0, 4.5, 4.0)) { - return "Wrong elements for (4.0..6.0 step 0.5).reversed(): $list6" - } - - val list7 = ArrayList() - for (i in (4.0.toFloat()..6.0.toFloat() step 0.5.toFloat()).reversed()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(6.0.toFloat(), 5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) { - return "Wrong elements for (4.0.toFloat()..6.0.toFloat() step 0.5.toFloat()).reversed(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt index b4882be67b2..1a8cb6394c9 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleDownTo.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c': $list5" } - val list6 = ArrayList() - for (i in 9.0 downTo 3.0) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0)) { - return "Wrong elements for 9.0 downTo 3.0: $list6" - } - - val list7 = ArrayList() - for (i in 9.0.toFloat() downTo 3.0.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(9.0.toFloat(), 8.0.toFloat(), 7.0.toFloat(), 6.0.toFloat(), 5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) { - return "Wrong elements for 9.0.toFloat() downTo 3.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt index dbb44a36836..4de044abc72 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRange.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'c'..'g': $list5" } - val list6 = ArrayList() - for (i in 3.0..9.0) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) { - return "Wrong elements for 3.0..9.0: $list6" - } - - val list7 = ArrayList() - for (i in 3.0.toFloat()..9.0.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat(), 6.0.toFloat(), 7.0.toFloat(), 8.0.toFloat(), 9.0.toFloat())) { - return "Wrong elements for 3.0.toFloat()..9.0.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt index 1ee00f49dba..ebbdc189e70 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleRangeWithNonConstantEnds.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for (\"ace\"[1])..(\"age\"[1]): $list5" } - val list6 = ArrayList() - for (i in (1.5 * 2)..(3.0 * 3.0)) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) { - return "Wrong elements for (1.5 * 2)..(3.0 * 3.0): $list6" - } - - val list7 = ArrayList() - for (i in (1.5.toFloat() * 2.toFloat())..(3.0.toFloat() * 3.0.toFloat())) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat(), 6.0.toFloat(), 7.0.toFloat(), 8.0.toFloat(), 9.0.toFloat())) { - return "Wrong elements for (1.5.toFloat() * 2.toFloat())..(3.0.toFloat() * 3.0.toFloat()): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt index 5e6eb9065f4..ca7d8b800ba 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedDownTo.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'g' downTo 'c' step 2: $list5" } - val list6 = ArrayList() - for (i in 6.0 downTo 4.0 step 0.5) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(6.0, 5.5, 5.0, 4.5, 4.0)) { - return "Wrong elements for 6.0 downTo 4.0 step 0.5: $list6" - } - - val list7 = ArrayList() - for (i in 6.0.toFloat() downTo 4.0.toFloat() step 0.5.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(6.0.toFloat(), 5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) { - return "Wrong elements for 6.0.toFloat() downTo 4.0.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt index 6abcb773afd..c399064999b 100644 --- a/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt +++ b/compiler/testData/codegen/boxWithStdlib/ranges/literal/simpleSteppedRange.kt @@ -47,23 +47,5 @@ fun box(): String { return "Wrong elements for 'c'..'g' step 2: $list5" } - val list6 = ArrayList() - for (i in 4.0..6.0 step 0.5) { - list6.add(i) - if (list6.size() > 23) break - } - if (list6 != listOf(4.0, 4.5, 5.0, 5.5, 6.0)) { - return "Wrong elements for 4.0..6.0 step 0.5: $list6" - } - - val list7 = ArrayList() - for (i in 4.0.toFloat()..6.0.toFloat() step 0.5.toFloat()) { - list7.add(i) - if (list7.size() > 23) break - } - if (list7 != listOf(4.0.toFloat(), 4.5.toFloat(), 5.0.toFloat(), 5.5.toFloat(), 6.0.toFloat())) { - return "Wrong elements for 4.0.toFloat()..6.0.toFloat() step 0.5.toFloat(): $list7" - } - return "OK" } diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java index cc217f4e299..9c607fdd272 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxWithStdlibCodegenTestGenerated.java @@ -2751,12 +2751,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("infiniteSteps.kt") - public void testInfiniteSteps() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/expression/infiniteSteps.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("maxValueMinusTwoToMaxValue.kt") public void testMaxValueMinusTwoToMaxValue() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/expression/maxValueMinusTwoToMaxValue.kt"); @@ -2775,12 +2769,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("nanEnds.kt") - public void testNanEnds() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/expression/nanEnds.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("oneElementDownTo.kt") public void testOneElementDownTo() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/expression/oneElementDownTo.kt"); @@ -2940,12 +2928,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("infiniteSteps.kt") - public void testInfiniteSteps() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/literal/infiniteSteps.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("maxValueMinusTwoToMaxValue.kt") public void testMaxValueMinusTwoToMaxValue() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/literal/maxValueMinusTwoToMaxValue.kt"); @@ -2964,12 +2946,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode doTestWithStdlib(fileName); } - @TestMetadata("nanEnds.kt") - public void testNanEnds() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/literal/nanEnds.kt"); - doTestWithStdlib(fileName); - } - @TestMetadata("oneElementDownTo.kt") public void testOneElementDownTo() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/ranges/literal/oneElementDownTo.kt"); diff --git a/core/builtins/native/kotlin/Primitives.kt b/core/builtins/native/kotlin/Primitives.kt index 99a14d03f45..358654ebef4 100644 --- a/core/builtins/native/kotlin/Primitives.kt +++ b/core/builtins/native/kotlin/Primitives.kt @@ -144,10 +144,6 @@ public class Byte private () : Number, Comparable { public operator fun rangeTo(other: Int): IntRange /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Long): LongRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Float): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char @@ -284,10 +280,6 @@ public class Short private () : Number, Comparable { public operator fun rangeTo(other: Int): IntRange /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Long): LongRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Float): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char @@ -424,10 +416,6 @@ public class Int private () : Number, Comparable { public operator fun rangeTo(other: Int): IntRange /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Long): LongRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Float): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Double): DoubleRange /** Shifts this value left by [bits]. */ public infix fun shl(bitCount: Int): Int @@ -579,10 +567,6 @@ public class Long private () : Number, Comparable { public operator fun rangeTo(other: Int): LongRange /** Creates a range from this value to the specified [other] value. */ public operator fun rangeTo(other: Long): LongRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Float): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Double): DoubleRange /** Shifts this value left by [bits]. */ public infix fun shl(bitCount: Int): Long @@ -726,18 +710,6 @@ public class Float private () : Number, Comparable { /** Returns the negative of this value. */ public operator fun unaryMinus(): Float - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Byte): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Short): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Int): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Long): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Float): FloatRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char @@ -866,18 +838,6 @@ public class Double private () : Number, Comparable { /** Returns the negative of this value. */ public operator fun unaryMinus(): Double - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Byte): DoubleRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Short): DoubleRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Int): DoubleRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Long): DoubleRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Float): DoubleRange - /** Creates a range from this value to the specified [other] value. */ - public operator fun rangeTo(other: Double): DoubleRange public override fun toByte(): Byte public override fun toChar(): Char diff --git a/core/builtins/src/kotlin/ProgressionIterators.kt b/core/builtins/src/kotlin/ProgressionIterators.kt index 73d6aed7194..0347d4be818 100644 --- a/core/builtins/src/kotlin/ProgressionIterators.kt +++ b/core/builtins/src/kotlin/ProgressionIterators.kt @@ -135,37 +135,3 @@ internal class LongProgressionIterator(start: Long, end: Long, val increment: Lo } } -/** - * An iterator over a progression of values of type `Float`. - * @property increment the number by which the value is incremented on each step. - */ -@Deprecated("This progression implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) -internal class FloatProgressionIterator(start: Float, val end: Float, val increment: Float) : FloatIterator() { - private var next = start - - override fun hasNext(): Boolean = if (increment > 0) next <= end else next >= end - - override fun nextFloat(): Float { - val value = next - next += increment - return value - } -} - -/** - * An iterator over a progression of values of type `Double`. - * @property increment the number by which the value is incremented on each step. - */ -@Deprecated("This progression implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) -internal class DoubleProgressionIterator(start: Double, val end: Double, val increment: Double) : DoubleIterator() { - private var next = start - - override fun hasNext(): Boolean = if (increment > 0) next <= end else next >= end - - override fun nextDouble(): Double { - val value = next - next += increment - return value - } -} - diff --git a/core/builtins/src/kotlin/Progressions.kt b/core/builtins/src/kotlin/Progressions.kt index da05ccaed58..d25775e2143 100644 --- a/core/builtins/src/kotlin/Progressions.kt +++ b/core/builtins/src/kotlin/Progressions.kt @@ -310,80 +310,3 @@ public open class LongProgression } } -/** - * A progression of values of type `Float`. - */ -@Deprecated("This progression implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) -public open class FloatProgression( - override val start: Float, - val endInclusive: Float, - override val increment: Float -) : Progression /*, Iterable */ { - init { - if (java.lang.Float.isNaN(increment)) throw IllegalArgumentException("Increment must be not NaN") - if (increment == 0.0f) throw IllegalArgumentException("Increment must be non-zero") - } - - /** - * The end value of the progression (inclusive). - */ - @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) - public override val end: Float get() = endInclusive - - override fun iterator(): FloatIterator = FloatProgressionIterator(start, endInclusive, increment) - - /** Checks if the progression is empty. */ - public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive - - override fun equals(other: Any?): Boolean = - other is FloatProgression && (isEmpty() && other.isEmpty() || - java.lang.Float.compare(start, other.start) == 0 && java.lang.Float.compare(endInclusive, other.endInclusive) == 0 && java.lang.Float.compare(increment, other.increment) == 0) - - override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(endInclusive)) + java.lang.Float.floatToIntBits(increment)) - - override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}" -} - -/** - * A progression of values of type `Double`. - */ -@Deprecated("This progression implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) -public open class DoubleProgression( - override val start: Double, - val endInclusive: Double, - override val increment: Double -) : Progression /*, Iterable */ { - init { - if (java.lang.Double.isNaN(increment)) throw IllegalArgumentException("Increment must be not NaN") - if (increment == 0.0) throw IllegalArgumentException("Increment must be non-zero") - } - - /** - * The end value of the progression (inclusive). - */ - @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) - public override val end: Double get() = endInclusive - - override fun iterator(): DoubleIterator = DoubleProgressionIterator(start, endInclusive, increment) - - /** Checks if the progression is empty. */ - public open fun isEmpty(): Boolean = if (increment > 0) start > endInclusive else start < endInclusive - - override fun equals(other: Any?): Boolean = - other is DoubleProgression && (isEmpty() && other.isEmpty() || - java.lang.Double.compare(start, other.start) == 0 && java.lang.Double.compare(endInclusive, other.endInclusive) == 0 && java.lang.Double.compare(increment, other.increment) == 0) - - override fun hashCode(): Int { - if (isEmpty()) return -1 - var temp = java.lang.Double.doubleToLongBits(start) - var result = (temp xor (temp ushr 32)) - temp = java.lang.Double.doubleToLongBits(endInclusive) - result = 31 * result + (temp xor (temp ushr 32)) - temp = java.lang.Double.doubleToLongBits(increment) - return (31 * result + (temp xor (temp ushr 32))).toInt() - } - - override fun toString(): String = if (increment > 0) "$start..$endInclusive step $increment" else "$start downTo $endInclusive step ${-increment}" -} - diff --git a/core/builtins/src/kotlin/Ranges.kt b/core/builtins/src/kotlin/Ranges.kt index 5cd0e37e169..4798e9d0c51 100644 --- a/core/builtins/src/kotlin/Ranges.kt +++ b/core/builtins/src/kotlin/Ranges.kt @@ -165,64 +165,3 @@ public class LongRange(start: Long, endInclusive: Long) : LongProgression(start, } } -@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) -@Suppress("DEPRECATION_ERROR") -/** - * A range of values of type `Float`. - */ -public class FloatRange(start: Float, endInclusive: Float) : FloatProgression(start, endInclusive, 1.0f), ClosedRange { - @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) - override val end: Float get() = endInclusive - - override fun contains(item: Float): Boolean = start <= item && item <= endInclusive - - override fun isEmpty(): Boolean = start > endInclusive - - override fun equals(other: Any?): Boolean = - other is FloatRange && (isEmpty() && other.isEmpty() || - java.lang.Float.compare(start, other.start) == 0 && java.lang.Float.compare(endInclusive, other.endInclusive) == 0) - - override fun hashCode(): Int = - if (isEmpty()) -1 else (31 * java.lang.Float.floatToIntBits(start) + java.lang.Float.floatToIntBits(endInclusive)) - - override fun toString(): String = "$start..$endInclusive" - - companion object { - /** An empty range of values of type Float. */ - public val EMPTY: FloatRange = FloatRange(1.0f, 0.0f) - } -} - -@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING) -@Suppress("DEPRECATION_ERROR") -/** - * A range of values of type `Double`. - */ -public class DoubleRange(start: Double, endInclusive: Double) : DoubleProgression(start, endInclusive, 1.0), ClosedRange { - @Deprecated("Use endInclusive instead.", ReplaceWith("endInclusive")) - override val end: Double get() = endInclusive - - override fun contains(item: Double): Boolean = start <= item && item <= endInclusive - - override fun isEmpty(): Boolean = start > endInclusive - - override fun equals(other: Any?): Boolean = - other is DoubleRange && (isEmpty() && other.isEmpty() || - java.lang.Double.compare(start, other.start) == 0 && java.lang.Double.compare(endInclusive, other.endInclusive) == 0) - - override fun hashCode(): Int { - if (isEmpty()) return -1 - var temp = java.lang.Double.doubleToLongBits(start) - val result = (temp xor (temp ushr 32)) - temp = java.lang.Double.doubleToLongBits(endInclusive) - return (31 * result + (temp xor (temp ushr 32))).toInt() - } - - override fun toString(): String = "$start..$endInclusive" - - companion object { - /** An empty range of values of type Double. */ - public val EMPTY: DoubleRange = DoubleRange(1.0, 0.0) - } -} - diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt index 2befbe3525b..755a9ab8d98 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/primitives.kt @@ -123,6 +123,8 @@ class GeneratePrimitives(out: PrintWriter) : BuiltInsSourceGenerator(out) { val returnType = maxByDomainCapacity(thisKind, otherKind) .let { if (it == PrimitiveType.CHAR) it else maxByDomainCapacity(it, PrimitiveType.INT) } + if (returnType == PrimitiveType.DOUBLE || returnType == PrimitiveType.FLOAT) + continue out.println(" /** Creates a range from this value to the specified [other] value. */") out.println(" public operator fun rangeTo(other: ${otherKind.capitalized}): ${returnType.capitalized}Range") } diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt index 27d9c326492..226c14266db 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/progressionIterators.kt @@ -84,7 +84,7 @@ class GenerateProgressionIterators(out: PrintWriter) : BuiltInsSourceGenerator(o out.println(integerProgressionIterator(kind)) } else { - out.println(floatingPointProgressionIterator(kind)) + continue } out.println() } diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt index df9e930e6e8..bed7f8aea4b 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/progressions.kt @@ -184,7 +184,7 @@ public open class $progression( override fun generateBody() { for (kind in ProgressionKind.values) { if (kind == FLOAT || kind == DOUBLE) - generateFloatingPointBody(kind) + continue else generateDiscreteBody(kind) } diff --git a/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt b/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt index a307f468d73..98ca64abfb0 100644 --- a/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt +++ b/generators/src/org/jetbrains/kotlin/generators/builtins/ranges.kt @@ -65,8 +65,7 @@ class GenerateRanges(out: PrintWriter) : BuiltInsSourceGenerator(out) { val toString = "\"\$start..\$endInclusive\"" if (kind == FLOAT || kind == DOUBLE) { - out.println("""@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)""") - out.println("""@Suppress("DEPRECATION_ERROR")""") + continue } if (kind == SHORT || kind == BYTE) { out.println("""@Deprecated("Use IntRange instead.", ReplaceWith("IntRange"), level = DeprecationLevel.WARNING)""") diff --git a/libraries/stdlib/src/generated/_Ranges.kt b/libraries/stdlib/src/generated/_Ranges.kt index b6d1dfbd1e8..6389661f3b0 100644 --- a/libraries/stdlib/src/generated/_Ranges.kt +++ b/libraries/stdlib/src/generated/_Ranges.kt @@ -31,7 +31,6 @@ public operator fun Range.contains(item: Byte): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("shortRangeContains") public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end @@ -40,9 +39,7 @@ public operator fun Range.contains(item: Byte): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("doubleRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @@ -50,9 +47,7 @@ public operator fun Range.contains(item: Byte): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("floatRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Byte): Boolean { return start <= item && item <= end } @@ -76,7 +71,6 @@ public operator fun Range.contains(item: Double): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("byteRangeContains") public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end @@ -85,7 +79,6 @@ public operator fun Range.contains(item: Double): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("shortRangeContains") public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end @@ -94,9 +87,7 @@ public operator fun Range.contains(item: Double): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("floatRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Double): Boolean { return start <= item && item <= end } @@ -120,7 +111,6 @@ public operator fun Range.contains(item: Float): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("byteRangeContains") public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end @@ -129,7 +119,6 @@ public operator fun Range.contains(item: Float): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("shortRangeContains") public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end @@ -138,9 +127,7 @@ public operator fun Range.contains(item: Float): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("doubleRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Float): Boolean { return start <= item && item <= end } @@ -156,7 +143,6 @@ public operator fun Range.contains(item: Int): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("byteRangeContains") public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end @@ -165,7 +151,6 @@ public operator fun Range.contains(item: Int): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("shortRangeContains") public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end @@ -174,9 +159,7 @@ public operator fun Range.contains(item: Int): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("doubleRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @@ -184,9 +167,7 @@ public operator fun Range.contains(item: Int): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("floatRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Int): Boolean { return start <= item && item <= end } @@ -202,7 +183,6 @@ public operator fun Range.contains(item: Long): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("byteRangeContains") public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end @@ -211,7 +191,6 @@ public operator fun Range.contains(item: Long): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("shortRangeContains") public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end @@ -220,9 +199,7 @@ public operator fun Range.contains(item: Long): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("doubleRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @@ -230,9 +207,7 @@ public operator fun Range.contains(item: Long): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("floatRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Long): Boolean { return start <= item && item <= end } @@ -256,7 +231,6 @@ public operator fun Range.contains(item: Short): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range will be removed soon.") @kotlin.jvm.JvmName("byteRangeContains") public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end @@ -265,9 +239,7 @@ public operator fun Range.contains(item: Short): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("doubleRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end } @@ -275,9 +247,7 @@ public operator fun Range.contains(item: Short): Boolean { /** * Checks if the specified [item] belongs to this range. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") @kotlin.jvm.JvmName("floatRangeContains") -@Suppress("DEPRECATION_ERROR") public operator fun Range.contains(item: Short): Boolean { return start <= item && item <= end } @@ -314,26 +284,6 @@ public infix fun Short.downTo(to: Byte): IntProgression { return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1) } -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Double.downTo(to: Byte): DoubleProgression { - return DoubleProgression.fromClosedRange(this, to.toDouble(), -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Float.downTo(to: Byte): FloatProgression { - return FloatProgression.fromClosedRange(this, to.toFloat(), -1.0F) -} - /** * Returns a progression from this value down to the specified [to] value with the increment -1. * The [to] value has to be less than this value. @@ -342,126 +292,6 @@ public infix fun Char.downTo(to: Char): CharProgression { return CharProgression.fromClosedRange(this, to, -1) } -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Int.downTo(to: Double): DoubleProgression { - return DoubleProgression.fromClosedRange(this.toDouble(), to, -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Long.downTo(to: Double): DoubleProgression { - return DoubleProgression.fromClosedRange(this.toDouble(), to, -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Byte.downTo(to: Double): DoubleProgression { - return DoubleProgression.fromClosedRange(this.toDouble(), to, -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Short.downTo(to: Double): DoubleProgression { - return DoubleProgression.fromClosedRange(this.toDouble(), to, -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Double.downTo(to: Double): DoubleProgression { - return DoubleProgression.fromClosedRange(this, to, -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Float.downTo(to: Double): DoubleProgression { - return DoubleProgression.fromClosedRange(this.toDouble(), to, -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Int.downTo(to: Float): FloatProgression { - return FloatProgression.fromClosedRange(this.toFloat(), to, -1.0F) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Long.downTo(to: Float): FloatProgression { - return FloatProgression.fromClosedRange(this.toFloat(), to, -1.0F) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Byte.downTo(to: Float): FloatProgression { - return FloatProgression.fromClosedRange(this.toFloat(), to, -1.0F) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Short.downTo(to: Float): FloatProgression { - return FloatProgression.fromClosedRange(this.toFloat(), to, -1.0F) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Double.downTo(to: Float): DoubleProgression { - return DoubleProgression.fromClosedRange(this, to.toDouble(), -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Float.downTo(to: Float): FloatProgression { - return FloatProgression.fromClosedRange(this, to, -1.0F) -} - /** * Returns a progression from this value down to the specified [to] value with the increment -1. * The [to] value has to be less than this value. @@ -494,26 +324,6 @@ public infix fun Short.downTo(to: Int): IntProgression { return IntProgression.fromClosedRange(this.toInt(), to, -1) } -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Double.downTo(to: Int): DoubleProgression { - return DoubleProgression.fromClosedRange(this, to.toDouble(), -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Float.downTo(to: Int): FloatProgression { - return FloatProgression.fromClosedRange(this, to.toFloat(), -1.0F) -} - /** * Returns a progression from this value down to the specified [to] value with the increment -1. * The [to] value has to be less than this value. @@ -546,26 +356,6 @@ public infix fun Short.downTo(to: Long): LongProgression { return LongProgression.fromClosedRange(this.toLong(), to, -1L) } -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Double.downTo(to: Long): DoubleProgression { - return DoubleProgression.fromClosedRange(this, to.toDouble(), -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Float.downTo(to: Long): FloatProgression { - return FloatProgression.fromClosedRange(this, to.toFloat(), -1.0F) -} - /** * Returns a progression from this value down to the specified [to] value with the increment -1. * The [to] value has to be less than this value. @@ -598,26 +388,6 @@ public infix fun Short.downTo(to: Short): IntProgression { return IntProgression.fromClosedRange(this.toInt(), to.toInt(), -1) } -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Double.downTo(to: Short): DoubleProgression { - return DoubleProgression.fromClosedRange(this, to.toDouble(), -1.0) -} - -/** - * Returns a progression from this value down to the specified [to] value with the increment -1. - * The [to] value has to be less than this value. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun Float.downTo(to: Short): FloatProgression { - return FloatProgression.fromClosedRange(this, to.toFloat(), -1.0F) -} - /** * Returns a progression that goes over the same range in the opposite direction with the same step. */ @@ -669,24 +439,6 @@ public fun ByteProgression.reversed(): ByteProgression { return ByteProgression.fromClosedRange(last, first, -increment) } -/** - * Returns a progression that goes over the same range in the opposite direction with the same step. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public fun DoubleProgression.reversed(): DoubleProgression { - return DoubleProgression.fromClosedRange(last, first, -increment) -} - -/** - * Returns a progression that goes over the same range in the opposite direction with the same step. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public fun FloatProgression.reversed(): FloatProgression { - return FloatProgression.fromClosedRange(last, first, -increment) -} - /** * Returns a progression that goes over the same range in the opposite direction with the same step. */ @@ -705,24 +457,6 @@ public fun ByteRange.reversed(): ByteProgression { return ByteProgression.fromClosedRange(last, first, -1) } -/** - * Returns a progression that goes over this range in reverse direction. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public fun DoubleRange.reversed(): DoubleProgression { - return DoubleProgression.fromClosedRange(last, first, -1.0) -} - -/** - * Returns a progression that goes over this range in reverse direction. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public fun FloatRange.reversed(): FloatProgression { - return FloatProgression.fromClosedRange(last, first, -1.0f) -} - /** * Returns a progression that goes over this range in reverse direction. */ @@ -790,26 +524,6 @@ public infix fun ByteProgression.step(step: Int): ByteProgression { return ByteProgression.fromClosedRange(first, last, if (increment > 0) step else -step) } -/** - * Returns a progression that goes over the same range with the given step. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun DoubleProgression.step(step: Double): DoubleProgression { - checkStepIsPositive(step > 0, step) - return DoubleProgression.fromClosedRange(first, last, if (increment > 0) step else -step) -} - -/** - * Returns a progression that goes over the same range with the given step. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun FloatProgression.step(step: Float): FloatProgression { - checkStepIsPositive(step > 0, step) - return FloatProgression.fromClosedRange(first, last, if (increment > 0) step else -step) -} - /** * Returns a progression that goes over the same range with the given step. */ @@ -830,28 +544,6 @@ public infix fun ByteRange.step(step: Int): ByteProgression { return ByteProgression.fromClosedRange(first, last, step) } -/** - * Returns a progression that goes over this range with given step. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun DoubleRange.step(step: Double): DoubleProgression { - if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.") - checkStepIsPositive(step > 0, step) - return DoubleProgression.fromClosedRange(start, end, step) -} - -/** - * Returns a progression that goes over this range with given step. - */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") -@Suppress("DEPRECATION_ERROR") -public infix fun FloatRange.step(step: Float): FloatProgression { - if (step.isNaN()) throw IllegalArgumentException("Step must not be NaN.") - checkStepIsPositive(step > 0, step) - return FloatProgression.fromClosedRange(start, end, step) -} - /** * Returns a progression that goes over this range with given step. */ @@ -1276,7 +968,6 @@ public fun Short.coerceIn(range: Range): Short { * Ensures that this value lies in the specified [range]. * @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") public fun > T.coerceIn(range: Range): T { if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.") return if (this < range.start) range.start else if (this > range.end) range.end else this @@ -1286,7 +977,6 @@ public fun > T.coerceIn(range: Range): T { * Ensures that this value lies in the specified [range]. * @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") public fun Double.coerceIn(range: Range): Double { if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.") return if (this < range.start) range.start else if (this > range.end) range.end else this @@ -1296,7 +986,6 @@ public fun Double.coerceIn(range: Range): Double { * Ensures that this value lies in the specified [range]. * @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.") public fun Float.coerceIn(range: Range): Float { if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: $range.") return if (this < range.start) range.start else if (this > range.end) range.end else this diff --git a/libraries/stdlib/src/kotlin/util/Ranges.kt b/libraries/stdlib/src/kotlin/util/Ranges.kt index 0bd814d22a9..0edcc26e7e2 100644 --- a/libraries/stdlib/src/kotlin/util/Ranges.kt +++ b/libraries/stdlib/src/kotlin/util/Ranges.kt @@ -5,37 +5,28 @@ package kotlin /** * Represents a range of [Comparable] values. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR) -public class ComparableRange> ( +private class ComparableRange> ( override val start: T, - override val end: T -): Range { - override fun contains(item: T): Boolean { - return start <= item && item <= end - } + override val endInclusive: T +): ClosedRange { - @Suppress("DEPRECATION_ERROR") override fun equals(other: Any?): Boolean { return other is ComparableRange<*> && (isEmpty() && other.isEmpty() || - start == other.start && end == other.end) + start == other.start && endInclusive == other.endInclusive) } override fun hashCode(): Int { - return if (isEmpty()) -1 else 31 * start.hashCode() + end.hashCode() + return if (isEmpty()) -1 else 31 * start.hashCode() + endInclusive.hashCode() } - override fun toString(): String = "$start..$end" + override fun toString(): String = "$start..$endInclusive" } /** * Creates a range from this [Comparable] value to the specified [that] value. This value * needs to be smaller than [that] value, otherwise the returned range will be empty. */ -@Deprecated("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.ERROR) -@Suppress("DEPRECATION_ERROR") -public operator fun > T.rangeTo(that: T): ComparableRange { - return ComparableRange(this, that) -} +public operator fun > T.rangeTo(that: T): ClosedRange = ComparableRange(this, that) internal fun checkStepIsPositive(isPositive: Boolean, step: Number) { diff --git a/libraries/stdlib/test/language/RangeIterationJVMTest.kt b/libraries/stdlib/test/language/RangeIterationJVMTest.kt index 2e023d0f68a..4dddaca34a8 100644 --- a/libraries/stdlib/test/language/RangeIterationJVMTest.kt +++ b/libraries/stdlib/test/language/RangeIterationJVMTest.kt @@ -17,31 +17,6 @@ import kotlin.test.* // Test data for codegen is generated from this class. If you change it, rerun GenerateTests public class RangeIterationJVMTest : RangeIterationTestBase() { - @test fun infiniteSteps() { - doTest(0.0..5.0 step java.lang.Double.POSITIVE_INFINITY, 0.0, 5.0, java.lang.Double.POSITIVE_INFINITY, listOf(0.0)) - doTest(0.0.toFloat()..5.0.toFloat() step java.lang.Float.POSITIVE_INFINITY, 0.0.toFloat(), 5.0.toFloat(), java.lang.Float.POSITIVE_INFINITY, - listOf(0.0.toFloat())) - doTest(5.0 downTo 0.0 step java.lang.Double.POSITIVE_INFINITY, 5.0, 0.0, java.lang.Double.NEGATIVE_INFINITY, listOf(5.0)) - doTest(5.0.toFloat() downTo 0.0.toFloat() step java.lang.Float.POSITIVE_INFINITY, 5.0.toFloat(), 0.0.toFloat(), java.lang.Float.NEGATIVE_INFINITY, - listOf(5.0.toFloat())) - } - - @test fun nanEnds() { - doTest(java.lang.Double.NaN..5.0, java.lang.Double.NaN, 5.0, 1.0, listOf()) - doTest(java.lang.Float.NaN.toFloat()..5.0.toFloat(), java.lang.Float.NaN, 5.0.toFloat(), 1.0.toFloat(), listOf()) - doTest(java.lang.Double.NaN downTo 0.0, java.lang.Double.NaN, 0.0, -1.0, listOf()) - doTest(java.lang.Float.NaN.toFloat() downTo 0.0.toFloat(), java.lang.Float.NaN, 0.0.toFloat(), -1.0.toFloat(), listOf()) - - doTest(0.0..java.lang.Double.NaN, 0.0, java.lang.Double.NaN, 1.0, listOf()) - doTest(0.0.toFloat()..java.lang.Float.NaN, 0.0.toFloat(), java.lang.Float.NaN, 1.0.toFloat(), listOf()) - doTest(5.0 downTo java.lang.Double.NaN, 5.0, java.lang.Double.NaN, -1.0, listOf()) - doTest(5.0.toFloat() downTo java.lang.Float.NaN, 5.0.toFloat(), java.lang.Float.NaN, -1.0.toFloat(), listOf()) - - doTest(java.lang.Double.NaN..java.lang.Double.NaN, java.lang.Double.NaN, java.lang.Double.NaN, 1.0, listOf()) - doTest(java.lang.Float.NaN..java.lang.Float.NaN, java.lang.Float.NaN, java.lang.Float.NaN, 1.0.toFloat(), listOf()) - doTest(java.lang.Double.NaN downTo java.lang.Double.NaN, java.lang.Double.NaN, java.lang.Double.NaN, -1.0, listOf()) - doTest(java.lang.Float.NaN downTo java.lang.Float.NaN, java.lang.Float.NaN, java.lang.Float.NaN, -1.0.toFloat(), listOf()) - } @test fun maxValueToMaxValue() { doTest(MaxI..MaxI, MaxI, MaxI, 1, listOf(MaxI)) diff --git a/libraries/stdlib/test/language/RangeIterationTest.kt b/libraries/stdlib/test/language/RangeIterationTest.kt index cdb90b2a367..afca46f4d9a 100644 --- a/libraries/stdlib/test/language/RangeIterationTest.kt +++ b/libraries/stdlib/test/language/RangeIterationTest.kt @@ -62,9 +62,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(LongRange.EMPTY, 1.toLong(), 0.toLong(), 1.toLong(), listOf()) doTest(CharRange.EMPTY, 1.toChar(), 0.toChar(), 1, listOf()) - - doTest(DoubleRange.EMPTY, 1.0, 0.0, 1.0, listOf()) - doTest(FloatRange.EMPTY, 1.0.toFloat(), 0.0.toFloat(), 1.0.toFloat(), listOf()) } @test fun emptyRange() { @@ -74,9 +71,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(10.toLong()..-5.toLong(), 10.toLong(), -5.toLong(), 1.toLong(), listOf()) doTest('z'..'a', 'z', 'a', 1, listOf()) - - doTest(5.0..-1.0, 5.0, -1.0, 1.0, listOf()) - doTest(5.0.toFloat()..-1.0.toFloat(), 5.0.toFloat(), -1.0.toFloat(), 1.toFloat(), listOf()) } @test fun oneElementRange() { @@ -86,9 +80,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(5.toLong()..5.toLong(), 5.toLong(), 5.toLong(), 1.toLong(), listOf(5.toLong())) doTest('k'..'k', 'k', 'k', 1, listOf('k')) - - doTest(5.0..5.0, 5.0, 5.0, 1.0, listOf(5.0)) - doTest(5.0.toFloat()..5.0.toFloat(), 5.0.toFloat(), 5.0.toFloat(), 1.toFloat(), listOf(5.0.toFloat())) } @test fun simpleRange() { @@ -98,11 +89,7 @@ public class RangeIterationTest : RangeIterationTestBase() { 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')) - - doTest(3.0..9.0, 3.0, 9.0, 1.0, listOf(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) - doTest(3.0.toFloat()..9.0.toFloat(), 3.0.toFloat(), 9.0.toFloat(), 1.toFloat(), - listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat(), 6.0.toFloat(), 7.0.toFloat(), 8.0.toFloat(), 9.0.toFloat())) - } + } @test fun simpleRangeWithNonConstantEnds() { @@ -112,10 +99,6 @@ public class RangeIterationTest : RangeIterationTestBase() { 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')) - - doTest((1.5 * 2)..(3.0 * 3.0), 3.0, 9.0, 1.0, listOf(3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0)) - doTest((1.5.toFloat() * 2.toFloat())..(3.0.toFloat() * 3.0.toFloat()), 3.0.toFloat(), 9.0.toFloat(), 1.toFloat(), - listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat(), 6.0.toFloat(), 7.0.toFloat(), 8.0.toFloat(), 9.0.toFloat())) } @test fun openRange() { @@ -134,9 +117,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(5.toLong() downTo 10.toLong(), 5.toLong(), 10.toLong(), -1.toLong(), listOf()) doTest('a' downTo 'z', 'a', 'z', -1, listOf()) - - doTest(-1.0 downTo 5.0, -1.0, 5.0, -1.0, listOf()) - doTest(-1.0.toFloat() downTo 5.0.toFloat(), -1.0.toFloat(), 5.0.toFloat(), -1.0.toFloat(), listOf()) } @test fun oneElementDownTo() { @@ -146,9 +126,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(5.toLong() downTo 5.toLong(), 5.toLong(), 5.toLong(), -1.toLong(), listOf(5.toLong())) doTest('k' downTo 'k', 'k', 'k', -1, listOf('k')) - - doTest(5.0 downTo 5.0, 5.0, 5.0, -1.0, listOf(5.0)) - doTest(5.0.toFloat() downTo 5.0.toFloat(), 5.0.toFloat(), 5.0.toFloat(), -1.0.toFloat(), listOf(5.0.toFloat())) } @test fun simpleDownTo() { @@ -158,10 +135,6 @@ public class RangeIterationTest : RangeIterationTestBase() { 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')) - - doTest(9.0 downTo 3.0, 9.0, 3.0, -1.0, listOf(9.0, 8.0, 7.0, 6.0, 5.0, 4.0, 3.0)) - doTest(9.0.toFloat() downTo 3.0.toFloat(), 9.0.toFloat(), 3.0.toFloat(), -1.0.toFloat(), - listOf(9.0.toFloat(), 8.0.toFloat(), 7.0.toFloat(), 6.0.toFloat(), 5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) } @@ -172,10 +145,6 @@ public class RangeIterationTest : RangeIterationTestBase() { 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')) - - doTest(4.0..6.0 step 0.5, 4.0, 6.0, 0.5, listOf(4.0, 4.5, 5.0, 5.5, 6.0)) - doTest(4.0.toFloat()..6.0.toFloat() step 0.5.toFloat(), 4.0.toFloat(), 6.0.toFloat(), 0.5.toFloat(), - listOf(4.0.toFloat(), 4.5.toFloat(), 5.0.toFloat(), 5.5.toFloat(), 6.0.toFloat())) } @test fun simpleSteppedDownTo() { @@ -185,10 +154,6 @@ public class RangeIterationTest : RangeIterationTestBase() { 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')) - - doTest(6.0 downTo 4.0 step 0.5, 6.0, 4.0, -0.5, listOf(6.0, 5.5, 5.0, 4.5, 4.0)) - doTest(6.0.toFloat() downTo 4.0.toFloat() step 0.5.toFloat(), 6.0.toFloat(), 4.0.toFloat(), -0.5.toFloat(), - listOf(6.0.toFloat(), 5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) } @@ -200,10 +165,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(3.toLong()..8.toLong() step 2.toLong(), 3.toLong(), 7.toLong(), 2.toLong(), listOf(3, 5, 7)) doTest('a'..'d' step 2, 'a', 'c', 2, listOf('a', 'c')) - - doTest(4.0..5.8 step 0.5, 4.0, 5.8, 0.5, listOf(4.0, 4.5, 5.0, 5.5)) - doTest(4.0.toFloat()..5.8.toFloat() step 0.5.toFloat(), 4.0.toFloat(), 5.8.toFloat(), 0.5.toFloat(), - listOf(4.0.toFloat(), 4.5.toFloat(), 5.0.toFloat(), 5.5.toFloat())) } // 'inexact' means last element is not equal to sequence end @@ -214,10 +175,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(8.toLong() downTo 3.toLong() step 2.toLong(), 8.toLong(), 4.toLong(), -2.toLong(), listOf(8, 6, 4)) doTest('d' downTo 'a' step 2, 'd', 'b', -2, listOf('d', 'b')) - - doTest(5.5 downTo 3.7 step 0.5, 5.5, 3.7, -0.5, listOf(5.5, 5.0, 4.5, 4.0)) - doTest(5.5.toFloat() downTo 3.7.toFloat() step 0.5.toFloat(), 5.5.toFloat(), 3.7.toFloat(), -0.5.toFloat(), - listOf(5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) } @@ -228,9 +185,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest((5.toLong()..3.toLong()).reversed(), 3.toLong(), 5.toLong(), -1.toLong(), listOf()) doTest(('c'..'a').reversed(), 'a', 'c', -1, listOf()) - - doTest((5.0..3.0).reversed(), 3.0, 5.0, -1.0, listOf()) - doTest((5.0.toFloat()..3.0.toFloat()).reversed(), 3.0.toFloat(), 5.0.toFloat(), -1.toFloat(), listOf()) } @test fun reversedEmptyBackSequence() { @@ -240,9 +194,6 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest((3.toLong() downTo 5.toLong()).reversed(), 5.toLong(), 3.toLong(), 1.toLong(), listOf()) doTest(('a' downTo 'c').reversed(), 'c', 'a', 1, listOf()) - - doTest((3.0 downTo 5.0).reversed(), 5.0, 3.0, 1.0, listOf()) - doTest((3.0.toFloat() downTo 5.0.toFloat()).reversed(), 5.0.toFloat(), 3.0.toFloat(), 1.toFloat(), listOf()) } @test fun reversedRange() { @@ -252,10 +203,6 @@ public class RangeIterationTest : RangeIterationTestBase() { 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')) - - doTest((3.0..5.0).reversed(), 5.0, 3.0, -1.0, listOf(5.0, 4.0, 3.0)) - doTest((3.0.toFloat()..5.0.toFloat()).reversed(), 5.0.toFloat(), 3.0.toFloat(), -1.toFloat(), - listOf(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) } @test fun reversedBackSequence() { @@ -266,10 +213,7 @@ public class RangeIterationTest : RangeIterationTestBase() { doTest(('c' downTo 'a').reversed(), 'a', 'c', 1, listOf('a', 'b', 'c')) - doTest((5.0 downTo 3.0).reversed(), 3.0, 5.0, 1.0, listOf(3.0, 4.0, 5.0)) - doTest((5.0.toFloat() downTo 3.0.toFloat()).reversed(), 3.0.toFloat(), 5.0.toFloat(), 1.toFloat(), - listOf(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat())) - } + } @test fun reversedSimpleSteppedRange() { doTest((3..9 step 2).reversed(), 9, 3, -2, listOf(9, 7, 5, 3)) @@ -278,10 +222,6 @@ public class RangeIterationTest : RangeIterationTestBase() { 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')) - - doTest((4.0..6.0 step 0.5).reversed(), 6.0, 4.0, -0.5, listOf(6.0, 5.5, 5.0, 4.5, 4.0)) - doTest((4.0.toFloat()..6.0.toFloat() step 0.5.toFloat()).reversed(), 6.0.toFloat(), 4.0.toFloat(), -0.5.toFloat(), - listOf(6.0.toFloat(), 5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat())) } // invariant progression.reversed().toList() == progression.toList().reversed() is preserved diff --git a/libraries/stdlib/test/language/RangeJVMTest.kt b/libraries/stdlib/test/language/RangeJVMTest.kt index e17e596a1ab..ceb7eb8460e 100644 --- a/libraries/stdlib/test/language/RangeJVMTest.kt +++ b/libraries/stdlib/test/language/RangeJVMTest.kt @@ -27,53 +27,34 @@ public class RangeJVMTest { fun assertFailsWithIllegalArgument(f: () -> Unit) = assertFailsWith(IllegalArgumentException::class, block = f) // create Progression explicitly with increment = 0 assertFailsWithIllegalArgument { IntProgression(0, 5, 0) } - assertFailsWithIllegalArgument { ByteProgression(0, 5, 0) } - assertFailsWithIllegalArgument { ShortProgression(0, 5, 0) } assertFailsWithIllegalArgument { LongProgression(0, 5, 0) } assertFailsWithIllegalArgument { CharProgression('a', 'z', 0) } - assertFailsWithIllegalArgument { DoubleProgression(0.0, 5.0, 0.0) } - assertFailsWithIllegalArgument { FloatProgression(0.0f, 5.0f, 0.0f) } + assertFailsWithIllegalArgument { 0..5 step 0 } assertFailsWithIllegalArgument { 0.toByte()..5.toByte() step 0 } assertFailsWithIllegalArgument { 0.toShort()..5.toShort() step 0 } assertFailsWithIllegalArgument { 0L..5L step 0L } assertFailsWithIllegalArgument { 'a'..'z' step 0 } - assertFailsWithIllegalArgument { 0.0..5.0 step 0.0 } - assertFailsWithIllegalArgument { 0.0f..5.0f step 0.0f } assertFailsWithIllegalArgument { 0 downTo -5 step 0 } assertFailsWithIllegalArgument { 0.toByte() downTo -5.toByte() step 0 } assertFailsWithIllegalArgument { 0.toShort() downTo -5.toShort() step 0 } assertFailsWithIllegalArgument { 0L downTo -5L step 0L } assertFailsWithIllegalArgument { 'z' downTo 'a' step 0 } - assertFailsWithIllegalArgument { 0.0 downTo -5.0 step 0.0 } - assertFailsWithIllegalArgument { 0.0f downTo -5.0f step 0.0f } assertFailsWithIllegalArgument { 0..5 step -2 } assertFailsWithIllegalArgument { 0.toByte()..5.toByte() step -2 } assertFailsWithIllegalArgument { 0.toShort()..5.toShort() step -2 } assertFailsWithIllegalArgument { 0L..5L step -2L } assertFailsWithIllegalArgument { 'a'..'z' step -2 } - assertFailsWithIllegalArgument { 0.0..5.0 step -0.5 } - assertFailsWithIllegalArgument { 0.0f..5.0f step -0.5f } + assertFailsWithIllegalArgument { 0 downTo -5 step -2 } assertFailsWithIllegalArgument { 0.toByte() downTo -5.toByte() step -2 } assertFailsWithIllegalArgument { 0.toShort() downTo -5.toShort() step -2 } assertFailsWithIllegalArgument { 0L downTo -5L step -2L } assertFailsWithIllegalArgument { 'z' downTo 'a' step -2 } - assertFailsWithIllegalArgument { 0.0 downTo -5.0 step -0.5 } - assertFailsWithIllegalArgument { 0.0f downTo -5.0f step -0.5f } - // NaN increment or step - assertFailsWithIllegalArgument { DoubleProgression(0.0, 5.0, jDouble.NaN) } - assertFailsWithIllegalArgument { FloatProgression(0.0f, 5.0f, jFloat.NaN) } - - assertFailsWithIllegalArgument { 0.0..5.0 step jDouble.NaN } - assertFailsWithIllegalArgument { 0.0f..5.0f step jFloat.NaN } - - assertFailsWithIllegalArgument { 5.0 downTo 0.0 step jDouble.NaN } - assertFailsWithIllegalArgument { 5.0f downTo 0.0f step jFloat.NaN } } } \ No newline at end of file diff --git a/libraries/stdlib/test/language/RangeTest.kt b/libraries/stdlib/test/language/RangeTest.kt index 23be1805a16..12bb8bcc2ac 100644 --- a/libraries/stdlib/test/language/RangeTest.kt +++ b/libraries/stdlib/test/language/RangeTest.kt @@ -251,12 +251,9 @@ public class RangeTest { assertTrue(1 downTo 2 == 2 downTo 3) assertTrue(-1L downTo 0L == -2L downTo -1L) - assertEquals(-1f downTo 1f, -2f downTo 2f) - assertEquals(-4.0 downTo -3.0, -2.0 downTo -1.0) assertEquals('j'..'a' step 4, 'u'..'q' step 2) assertFalse(0..1 == IntRange.EMPTY) - assertFalse(1f downTo 2f == 2f downTo 1f) assertEquals("range".."progression", "hashcode".."equals") assertFalse(("aa".."bb") == ("aaa".."bbb")) @@ -276,7 +273,6 @@ public class RangeTest { assertEquals((1 downTo 2).hashCode(), (2 downTo 3).hashCode()) assertEquals((1L downTo 2L).hashCode(), (2L downTo 3L).hashCode()) - assertEquals((1.0 downTo 2.0).hashCode(), (2.0 downTo 3.0).hashCode()) assertEquals(('a' downTo 'b').hashCode(), ('c' downTo 'd').hashCode()) assertEquals(("range".."progression").hashCode(), ("hashcode".."equals").hashCode()) diff --git a/libraries/stdlib/test/numbers/CoercionTest.kt b/libraries/stdlib/test/numbers/CoercionTest.kt index 6730ca3509c..ad777d8018b 100644 --- a/libraries/stdlib/test/numbers/CoercionTest.kt +++ b/libraries/stdlib/test/numbers/CoercionTest.kt @@ -72,7 +72,7 @@ class CoercionTest { expect(1.0) { 5.0.coerceAtMost(1.0) } expect(1.0) { 1.0.coerceAtMost(5.0) } - for (value in 0.0..10.0) { + for (value in (0..10).map { it.toDouble() }) { expect(value) { value.coerceIn(null, null) } val min = 2.0 val max = 5.0 diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt index 146e10561f6..be3b8d4ef28 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Comparables.kt @@ -79,7 +79,6 @@ fun comparables(): List { @return this value if it's in the [range], or range.start if this value is less than range.start, or range.end if this value is greater than range.end. """ } - deprecate(Deprecation("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)) body { """ if (range.isEmpty()) throw IllegalArgumentException("Cannot coerce value to an empty range: ${'$'}range.") diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt index 80f34417b46..d5d2342647d 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Ranges.kt @@ -7,6 +7,7 @@ fun ranges(): List { val templates = arrayListOf() val rangePrimitives = listOf(PrimitiveType.Int, PrimitiveType.Long, PrimitiveType.Char) + val floatingPointPrimitives = listOf(PrimitiveType.Double, PrimitiveType.Float) fun rangeElementType(fromType: PrimitiveType, toType: PrimitiveType) = maxByCapacity(fromType, toType).let { if (it == PrimitiveType.Char) it else maxByCapacity(it, PrimitiveType.Int) } @@ -27,7 +28,7 @@ fun ranges(): List { templates add f("reversed()") { only(RangesOfPrimitives, ProgressionsOfPrimitives) - only(defaultPrimitives - PrimitiveType.Boolean - rangePrimitives) + only(defaultPrimitives - PrimitiveType.Boolean - rangePrimitives - floatingPointPrimitives) doc(ProgressionsOfPrimitives) { "Returns a progression that goes over the same range in the opposite direction with the same step." } doc(RangesOfPrimitives) { "Returns a progression that goes over this range in reverse direction." } returns("TProgression") @@ -67,7 +68,7 @@ fun ranges(): List { infix(true) only(RangesOfPrimitives, ProgressionsOfPrimitives) - only(defaultPrimitives - PrimitiveType.Boolean - rangePrimitives) + only(defaultPrimitives - PrimitiveType.Boolean - rangePrimitives - floatingPointPrimitives) doc(ProgressionsOfPrimitives) { "Returns a progression that goes over the same range with the given step." } doc(RangesOfPrimitives) { "Returns a progression that goes over this range with given step." } returns("TProgression") @@ -132,8 +133,9 @@ fun ranges(): List { val numericPrimitives = PrimitiveType.numericPrimitives val numericPermutations = numericPrimitives.flatMap { fromType -> numericPrimitives.map { toType -> fromType to toType }} val primitivePermutations = numericPermutations + (PrimitiveType.Char to PrimitiveType.Char) + val integralPermutations = primitivePermutations.filter { it.first.isIntegral() && it.second.isIntegral() } - templates addAll primitivePermutations.map { downTo(it.first, it.second) } + templates addAll integralPermutations.map { downTo(it.first, it.second) } fun until(fromType: PrimitiveType, toType: PrimitiveType) = f("until(to: $toType)") { infix(true) @@ -178,20 +180,18 @@ fun ranges(): List { } } - templates addAll primitivePermutations - .filter { it.first.isIntegral() && it.second.isIntegral() } - .map { until(it.first, it.second) } + templates addAll integralPermutations.map { until(it.first, it.second) } fun contains(rangeType: PrimitiveType, itemType: PrimitiveType) = f("contains(item: $itemType)") { operator(true) - if (!rangeType.isIntegral()) { - deprecate(Deprecation("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)) - annotations("""@Suppress("DEPRECATION_ERROR")""") - } - else if (rangeType !in rangePrimitives) { - deprecate(Deprecation("This range will be removed soon.", level = DeprecationLevel.WARNING)) - } +// if (!rangeType.isIntegral()) { +// deprecate(Deprecation("This range implementation has unclear semantics and will be removed soon.", level = DeprecationLevel.WARNING)) +// annotations("""@Suppress("DEPRECATION_ERROR")""") +// } +// else if (rangeType !in rangePrimitives) { +// deprecate(Deprecation("This range will be removed soon.", level = DeprecationLevel.WARNING)) +// } check(rangeType.isNumeric() == itemType.isNumeric()) { "Required rangeType and itemType both to be numeric or both not, got: $rangeType, $itemType" } only(Ranges)