summaryrefslogtreecommitdiff
path: root/test/files/run/t9219.scala
diff options
context:
space:
mode:
authorSzabolcs Berecz <szabolcs.berecz@gmail.com>2015-03-14 01:27:02 +0100
committerSzabolcs Berecz <szabolcs.berecz@gmail.com>2015-03-14 01:27:02 +0100
commit8e0a386508d6cb655db0a29a23fb26170b262548 (patch)
tree261442a2328bbb61ad2c00fb4a22d665d8c1a102 /test/files/run/t9219.scala
parentfa33395a25c87115c910e8d4a4124aee6134062b (diff)
downloadscala-8e0a386508d6cb655db0a29a23fb26170b262548.tar.gz
scala-8e0a386508d6cb655db0a29a23fb26170b262548.tar.bz2
scala-8e0a386508d6cb655db0a29a23fb26170b262548.zip
SI-9219 Stream toString returns unexpected result
- Cursor was not advanced before appending the second element when only the first two elements of the stream were known. - When there is no cycle in the stream, the "scout" (and "cursor") ends up pointing to a stream where tailDefined is false. This means that cursor is either empty, or cursor.tail is not yet evaluated. The former case is handled properly, but in the latter case, one more element (cursor.head) needs to be appended.
Diffstat (limited to 'test/files/run/t9219.scala')
-rw-r--r--test/files/run/t9219.scala11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/files/run/t9219.scala b/test/files/run/t9219.scala
new file mode 100644
index 0000000000..c15f55faac
--- /dev/null
+++ b/test/files/run/t9219.scala
@@ -0,0 +1,11 @@
+object Test extends App {
+ def check[U](f: Stream[Int] => U) = {
+ val s = Stream.from(1)
+ f(s)
+ println(s)
+ }
+
+ check(_.tail)
+ check(_.take(4).force)
+ check(_(5))
+}