summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTomas Janousek <tomi@nomi.cz>2015-09-19 01:09:24 +0200
committerLukas Rytz <lukas.rytz@gmail.com>2015-09-21 11:53:49 +0200
commit8cca2bcae8d1393cb7de8f777ace6a918acabb28 (patch)
tree53400d136c1b7aa21a13f302e6648439a24b8023 /test
parent0f72dd37f85bbcaa07cfb325685dc019e6bc1c26 (diff)
downloadscala-8cca2bcae8d1393cb7de8f777ace6a918acabb28.tar.gz
scala-8cca2bcae8d1393cb7de8f777ace6a918acabb28.tar.bz2
scala-8cca2bcae8d1393cb7de8f777ace6a918acabb28.zip
Fix NPE in PagedSeq.slice at end of seq
See https://github.com/scala/scala-parser-combinators/issues/70 Basically the same thing as SI-6615, including the fact everything works okay if the PagedSeq is printed before calling slice. It might seem strange that this allows taking slices that start beyond the end, but - this was possible anyway if one forced the entire sequence, and - it is reasonable to be able to take a slice at the very end (not beyond it) and get an empty sequence, which is exactly what StreamReader in scala-parser-combinators does and gets an NPE.
Diffstat (limited to 'test')
-rw-r--r--test/junit/scala/collection/immutable/PagedSeqTest.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/junit/scala/collection/immutable/PagedSeqTest.scala b/test/junit/scala/collection/immutable/PagedSeqTest.scala
index 2b576a3655..74f8825307 100644
--- a/test/junit/scala/collection/immutable/PagedSeqTest.scala
+++ b/test/junit/scala/collection/immutable/PagedSeqTest.scala
@@ -13,6 +13,12 @@ class PagedSeqTest {
assertEquals(Seq('a'), PagedSeq.fromStrings(List.fill(5000)("a")).slice(4096, 4097))
}
+ // should not NPE, and should be empty
+ @Test
+ def test_SI9480(): Unit = {
+ assertEquals(Seq(), PagedSeq.fromStrings(List("a")).slice(1))
+ }
+
// Slices shouldn't read outside where they belong
@Test
def test_SI6519 {