Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SI-8553 WrappedArray throws exception on lastIndexWhere when index ou…
…t 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.
- Loading branch information
1 parent
3f28bbe
commit 7f08e00
Showing
2 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} |