summaryrefslogtreecommitdiff
path: root/test/junit/scala/collection
diff options
context:
space:
mode:
authorMartijn Hoekstra <martijnhoekstra@gmail.com>2016-05-16 18:52:06 +0200
committerMartijn Hoekstra <martijnhoekstra@gmail.com>2016-05-21 09:48:24 +0200
commitc89c36597f922fe29cbb3cec8095611f86ba4976 (patch)
treeeeaef6bee4da5441da999727ff5ba97c4e2aa394 /test/junit/scala/collection
parentb3f8332cf399cd15067c879c8297c25598045883 (diff)
downloadscala-c89c36597f922fe29cbb3cec8095611f86ba4976.tar.gz
scala-c89c36597f922fe29cbb3cec8095611f86ba4976.tar.bz2
scala-c89c36597f922fe29cbb3cec8095611f86ba4976.zip
SI-9766 - allow ++ on empty ConcatIterator
Diffstat (limited to 'test/junit/scala/collection')
-rw-r--r--test/junit/scala/collection/IteratorTest.scala18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala
index 329c85127a..d980cadeb3 100644
--- a/test/junit/scala/collection/IteratorTest.scala
+++ b/test/junit/scala/collection/IteratorTest.scala
@@ -192,4 +192,22 @@ class IteratorTest {
assertSameElements(exp, res)
assertEquals(8, counter) // was 14
}
+
+ // SI-9766
+ @Test def exhaustedConcatIteratorConcat: Unit = {
+ def consume[A](i: Iterator[A]) = {
+ while(i.hasNext) i.next()
+ }
+ val joiniter = Iterator.empty ++ Seq(1, 2, 3)
+ assertTrue(joiniter.hasNext)
+ consume(joiniter)
+ val concatiter = joiniter ++ Seq(4, 5, 6)
+ assertTrue(concatiter.hasNext)
+ consume(concatiter)
+ assertFalse(concatiter.hasNext)
+ val concatFromEmpty = concatiter ++ Seq(7, 8, 9)
+ assertTrue(concatFromEmpty.hasNext)
+ consume(concatFromEmpty)
+ assertFalse(concatFromEmpty.hasNext)
+ }
}