Renamed NumberSequence to Progression.
This commit is contained in:
@@ -5,7 +5,7 @@ import org.junit.Test as test
|
||||
|
||||
public class RangeIterationTest {
|
||||
private fun <N> doTest(
|
||||
sequence: NumberSequence<N>,
|
||||
sequence: Progression<N>,
|
||||
expectedStart: N,
|
||||
expectedEnd: N,
|
||||
expectedIncrement: Number,
|
||||
|
||||
@@ -143,15 +143,15 @@ public class RangeTest {
|
||||
assertFalse("trail" in range)
|
||||
}
|
||||
|
||||
test fun illegalSequenceCreation() {
|
||||
// create sequence explicitly with increment = 0
|
||||
failsWith(javaClass<IllegalArgumentException>()) { IntSequence(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { ByteSequence(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { ShortSequence(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { LongSequence(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { CharacterSequence('a', 'z', 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { DoubleSequence(0.0, 5.0, 0.0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { FloatSequence(0.0.toFloat(), 5.0.toFloat(), 0.0.toFloat()) }
|
||||
test fun illegalProgressionCreation() {
|
||||
// create Progression explicitly with increment = 0
|
||||
failsWith(javaClass<IllegalArgumentException>()) { IntProgression(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { ByteProgression(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { ShortProgression(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { LongProgression(0, 5, 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { CharProgression('a', 'z', 0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { DoubleProgression(0.0, 5.0, 0.0) }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { FloatProgression(0.0.toFloat(), 5.0.toFloat(), 0.0.toFloat()) }
|
||||
|
||||
failsWith(javaClass<IllegalArgumentException>()) { 0..5 step 0 }
|
||||
failsWith(javaClass<IllegalArgumentException>()) { 0.toByte()..5.toByte() step 0 }
|
||||
|
||||
@@ -20,7 +20,7 @@ private fun generateDownTos(outputFile: File, header: String) {
|
||||
|
||||
fun generateDownTo(writer: PrintWriter, fromType: String, toType: String) {
|
||||
val elementType = getMaxType(fromType, toType)
|
||||
val rangeType = if (elementType == "Char") "CharacterSequence" else elementType + "Sequence"
|
||||
val progressionType = elementType + "Progression"
|
||||
|
||||
val fromExpr = if (elementType == fromType) "this" else "this.to$elementType()"
|
||||
val toExpr = if (elementType == toType) "to" else "to.to$elementType()"
|
||||
@@ -32,8 +32,8 @@ private fun generateDownTos(outputFile: File, header: String) {
|
||||
}
|
||||
|
||||
writer.println("""
|
||||
public inline fun $fromType.downTo(to: $toType): $rangeType {
|
||||
return $rangeType($fromExpr, $toExpr, $incrementExpr)
|
||||
public inline fun $fromType.downTo(to: $toType): $progressionType {
|
||||
return $progressionType($fromExpr, $toExpr, $incrementExpr)
|
||||
}""")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user