summaryrefslogtreecommitdiff
path: root/test/files/run/stream-stack-overflow-filter-map.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/stream-stack-overflow-filter-map.scala')
-rw-r--r--test/files/run/stream-stack-overflow-filter-map.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/files/run/stream-stack-overflow-filter-map.scala b/test/files/run/stream-stack-overflow-filter-map.scala
new file mode 100644
index 0000000000..e2bd47bfca
--- /dev/null
+++ b/test/files/run/stream-stack-overflow-filter-map.scala
@@ -0,0 +1,14 @@
+object Test extends App {
+ //This runs fine.
+ val resFMap1 = (1 to 10000).toStream filter (_ => false) flatMap (Seq(_))
+ val resMap1 = (1 to 10000).toStream filter (_ => false) map (_ + 1)
+ assert(resMap1.isEmpty)
+ assert(resFMap1.isEmpty)
+ println(resMap1)
+ println(resFMap1)
+ //This will cause a stack overflow
+ val resFMap2 = (1 to 10000).toStream withFilter (_ => false) flatMap (Seq(_))
+ val resMap2 = (1 to 10000).toStream withFilter (_ => false) map (_ + 1)
+ assert(resMap1 == resMap2)
+ assert(resFMap1 == resFMap2)
+}