summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/streams.check6
-rw-r--r--test/files/run/streams.scala14
2 files changed, 20 insertions, 0 deletions
diff --git a/test/files/run/streams.check b/test/files/run/streams.check
index 5346c73d12..7f894052d9 100644
--- a/test/files/run/streams.check
+++ b/test/files/run/streams.check
@@ -17,3 +17,9 @@ Stream()
999
512
+100000
+Stream(100001, ?)
+Stream(100001, ?)
+true
+true
+705082704
diff --git a/test/files/run/streams.scala b/test/files/run/streams.scala
index 1e781a6171..970f3cef16 100644
--- a/test/files/run/streams.scala
+++ b/test/files/run/streams.scala
@@ -29,4 +29,18 @@ object Test extends Application {
def powers(x: Int) = if ((x&(x-1)) == 0) Some(x) else None
println(s3.flatMap(powers).reverse.head)
+ // large enough to generate StackOverflows (on most systems)
+ // unless the following methods are tail call optimized.
+ val size = 100000
+
+ // test tail recursive methods
+ println(Stream.from(1).take(size).last)
+ println(Stream.from(1).drop(size))
+ println(Stream.from(1).filter(_ > size).take(5))
+ println(Stream.from(1).take(size).forall(_ >= 0))
+ println(Stream.from(1).exists(_ > size))
+ Stream.from(1).take(size).foreach( x => () )
+ println(Stream.from(1).take(size).foldLeft(0)(_ + _))
+ val arr = new Array[Int](size)
+ Stream.from(1).take(size).copyToArray(arr, 0)
}