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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user