From 7f08e00a3aa0f59314767313977d9f2899a80cd9 Mon Sep 17 00:00:00 2001 From: Rui Gonçalves Date: Mon, 12 May 2014 00:29:44 +0100 Subject: 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. --- .../junit/scala/collection/IndexedSeqOptimizedTest.scala | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 test/junit/scala/collection/IndexedSeqOptimizedTest.scala (limited to 'test/junit') 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)) + } +} -- cgit v1.2.3