summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2009-10-27 10:23:01 +0000
committerAdriaan Moors <adriaan.moors@epfl.ch>2009-10-27 10:23:01 +0000
commit38c3ca67563a68e8f30fd84282b1b9c4cebadeaa (patch)
tree5c6dbdef9f540e986110fb739227bfa0a78acce9 /test/files
parent42a42ac0c346d48594958ac80d5eb814b8aa0c39 (diff)
downloadscala-38c3ca67563a68e8f30fd84282b1b9c4cebadeaa.tar.gz
scala-38c3ca67563a68e8f30fd84282b1b9c4cebadeaa.tar.bz2
scala-38c3ca67563a68e8f30fd84282b1b9c4cebadeaa.zip
fixed bug in Stream::flatMap (still optimised a...
fixed bug in Stream::flatMap (still optimised as it was needed for correctness --> added regression tests for corresponding tickets)
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/stream_flatmap_odds.check1
-rw-r--r--test/files/run/stream_flatmap_odds.scala4
-rw-r--r--test/files/run/t153.check1
-rw-r--r--test/files/run/t153.scala5
-rw-r--r--test/files/run/t498.check1
-rw-r--r--test/files/run/t498.scala5
6 files changed, 17 insertions, 0 deletions
diff --git a/test/files/run/stream_flatmap_odds.check b/test/files/run/stream_flatmap_odds.check
new file mode 100644
index 0000000000..2b945e7c64
--- /dev/null
+++ b/test/files/run/stream_flatmap_odds.check
@@ -0,0 +1 @@
+Stream(1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83)
diff --git a/test/files/run/stream_flatmap_odds.scala b/test/files/run/stream_flatmap_odds.scala
new file mode 100644
index 0000000000..ed1a537bd9
--- /dev/null
+++ b/test/files/run/stream_flatmap_odds.scala
@@ -0,0 +1,4 @@
+object Test extends Application {
+ lazy val odds: Stream[Int] = Stream(1) append ( odds flatMap {x => Stream(x + 2)} )
+ println(odds take 42 force)
+} \ No newline at end of file
diff --git a/test/files/run/t153.check b/test/files/run/t153.check
new file mode 100644
index 0000000000..504fd7fc7f
--- /dev/null
+++ b/test/files/run/t153.check
@@ -0,0 +1 @@
+Stream(524288, 262144, 131072, 65536, 32768, 16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1)
diff --git a/test/files/run/t153.scala b/test/files/run/t153.scala
new file mode 100644
index 0000000000..c7b3c1c762
--- /dev/null
+++ b/test/files/run/t153.scala
@@ -0,0 +1,5 @@
+object Test extends Application {
+ def powers(x: Int) = if ((x&(x-1))==0) Some(x) else None
+ val res = (Stream.range(1, 1000000) flatMap powers).reverse
+ println(res take 42 force)
+} \ No newline at end of file
diff --git a/test/files/run/t498.check b/test/files/run/t498.check
new file mode 100644
index 0000000000..b1ce75e80b
--- /dev/null
+++ b/test/files/run/t498.check
@@ -0,0 +1 @@
+Stream(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
diff --git a/test/files/run/t498.scala b/test/files/run/t498.scala
new file mode 100644
index 0000000000..50be317c4c
--- /dev/null
+++ b/test/files/run/t498.scala
@@ -0,0 +1,5 @@
+object Test extends Application {
+// the function passed to flatMap produces lots of empty streams, but this should not overflow the stack
+ val res = Stream.from(1).flatMap(i => if (i < 3000) Stream.empty else List(1))
+ println(res take 42 force)
+} \ No newline at end of file