diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/scalacheck/range.scala | 3 | ||||
-rw-r--r-- | test/junit/scala/collection/NumericRangeTest.scala | 19 |
2 files changed, 20 insertions, 2 deletions
diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala index 1eb186f303..493083a51f 100644 --- a/test/files/scalacheck/range.scala +++ b/test/files/scalacheck/range.scala @@ -265,7 +265,8 @@ object TooLargeRange extends Properties("Too Large Range") { property("Too large range throws exception") = forAll(genTooLargeStart) { start => try { val r = Range.inclusive(start, Int.MaxValue, 1) - println("how here? r = " + r.toString) + val l = r.length + println("how here? length = " + l + ", r = " + r.toString) false } catch { case _: IllegalArgumentException => true } diff --git a/test/junit/scala/collection/NumericRangeTest.scala b/test/junit/scala/collection/NumericRangeTest.scala index 0260723b9d..3980c31577 100644 --- a/test/junit/scala/collection/NumericRangeTest.scala +++ b/test/junit/scala/collection/NumericRangeTest.scala @@ -6,7 +6,7 @@ import org.junit.Test import scala.math._ import scala.util._ -/* Tests various maps by making sure they all agree on the same answers. */ +/* Tests various ranges by making sure they all agree on the same answers. */ @RunWith(classOf[JUnit4]) class RangeConsistencyTest { def r2nr[T: Integral]( @@ -120,4 +120,21 @@ class RangeConsistencyTest { case _ => false } }} + + @Test + def testSI6736() { + // These operations on overfull ranges should all succeed. + assert( (0 to Int.MaxValue).contains(4) ) + assert( !((Int.MinValue to 0).contains(4)) ) + assert( (Int.MinValue to 0).last == 0 ) + assert( (Int.MinValue until 5).last == 4 ) + assert( (-7 to -99 by -4).last == -99 && (-7 until -99 by -4).last == -95 ) + assert( (Int.MinValue to 5) == (Int.MinValue until 6) ) + assert( (-3 to Int.MaxValue).drop(4).length == Int.MaxValue ) + assert( (-3 to Int.MaxValue).take(1234) == (-3 to 1230) ) + assert( (-3 to Int.MaxValue).dropRight(4).length == Int.MaxValue ) + assert( (-3 to Int.MaxValue).takeRight(1234).length == 1234 ) + assert( (-3 to Int.MaxValue).dropWhile(_ <= 0).length == Int.MaxValue ) + assert( (-3 to Int.MaxValue).span(_ <= 0) match { case (a,b) => a.length == 4 && b.length == Int.MaxValue } ) + } } |