Drop Ranges, Progressions, ProgressionIterators for Double and Float.
Undeprecate generic Comparable.rangeTo, but return private implementation instead. Undeprecate contains and coerceIn for generic ranges.
This commit is contained in:
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'a' downTo 'z': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = -1.0 downTo 5.0
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for -1.0 downTo 5.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
val range7 = -1.0.toFloat() downTo 5.0.toFloat()
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>()) {
|
||||
return "Wrong elements for -1.0.toFloat() downTo 5.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'z'..'a': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = 5.0..-1.0
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for 5.0..-1.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
val range7 = 5.0.toFloat()..-1.0.toFloat()
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>()) {
|
||||
return "Wrong elements for 5.0.toFloat()..-1.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'd' downTo 'a' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
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<Double>(5.5, 5.0, 4.5, 4.0)) {
|
||||
return "Wrong elements for 5.5 downTo 3.7 step 0.5: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'a'..'d' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = 4.0..5.8 step 0.5
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(4.0, 4.5, 5.0, 5.5)) {
|
||||
return "Wrong elements for 4.0..5.8 step 0.5: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
@@ -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<Double>()
|
||||
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<Double>(0.0)) {
|
||||
return "Wrong elements for 0.0..5.0 step java.lang.Double.POSITIVE_INFINITY: $list1"
|
||||
}
|
||||
|
||||
val list2 = ArrayList<Float>()
|
||||
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<Float>(0.0.toFloat())) {
|
||||
return "Wrong elements for 0.0.toFloat()..5.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list2"
|
||||
}
|
||||
|
||||
val list3 = ArrayList<Double>()
|
||||
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<Double>(5.0)) {
|
||||
return "Wrong elements for 5.0 downTo 0.0 step java.lang.Double.POSITIVE_INFINITY: $list3"
|
||||
}
|
||||
|
||||
val list4 = ArrayList<Float>()
|
||||
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<Float>(5.0.toFloat())) {
|
||||
return "Wrong elements for 5.0.toFloat() downTo 0.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list4"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -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<Double>()
|
||||
val range1 = java.lang.Double.NaN..5.0
|
||||
for (i in range1) {
|
||||
list1.add(i)
|
||||
if (list1.size() > 23) break
|
||||
}
|
||||
if (list1 != listOf<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN..5.0: $list1"
|
||||
}
|
||||
|
||||
val list2 = ArrayList<Float>()
|
||||
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<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN.toFloat()..5.0.toFloat(): $list2"
|
||||
}
|
||||
|
||||
val list3 = ArrayList<Double>()
|
||||
val range3 = java.lang.Double.NaN downTo 0.0
|
||||
for (i in range3) {
|
||||
list3.add(i)
|
||||
if (list3.size() > 23) break
|
||||
}
|
||||
if (list3 != listOf<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN downTo 0.0: $list3"
|
||||
}
|
||||
|
||||
val list4 = ArrayList<Float>()
|
||||
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<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN.toFloat() downTo 0.0.toFloat(): $list4"
|
||||
}
|
||||
|
||||
val list5 = ArrayList<Double>()
|
||||
val range5 = 0.0..java.lang.Double.NaN
|
||||
for (i in range5) {
|
||||
list5.add(i)
|
||||
if (list5.size() > 23) break
|
||||
}
|
||||
if (list5 != listOf<Double>()) {
|
||||
return "Wrong elements for 0.0..java.lang.Double.NaN: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Float>()
|
||||
val range6 = 0.0.toFloat()..java.lang.Float.NaN
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Float>()) {
|
||||
return "Wrong elements for 0.0.toFloat()..java.lang.Float.NaN: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Double>()
|
||||
val range7 = 5.0 downTo java.lang.Double.NaN
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Double>()) {
|
||||
return "Wrong elements for 5.0 downTo java.lang.Double.NaN: $list7"
|
||||
}
|
||||
|
||||
val list8 = ArrayList<Float>()
|
||||
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<Float>()) {
|
||||
return "Wrong elements for 5.0.toFloat() downTo java.lang.Float.NaN: $list8"
|
||||
}
|
||||
|
||||
val list9 = ArrayList<Double>()
|
||||
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<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN..java.lang.Double.NaN: $list9"
|
||||
}
|
||||
|
||||
val list10 = ArrayList<Float>()
|
||||
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<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN..java.lang.Float.NaN: $list10"
|
||||
}
|
||||
|
||||
val list11 = ArrayList<Double>()
|
||||
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<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN downTo java.lang.Double.NaN: $list11"
|
||||
}
|
||||
|
||||
val list12 = ArrayList<Float>()
|
||||
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<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN downTo java.lang.Float.NaN: $list12"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'k' downTo 'k': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = 5.0 downTo 5.0
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(5.0)) {
|
||||
return "Wrong elements for 5.0 downTo 5.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
val range7 = 5.0.toFloat() downTo 5.0.toFloat()
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(5.0.toFloat())) {
|
||||
return "Wrong elements for 5.0.toFloat() downTo 5.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'k'..'k': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = 5.0..5.0
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(5.0)) {
|
||||
return "Wrong elements for 5.0..5.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
val range7 = 5.0.toFloat()..5.0.toFloat()
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(5.0.toFloat())) {
|
||||
return "Wrong elements for 5.0.toFloat()..5.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('c' downTo 'a').reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = (5.0 downTo 3.0).reversed()
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(3.0, 4.0, 5.0)) {
|
||||
return "Wrong elements for (5.0 downTo 3.0).reversed(): $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
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<Float>(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat())) {
|
||||
return "Wrong elements for (5.0.toFloat() downTo 3.0.toFloat()).reversed(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('a' downTo 'c').reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = (3.0 downTo 5.0).reversed()
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for (3.0 downTo 5.0).reversed(): $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
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<Float>()) {
|
||||
return "Wrong elements for (3.0.toFloat() downTo 5.0.toFloat()).reversed(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('c'..'a').reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = (5.0..3.0).reversed()
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for (5.0..3.0).reversed(): $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
val range7 = (5.0.toFloat()..3.0.toFloat()).reversed()
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>()) {
|
||||
return "Wrong elements for (5.0.toFloat()..3.0.toFloat()).reversed(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -42,25 +42,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('a'..'c').reversed(): $list4"
|
||||
}
|
||||
|
||||
val list5 = ArrayList<Double>()
|
||||
val range5 = (3.0..5.0).reversed()
|
||||
for (i in range5) {
|
||||
list5.add(i)
|
||||
if (list5.size() > 23) break
|
||||
}
|
||||
if (list5 != listOf<Double>(5.0, 4.0, 3.0)) {
|
||||
return "Wrong elements for (3.0..5.0).reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Float>()
|
||||
val range6 = (3.0.toFloat()..5.0.toFloat()).reversed()
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Float>(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) {
|
||||
return "Wrong elements for (3.0.toFloat()..5.0.toFloat()).reversed(): $list6"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('c'..'g' step 2).reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
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<Double>(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<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'g' downTo 'c': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = 9.0 downTo 3.0
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
val range7 = 9.0.toFloat() downTo 3.0.toFloat()
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(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"
|
||||
}
|
||||
|
||||
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'c'..'g': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = 3.0..9.0
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
val range7 = 3.0.toFloat()..9.0.toFloat()
|
||||
for (i in range7) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(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"
|
||||
}
|
||||
|
||||
Vendored
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for (\"ace\"[1])..(\"age\"[1]): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = (1.5 * 2)..(3.0 * 3.0)
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'g' downTo 'c' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
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<Double>(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<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
-20
@@ -52,25 +52,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'c'..'g' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
val range6 = 4.0..6.0 step 0.5
|
||||
for (i in range6) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'a' downTo 'z': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in -1.0 downTo 5.0) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for -1.0 downTo 5.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in -1.0.toFloat() downTo 5.0.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>()) {
|
||||
return "Wrong elements for -1.0.toFloat() downTo 5.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'z'..'a': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 5.0..-1.0) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for 5.0..-1.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in 5.0.toFloat()..-1.0.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>()) {
|
||||
return "Wrong elements for 5.0.toFloat()..-1.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-18
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'd' downTo 'a' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 5.5 downTo 3.7 step 0.5) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(5.5, 5.0, 4.5, 4.0)) {
|
||||
return "Wrong elements for 5.5 downTo 3.7 step 0.5: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
-18
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'a'..'d' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 4.0..5.8 step 0.5) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(4.0, 4.5, 5.0, 5.5)) {
|
||||
return "Wrong elements for 4.0..5.8 step 0.5: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in 4.0.toFloat()..5.8.toFloat() step 0.5.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(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"
|
||||
}
|
||||
|
||||
@@ -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<Double>()
|
||||
for (i in 0.0..5.0 step java.lang.Double.POSITIVE_INFINITY) {
|
||||
list1.add(i)
|
||||
if (list1.size() > 23) break
|
||||
}
|
||||
if (list1 != listOf<Double>(0.0)) {
|
||||
return "Wrong elements for 0.0..5.0 step java.lang.Double.POSITIVE_INFINITY: $list1"
|
||||
}
|
||||
|
||||
val list2 = ArrayList<Float>()
|
||||
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<Float>(0.0.toFloat())) {
|
||||
return "Wrong elements for 0.0.toFloat()..5.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list2"
|
||||
}
|
||||
|
||||
val list3 = ArrayList<Double>()
|
||||
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<Double>(5.0)) {
|
||||
return "Wrong elements for 5.0 downTo 0.0 step java.lang.Double.POSITIVE_INFINITY: $list3"
|
||||
}
|
||||
|
||||
val list4 = ArrayList<Float>()
|
||||
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<Float>(5.0.toFloat())) {
|
||||
return "Wrong elements for 5.0.toFloat() downTo 0.0.toFloat() step java.lang.Float.POSITIVE_INFINITY: $list4"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -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<Double>()
|
||||
for (i in java.lang.Double.NaN..5.0) {
|
||||
list1.add(i)
|
||||
if (list1.size() > 23) break
|
||||
}
|
||||
if (list1 != listOf<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN..5.0: $list1"
|
||||
}
|
||||
|
||||
val list2 = ArrayList<Float>()
|
||||
for (i in java.lang.Float.NaN.toFloat()..5.0.toFloat()) {
|
||||
list2.add(i)
|
||||
if (list2.size() > 23) break
|
||||
}
|
||||
if (list2 != listOf<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN.toFloat()..5.0.toFloat(): $list2"
|
||||
}
|
||||
|
||||
val list3 = ArrayList<Double>()
|
||||
for (i in java.lang.Double.NaN downTo 0.0) {
|
||||
list3.add(i)
|
||||
if (list3.size() > 23) break
|
||||
}
|
||||
if (list3 != listOf<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN downTo 0.0: $list3"
|
||||
}
|
||||
|
||||
val list4 = ArrayList<Float>()
|
||||
for (i in java.lang.Float.NaN.toFloat() downTo 0.0.toFloat()) {
|
||||
list4.add(i)
|
||||
if (list4.size() > 23) break
|
||||
}
|
||||
if (list4 != listOf<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN.toFloat() downTo 0.0.toFloat(): $list4"
|
||||
}
|
||||
|
||||
val list5 = ArrayList<Double>()
|
||||
for (i in 0.0..java.lang.Double.NaN) {
|
||||
list5.add(i)
|
||||
if (list5.size() > 23) break
|
||||
}
|
||||
if (list5 != listOf<Double>()) {
|
||||
return "Wrong elements for 0.0..java.lang.Double.NaN: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Float>()
|
||||
for (i in 0.0.toFloat()..java.lang.Float.NaN) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Float>()) {
|
||||
return "Wrong elements for 0.0.toFloat()..java.lang.Float.NaN: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Double>()
|
||||
for (i in 5.0 downTo java.lang.Double.NaN) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Double>()) {
|
||||
return "Wrong elements for 5.0 downTo java.lang.Double.NaN: $list7"
|
||||
}
|
||||
|
||||
val list8 = ArrayList<Float>()
|
||||
for (i in 5.0.toFloat() downTo java.lang.Float.NaN) {
|
||||
list8.add(i)
|
||||
if (list8.size() > 23) break
|
||||
}
|
||||
if (list8 != listOf<Float>()) {
|
||||
return "Wrong elements for 5.0.toFloat() downTo java.lang.Float.NaN: $list8"
|
||||
}
|
||||
|
||||
val list9 = ArrayList<Double>()
|
||||
for (i in java.lang.Double.NaN..java.lang.Double.NaN) {
|
||||
list9.add(i)
|
||||
if (list9.size() > 23) break
|
||||
}
|
||||
if (list9 != listOf<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN..java.lang.Double.NaN: $list9"
|
||||
}
|
||||
|
||||
val list10 = ArrayList<Float>()
|
||||
for (i in java.lang.Float.NaN..java.lang.Float.NaN) {
|
||||
list10.add(i)
|
||||
if (list10.size() > 23) break
|
||||
}
|
||||
if (list10 != listOf<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN..java.lang.Float.NaN: $list10"
|
||||
}
|
||||
|
||||
val list11 = ArrayList<Double>()
|
||||
for (i in java.lang.Double.NaN downTo java.lang.Double.NaN) {
|
||||
list11.add(i)
|
||||
if (list11.size() > 23) break
|
||||
}
|
||||
if (list11 != listOf<Double>()) {
|
||||
return "Wrong elements for java.lang.Double.NaN downTo java.lang.Double.NaN: $list11"
|
||||
}
|
||||
|
||||
val list12 = ArrayList<Float>()
|
||||
for (i in java.lang.Float.NaN downTo java.lang.Float.NaN) {
|
||||
list12.add(i)
|
||||
if (list12.size() > 23) break
|
||||
}
|
||||
if (list12 != listOf<Float>()) {
|
||||
return "Wrong elements for java.lang.Float.NaN downTo java.lang.Float.NaN: $list12"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'k' downTo 'k': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 5.0 downTo 5.0) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(5.0)) {
|
||||
return "Wrong elements for 5.0 downTo 5.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in 5.0.toFloat() downTo 5.0.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(5.0.toFloat())) {
|
||||
return "Wrong elements for 5.0.toFloat() downTo 5.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'k'..'k': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 5.0..5.0) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(5.0)) {
|
||||
return "Wrong elements for 5.0..5.0: $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in 5.0.toFloat()..5.0.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(5.0.toFloat())) {
|
||||
return "Wrong elements for 5.0.toFloat()..5.0.toFloat(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-18
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('c' downTo 'a').reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in (5.0 downTo 3.0).reversed()) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(3.0, 4.0, 5.0)) {
|
||||
return "Wrong elements for (5.0 downTo 3.0).reversed(): $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in (5.0.toFloat() downTo 3.0.toFloat()).reversed()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(3.0.toFloat(), 4.0.toFloat(), 5.0.toFloat())) {
|
||||
return "Wrong elements for (5.0.toFloat() downTo 3.0.toFloat()).reversed(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-18
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('a' downTo 'c').reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in (3.0 downTo 5.0).reversed()) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for (3.0 downTo 5.0).reversed(): $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in (3.0.toFloat() downTo 5.0.toFloat()).reversed()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>()) {
|
||||
return "Wrong elements for (3.0.toFloat() downTo 5.0.toFloat()).reversed(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('c'..'a').reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in (5.0..3.0).reversed()) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>()) {
|
||||
return "Wrong elements for (5.0..3.0).reversed(): $list6"
|
||||
}
|
||||
|
||||
val list7 = ArrayList<Float>()
|
||||
for (i in (5.0.toFloat()..3.0.toFloat()).reversed()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>()) {
|
||||
return "Wrong elements for (5.0.toFloat()..3.0.toFloat()).reversed(): $list7"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -38,23 +38,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('a'..'c').reversed(): $list4"
|
||||
}
|
||||
|
||||
val list5 = ArrayList<Double>()
|
||||
for (i in (3.0..5.0).reversed()) {
|
||||
list5.add(i)
|
||||
if (list5.size() > 23) break
|
||||
}
|
||||
if (list5 != listOf<Double>(5.0, 4.0, 3.0)) {
|
||||
return "Wrong elements for (3.0..5.0).reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Float>()
|
||||
for (i in (3.0.toFloat()..5.0.toFloat()).reversed()) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Float>(5.0.toFloat(), 4.0.toFloat(), 3.0.toFloat())) {
|
||||
return "Wrong elements for (3.0.toFloat()..5.0.toFloat()).reversed(): $list6"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
-18
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for ('c'..'g' step 2).reversed(): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in (4.0..6.0 step 0.5).reversed()) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'g' downTo 'c': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 9.0 downTo 3.0) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
for (i in 9.0.toFloat() downTo 3.0.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(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"
|
||||
}
|
||||
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'c'..'g': $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 3.0..9.0) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
for (i in 3.0.toFloat()..9.0.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(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"
|
||||
}
|
||||
|
||||
-18
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for (\"ace\"[1])..(\"age\"[1]): $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in (1.5 * 2)..(3.0 * 3.0)) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
-18
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'g' downTo 'c' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 6.0 downTo 4.0 step 0.5) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
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<Float>(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"
|
||||
}
|
||||
|
||||
@@ -47,23 +47,5 @@ fun box(): String {
|
||||
return "Wrong elements for 'c'..'g' step 2: $list5"
|
||||
}
|
||||
|
||||
val list6 = ArrayList<Double>()
|
||||
for (i in 4.0..6.0 step 0.5) {
|
||||
list6.add(i)
|
||||
if (list6.size() > 23) break
|
||||
}
|
||||
if (list6 != listOf<Double>(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<Float>()
|
||||
for (i in 4.0.toFloat()..6.0.toFloat() step 0.5.toFloat()) {
|
||||
list7.add(i)
|
||||
if (list7.size() > 23) break
|
||||
}
|
||||
if (list7 != listOf<Float>(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"
|
||||
}
|
||||
|
||||
-24
@@ -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");
|
||||
|
||||
@@ -144,10 +144,6 @@ public class Byte private () : Number, Comparable<Byte> {
|
||||
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<Short> {
|
||||
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<Int> {
|
||||
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<Long> {
|
||||
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<Float> {
|
||||
/** 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<Double> {
|
||||
/** 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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Float> /*, Iterable<Float> */ {
|
||||
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<Double> /*, Iterable<Double> */ {
|
||||
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}"
|
||||
}
|
||||
|
||||
|
||||
@@ -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<Float> {
|
||||
@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<Double> {
|
||||
@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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ class GenerateProgressionIterators(out: PrintWriter) : BuiltInsSourceGenerator(o
|
||||
out.println(integerProgressionIterator(kind))
|
||||
}
|
||||
else {
|
||||
out.println(floatingPointProgressionIterator(kind))
|
||||
continue
|
||||
}
|
||||
out.println()
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)""")
|
||||
|
||||
@@ -31,7 +31,6 @@ public operator fun Range<Long>.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<Short>.contains(item: Byte): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -40,9 +39,7 @@ public operator fun Range<Short>.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<Double>.contains(item: Byte): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -50,9 +47,7 @@ public operator fun Range<Double>.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<Float>.contains(item: Byte): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -76,7 +71,6 @@ public operator fun Range<Long>.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<Byte>.contains(item: Double): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -85,7 +79,6 @@ public operator fun Range<Byte>.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<Short>.contains(item: Double): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -94,9 +87,7 @@ public operator fun Range<Short>.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<Float>.contains(item: Double): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -120,7 +111,6 @@ public operator fun Range<Long>.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<Byte>.contains(item: Float): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -129,7 +119,6 @@ public operator fun Range<Byte>.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<Short>.contains(item: Float): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -138,9 +127,7 @@ public operator fun Range<Short>.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<Double>.contains(item: Float): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -156,7 +143,6 @@ public operator fun Range<Long>.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<Byte>.contains(item: Int): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -165,7 +151,6 @@ public operator fun Range<Byte>.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<Short>.contains(item: Int): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -174,9 +159,7 @@ public operator fun Range<Short>.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<Double>.contains(item: Int): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -184,9 +167,7 @@ public operator fun Range<Double>.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<Float>.contains(item: Int): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -202,7 +183,6 @@ public operator fun Range<Int>.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<Byte>.contains(item: Long): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -211,7 +191,6 @@ public operator fun Range<Byte>.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<Short>.contains(item: Long): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -220,9 +199,7 @@ public operator fun Range<Short>.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<Double>.contains(item: Long): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -230,9 +207,7 @@ public operator fun Range<Double>.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<Float>.contains(item: Long): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -256,7 +231,6 @@ public operator fun Range<Long>.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<Byte>.contains(item: Short): Boolean {
|
||||
return start <= item && item <= end
|
||||
@@ -265,9 +239,7 @@ public operator fun Range<Byte>.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<Double>.contains(item: Short): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
@@ -275,9 +247,7 @@ public operator fun Range<Double>.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<Float>.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>): 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: Comparable<T>> T.coerceIn(range: Range<T>): 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: Comparable<T>> T.coerceIn(range: Range<T>): 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>): 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>): 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>): 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
|
||||
|
||||
@@ -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<T: Comparable<T>> (
|
||||
private class ComparableRange<T: Comparable<T>> (
|
||||
override val start: T,
|
||||
override val end: T
|
||||
): Range<T> {
|
||||
override fun contains(item: T): Boolean {
|
||||
return start <= item && item <= end
|
||||
}
|
||||
override val endInclusive: T
|
||||
): ClosedRange<T> {
|
||||
|
||||
@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: Comparable<T>> T.rangeTo(that: T): ComparableRange<T> {
|
||||
return ComparableRange(this, that)
|
||||
}
|
||||
public operator fun <T: Comparable<T>> T.rangeTo(that: T): ClosedRange<T> = ComparableRange(this, that)
|
||||
|
||||
|
||||
internal fun checkStepIsPositive(isPositive: Boolean, step: Number) {
|
||||
|
||||
@@ -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<Float>(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<Float>(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))
|
||||
|
||||
@@ -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<Long>(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<Float>(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<Long>(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<Float>(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<Long>(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<Float>(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<Long>(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<Float>(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<Long>(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<Float>(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<Long>(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<Float>(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<Long>(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<Float>(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<Long>(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<Float>(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<Float>(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<Long>(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<Float>(6.0.toFloat(), 5.5.toFloat(), 5.0.toFloat(), 4.5.toFloat(), 4.0.toFloat()))
|
||||
}
|
||||
|
||||
// invariant progression.reversed().toList() == progression.toList().reversed() is preserved
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -79,7 +79,6 @@ fun comparables(): List<GenericFunction> {
|
||||
@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.")
|
||||
|
||||
@@ -7,6 +7,7 @@ fun ranges(): List<GenericFunction> {
|
||||
val templates = arrayListOf<GenericFunction>()
|
||||
|
||||
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<GenericFunction> {
|
||||
|
||||
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<GenericFunction> {
|
||||
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<GenericFunction> {
|
||||
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<GenericFunction> {
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user