summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/immutable/Range.scala2
-rw-r--r--test/files/scalacheck/range.scala7
2 files changed, 8 insertions, 1 deletions
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index ed4f4615c2..804c67527a 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -128,7 +128,7 @@ extends IndexedSeq[Int]
if (isEmpty)
Nil.init
- dropRight(length - 1)
+ dropRight(1)
}
/** Creates a new range containing all the elements of this range except the first one.
diff --git a/test/files/scalacheck/range.scala b/test/files/scalacheck/range.scala
index 6a0e83a47d..56295f204c 100644
--- a/test/files/scalacheck/range.scala
+++ b/test/files/scalacheck/range.scala
@@ -130,6 +130,13 @@ abstract class RangeTest(kind: String) extends Properties("Range "+kind) {
(t.size == (0 max x min r.size) && t.start == r.start && t.step == r.step) :| str(r)+" / "+str(t)+": "+x
}
+ property("init") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r))) { r =>
+ (r.size == 0) || {
+ val t = r.init
+ (t.size + 1 == r.size) && (t.isEmpty || t.head == r.head)
+ }
+ }
+
property("takeWhile") = forAll(myGen suchThat (r => expectedSize(r).toInt == expectedSize(r)), arbInt.arbitrary) { (r, x) =>
val t = (if (r.step > 0) r takeWhile (_ <= x) else r takeWhile(_ >= x))
if (r.size == 0) {