summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorRui Gonçalves <ruippeixotog@gmail.com>2014-05-12 00:29:44 +0100
committerRui Gonçalves <ruippeixotog@gmail.com>2014-05-12 00:29:44 +0100
commit7f08e00a3aa0f59314767313977d9f2899a80cd9 (patch)
treebbf7de6e28ca76648b72c31a5911c255f8b9eab6 /test/junit
parent3f28bbed6d1c2d49201da700907aae460f15cd4d (diff)
downloadscala-7f08e00a3aa0f59314767313977d9f2899a80cd9.tar.gz
scala-7f08e00a3aa0f59314767313977d9f2899a80cd9.tar.bz2
scala-7f08e00a3aa0f59314767313977d9f2899a80cd9.zip
SI-8553 WrappedArray throws exception on lastIndexWhere when index out of range
Adds a check in `IndexedSeqOptimized#lastIndexWhere(A => Boolean, Int)` to begin searching in the end of the collection if `end` is greater than the collection's length. Discussed in https://groups.google.com/d/topic/scala-internals/-MacXivbY0Q/discussion.
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/collection/IndexedSeqOptimizedTest.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/junit/scala/collection/IndexedSeqOptimizedTest.scala b/test/junit/scala/collection/IndexedSeqOptimizedTest.scala
new file mode 100644
index 0000000000..e5382907af
--- /dev/null
+++ b/test/junit/scala/collection/IndexedSeqOptimizedTest.scala
@@ -0,0 +1,16 @@
+package scala.collection
+
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import org.junit.Assert._
+import org.junit.Test
+
+@RunWith(classOf[JUnit4])
+class IndexedSeqOptimizedTest {
+
+ @Test
+ def notThrowsAnExceptionInLastIndexOf() {
+ assertEquals(0, (Array(2): collection.mutable.WrappedArray[Int]).lastIndexWhere(_ => true, 1))
+ assertEquals(2, "abc123".lastIndexWhere(_.isLetter, 6))
+ }
+}