summaryrefslogtreecommitdiff
path: root/test/junit
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2014-12-04 17:28:26 +0100
committerLukas Rytz <lukas.rytz@typesafe.com>2014-12-04 17:28:26 +0100
commit083c6657d5d8c0a3a4fad017928a2c1c644d8fb7 (patch)
tree81b42ae308c382c920e674e28a1689420ac08f02 /test/junit
parentb1ae72455e9749df233d8a9f7cea6d486acc8424 (diff)
parent7cf0370ef9e68b60f594143447b753945a8a8780 (diff)
downloadscala-083c6657d5d8c0a3a4fad017928a2c1c644d8fb7.tar.gz
scala-083c6657d5d8c0a3a4fad017928a2c1c644d8fb7.tar.bz2
scala-083c6657d5d8c0a3a4fad017928a2c1c644d8fb7.zip
Merge pull request #4146 from Ichoran/issue/6519
SI-6519 PagedSeq is not lazy enough
Diffstat (limited to 'test/junit')
-rw-r--r--test/junit/scala/collection/immutable/PagedSeqTest.scala18
1 files changed, 15 insertions, 3 deletions
diff --git a/test/junit/scala/collection/immutable/PagedSeqTest.scala b/test/junit/scala/collection/immutable/PagedSeqTest.scala
index 5f83cf6f31..2b576a3655 100644
--- a/test/junit/scala/collection/immutable/PagedSeqTest.scala
+++ b/test/junit/scala/collection/immutable/PagedSeqTest.scala
@@ -5,12 +5,24 @@ import org.junit.runners.JUnit4
import org.junit.Test
import org.junit.Assert._
-/* Test for SI-6615 */
@RunWith(classOf[JUnit4])
class PagedSeqTest {
+ // should not NPE, and should equal the given Seq
@Test
- def rovingDoesNotNPE(): Unit = {
- // should not NPE, and should equal the given Seq
+ def test_SI6615(): Unit = {
assertEquals(Seq('a'), PagedSeq.fromStrings(List.fill(5000)("a")).slice(4096, 4097))
}
+
+ // Slices shouldn't read outside where they belong
+ @Test
+ def test_SI6519 {
+ var readAttempt = 0
+ val sideEffectingIterator = new Iterator[Int] {
+ def hasNext = readAttempt < 65536
+ def next = { readAttempt += 1; readAttempt }
+ }
+ val s = PagedSeq.fromIterator(sideEffectingIterator).slice(0,2).mkString
+ assertEquals(s, "12")
+ assert(readAttempt <= 4096)
+ }
}