diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-12 09:32:36 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-12 09:32:36 -0800 |
commit | 668966be53da2b9b8602098625180192438345b1 (patch) | |
tree | 0b2918c93c6a91cae308044b9926ce2471e32ca7 /test/junit | |
parent | 00067482917cbe7ac337550e1f565fea966c2d78 (diff) | |
parent | e152297090c26051b7e9a6a1740c4670d23d9d5d (diff) | |
download | scala-668966be53da2b9b8602098625180192438345b1.tar.gz scala-668966be53da2b9b8602098625180192438345b1.tar.bz2 scala-668966be53da2b9b8602098625180192438345b1.zip |
Merge pull request #3437 from Ichoran/issue/6736
SI-6736 Range.contains is wrong
Diffstat (limited to 'test/junit')
-rw-r--r-- | test/junit/scala/collection/NumericRangeTest.scala | 19 |
1 files changed, 18 insertions, 1 deletions
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 } ) + } } |