diff options
author | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-05-28 12:16:15 +0200 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@typesafe.com> | 2015-05-28 12:16:15 +0200 |
commit | 3ae3e9f086f88054102aa3b88bc18350d85edd1f (patch) | |
tree | 22d00b34f0cc48c2e11663b0d005859295403457 /test | |
parent | b0a511f579013357aed47a4e51287175214da29a (diff) | |
parent | 5ebb7bb3bfc0e5152a707e693379d5ac5b5d9355 (diff) | |
download | scala-3ae3e9f086f88054102aa3b88bc18350d85edd1f.tar.gz scala-3ae3e9f086f88054102aa3b88bc18350d85edd1f.tar.bz2 scala-3ae3e9f086f88054102aa3b88bc18350d85edd1f.zip |
Merge pull request #4530 from som-snytt/issue/9332
SI-9332 Iterator.span exhausts leading iterator
Diffstat (limited to 'test')
-rw-r--r-- | test/junit/scala/collection/IteratorTest.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/junit/scala/collection/IteratorTest.scala b/test/junit/scala/collection/IteratorTest.scala index d5389afd0c..1c1e50aed9 100644 --- a/test/junit/scala/collection/IteratorTest.scala +++ b/test/junit/scala/collection/IteratorTest.scala @@ -154,4 +154,14 @@ class IteratorTest { results += (Stream from 1).toIterator.drop(10).toStream.drop(10).toIterator.next() assertSameElements(List(1,1,21), results) } + // SI-9332 + @Test def spanExhaustsLeadingIterator(): Unit = { + def it = Iterator.iterate(0)(_ + 1).take(6) + val (x, y) = it.span(_ != 1) + val z = x.toList + assertEquals(1, z.size) + assertFalse(x.hasNext) + assertEquals(1, y.next) + assertFalse(x.hasNext) // was true, after advancing underlying iterator + } } |