summaryrefslogtreecommitdiff
path: root/test/junit/scala/collection/IteratorTest.scala
diff options
context:
space:
mode:
authorSom Snytt <som.snytt@gmail.com>2014-05-27 12:06:56 -0700
committerSom Snytt <som.snytt@gmail.com>2014-05-27 12:06:56 -0700
commitd4f664c98364858c319b599caa1cdbb68030440a (patch)
tree65f9efb179460384b5ddb224faf574be6d8ca52c /test/junit/scala/collection/IteratorTest.scala
parent5551cf66e5b27ae398b527df6fe4247aed1ff307 (diff)
downloadscala-d4f664c98364858c319b599caa1cdbb68030440a.tar.gz
scala-d4f664c98364858c319b599caa1cdbb68030440a.tar.bz2
scala-d4f664c98364858c319b599caa1cdbb68030440a.zip
SI-8475 GroupedIterator is also lazy when padded
This is the related case which dnlgtm in the previous fix. The old code seems to be tilting for laziness, but we have to fill the buffer with the current group anyway, so there is no reason to be coy about calling ArrayBuffer.length.
Diffstat (limited to 'test/junit/scala/collection/IteratorTest.scala')
-rw-r--r--test/junit/scala/collection/IteratorTest.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala
index cb7cbb40bc..b7a9805c9f 100644
--- a/test/junit/scala/collection/IteratorTest.scala
+++ b/test/junit/scala/collection/IteratorTest.scala
@@ -17,4 +17,12 @@ class IteratorTest {
slidingIt.next
assertEquals("Counter should be one, that means we didn't look further than needed", 1, counter)
}
+
+ @Test def groupedIteratorIsLazyWhenPadded(): Unit = {
+ var counter = 0
+ def it = new Iterator[Int] { var i = 0 ; def hasNext = { counter = i; true } ; def next = { i += 1; i } }
+ val slidingIt = it sliding 2 withPadding -1
+ slidingIt.next
+ assertEquals("Counter should be one, that means we didn't look further than needed", 1, counter)
+ }
}