Add failing tests for overflow in empty progressions KT-24204

This commit is contained in:
Ilya Gorbunov
2018-07-09 03:43:47 +03:00
parent 14b8ff7d71
commit be8cb94105
12 changed files with 304 additions and 2 deletions
@@ -93,6 +93,11 @@ public class RangeIterationJVMTest : RangeIterationTestBase() {
doTest((MaxC - 5)..MaxC step 3, (MaxC - 5), (MaxC - 2), 3, listOf((MaxC - 5), (MaxC - 2)))
}
@Test fun overflowZeroToMinValue() {
doTest(0..MinI step 3, 0, MinI, 3, listOf())
doTest(0L..MinL step 3, 0, MinL, 3.toLong(), listOf())
}
@Test fun progressionDownToMinValue() {
doTest((MinI + 2) downTo MinI step 1, MinI + 2, MinI, -1, listOf(MinI + 2, MinI + 1, MinI))
doTest((MinB + 2).toByte() downTo MinB step 1, (MinB + 2).toInt(), MinB.toInt(), -1, listOf((MinB + 2).toInt(), (MinB + 1).toInt(), MinB.toInt()))
@@ -110,4 +115,9 @@ public class RangeIterationJVMTest : RangeIterationTestBase() {
doTest((MinC + 5) downTo MinC step 3, (MinC + 5), (MinC + 2), -3, listOf((MinC + 5), (MinC + 2)))
}
@Test fun overflowZeroDownToMaxValue() {
doTest(0 downTo MaxI step 3, 0, MaxI, -3, listOf())
doTest(0 downTo MaxL step 3, 0, MaxL, -3.toLong(), listOf())
}
}
@@ -54,6 +54,7 @@ class ProgressionLastElementTest {
doTest(MIN + 1, MAX, MAX, MAX)
doTest(MAX - 7, MAX, 3, MAX - 1)
doTest(MAX - 7, MAX, MAX, MAX - 7)
doTest(0, MAX, -3, MAX)
// end == MIN
doTest(0, MIN, MIN, MIN)
@@ -61,6 +62,7 @@ class ProgressionLastElementTest {
doTest(MAX, MIN, MIN, -1)
doTest(MIN + 7, MIN, -3, MIN + 1)
doTest(MIN + 7, MIN, MIN, MIN + 7)
doTest(0, MIN, 3, MIN)
}
@Test fun iterateToFinalElement() {