diff options
-rw-r--r-- | src/library/scala/collection/immutable/PagedSeq.scala | 7 | ||||
-rw-r--r-- | test/files/run/t3647.scala | 23 | ||||
-rw-r--r-- | test/files/run/t3935.scala | 15 |
3 files changed, 41 insertions, 4 deletions
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala index 9cb1040f95..270524eaa7 100644 --- a/src/library/scala/collection/immutable/PagedSeq.scala +++ b/src/library/scala/collection/immutable/PagedSeq.scala @@ -65,11 +65,10 @@ object PagedSeq { def fromLines(source: Iterator[String]): PagedSeq[Char] = { var isFirst = true fromStrings(source map { line => - if (isFirst) line - else { + if (isFirst) { isFirst = false - "\n"+line - } + line + } else "\n"+line }) } diff --git a/test/files/run/t3647.scala b/test/files/run/t3647.scala new file mode 100644 index 0000000000..a970e887f6 --- /dev/null +++ b/test/files/run/t3647.scala @@ -0,0 +1,23 @@ + + + +import collection.immutable._ + + +object Test { + def main(args: Array[String]) { + val ps = PagedSeq.fromLines(List( + "line1", + "line2", + "line3", + "line4" + ).iterator) + assert(ps.filter(_ == '\n').size == 3) + + val ps1 = PagedSeq.fromLines(List("Ok").iterator) + assert(ps1.filter(_ == '\n').size == 0) + + val eps = PagedSeq.fromLines(List().iterator) + assert(eps.filter(_ == '\n').size == 0) + } +} diff --git a/test/files/run/t3935.scala b/test/files/run/t3935.scala new file mode 100644 index 0000000000..c66b1b0599 --- /dev/null +++ b/test/files/run/t3935.scala @@ -0,0 +1,15 @@ + + + + +object Test { + def main(args: Array[String]) { + val q = scala.collection.mutable.Queue[String]() + assert(q.length == 0) + try { + assert(q.front != null) + } catch { + case _ => + } + } +} |