diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-09-26 14:29:12 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-09-26 14:29:12 -0700 |
commit | ae0269200c6e5af8120587e2317f595e746c6114 (patch) | |
tree | 0338816b25d52661777c8936ccc6f154f8fae474 /test | |
parent | 63f5eb5eb751fa5bfb69d0e783aa360abac82a1b (diff) | |
download | scala-ae0269200c6e5af8120587e2317f595e746c6114.tar.gz scala-ae0269200c6e5af8120587e2317f595e746c6114.tar.bz2 scala-ae0269200c6e5af8120587e2317f595e746c6114.zip |
SI-9936 SeqLike.indexWhere starts at zero
This follows the Scaladoc, and makes
```
"abcdef".indexOf('c', -1)
```
work like
```
"abcdef".toVector.indexOf('c', -1)
```
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/collection/SeqLikeTest.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/junit/scala/collection/SeqLikeTest.scala b/test/junit/scala/collection/SeqLikeTest.scala new file mode 100644 index 0000000000..2ab682299d --- /dev/null +++ b/test/junit/scala/collection/SeqLikeTest.scala @@ -0,0 +1,19 @@ +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 SeqLikeTest { + + @Test def `SI-9936 indexWhere`(): Unit = { + assertEquals(2, "abcde".indexOf('c', -1)) + assertEquals(2, "abcde".indexOf('c', -2)) + assertEquals(2, "abcde".toVector.indexOf('c', -1)) + assertEquals(2, "abcde".toVector.indexOf('c', -2)) + assertEquals(2, "abcde".toVector.indexWhere(_ == 'c', -1)) + assertEquals(2, "abcde".toVector.indexWhere(_ == 'c', -2)) + } +} |