summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2014-01-31 17:18:29 -0800
committerRex Kerr <ichoran@gmail.com>2014-02-09 12:41:33 -0800
commite152297090c26051b7e9a6a1740c4670d23d9d5d (patch)
tree805e754ab40aaf56ccdc6581d8d6ed1e1e6d6fe3 /test/junit
parent95f21ca8a095767202e1c4d620a865c1647d7e6c (diff)
downloadscala-e152297090c26051b7e9a6a1740c4670d23d9d5d.tar.gz
scala-e152297090c26051b7e9a6a1740c4670d23d9d5d.tar.bz2
scala-e152297090c26051b7e9a6a1740c4670d23d9d5d.zip
Reasonable Range operations consistently work when overfull.
Operations are reasonable when they don't require indexing or conversion into a collection. These include head, tail, init, last, drop, take, dropWhile, takeWhile, dropRight, takeRight, span. Tests added also to verify the new behavior.
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/collection/NumericRangeTest.scala18
1 files changed, 15 insertions, 3 deletions
diff --git a/test/junit/scala/collection/NumericRangeTest.scala b/test/junit/scala/collection/NumericRangeTest.scala
index f03bf1c498..3980c31577 100644
--- a/test/junit/scala/collection/NumericRangeTest.scala
+++ b/test/junit/scala/collection/NumericRangeTest.scala
@@ -122,7 +122,19 @@ class RangeConsistencyTest {
}}
@Test
- def testSI6736() { assert{
- (0 to Int.MaxValue).contains(4) && !((Int.MinValue to 0).contains(4))
- } }
+ 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 } )
+ }
}