summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-05-20 13:26:59 +0000
committerPaul Phillips <paulp@improving.org>2010-05-20 13:26:59 +0000
commitb96804031a11f36ae00acc3020a7ed338b926abe (patch)
tree70e23a8fafb44532d546c6fe44f563484d42e359
parent50bf167d084b78e4c0f4b906ad0587cd29b533dc (diff)
downloadscala-b96804031a11f36ae00acc3020a7ed338b926abe.tar.gz
scala-b96804031a11f36ae00acc3020a7ed338b926abe.tar.bz2
scala-b96804031a11f36ae00acc3020a7ed338b926abe.zip
Bug in lastIndexOfSeq. Closes #3455, no review.
-rw-r--r--src/library/scala/collection/SeqLike.scala2
-rw-r--r--test/files/run/colltest1.scala6
2 files changed, 5 insertions, 3 deletions
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 26d113ed85..5f75169f3c 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -508,7 +508,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
* @return the last index such that the elements of this $coll starting a this index
* match the elements of sequence `that`, or `-1` of no such subsequence exists.
*/
- def lastIndexOfSlice[B >: A](that: Seq[B]): Int = lastIndexOfSlice(that, that.length)
+ def lastIndexOfSlice[B >: A](that: Seq[B]): Int = lastIndexOfSlice(that, length)
/** Finds last index before or at a given end index where this $coll contains a given sequence as a slice.
* @param that the sequence to test
diff --git a/test/files/run/colltest1.scala b/test/files/run/colltest1.scala
index 557282cb8d..943fe4c4e7 100644
--- a/test/files/run/colltest1.scala
+++ b/test/files/run/colltest1.scala
@@ -2,8 +2,7 @@ import collection._
object Test extends Application {
- def orderedTraversableTest(empty: Traversable[Int])
- {
+ def orderedTraversableTest(empty: Traversable[Int]) {
println("new test starting with "+empty)
assert(empty.isEmpty)
val ten = empty ++ List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
@@ -113,6 +112,9 @@ object Test extends Application {
assert(ten.endsWith(List(9, 10)))
assert(ten.endsWith(List()))
assert(ten.indexOfSlice(List(3, 4, 5)) == 2, ten.indexOfSlice(List(3, 4, 5)))
+ assert(ten.lastIndexOfSlice(List(8, 9, 10)) == 7)
+ assert(ten.lastIndexOfSlice(List(1, 2, 3)) == 0)
+ assert(ten.lastIndexOfSlice(List(9, 10, 11)) == -1)
assert(ten contains 1)
assert(ten contains 10)
assert(!(ten contains 0))