summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-10-29 17:17:43 -0700
committerPaul Phillips <paulp@improving.org>2012-11-01 05:04:53 -0700
commit8a537b7d7da03833946a6a2f4461da2080363c88 (patch)
tree50d2a05eb55cd8b7f8f56f09260ddebf55f16f8f /test
parente660b58f795a9ad7825398b5831e4011b652cffb (diff)
downloadscala-8a537b7d7da03833946a6a2f4461da2080363c88.tar.gz
scala-8a537b7d7da03833946a6a2f4461da2080363c88.tar.bz2
scala-8a537b7d7da03833946a6a2f4461da2080363c88.zip
Fix SI-6584, Stream#distinct uses too much memory.
Nesting recursive calls in Stream is always a dicey business.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t6584.check8
-rw-r--r--test/files/run/t6584.scala16
2 files changed, 24 insertions, 0 deletions
diff --git a/test/files/run/t6584.check b/test/files/run/t6584.check
new file mode 100644
index 0000000000..35c8688751
--- /dev/null
+++ b/test/files/run/t6584.check
@@ -0,0 +1,8 @@
+Array: 102400
+Vector: 102400
+List: 102400
+Stream: 102400
+Array: 102400
+Vector: 102400
+List: 102400
+Stream: 102400
diff --git a/test/files/run/t6584.scala b/test/files/run/t6584.scala
new file mode 100644
index 0000000000..24c236ef35
--- /dev/null
+++ b/test/files/run/t6584.scala
@@ -0,0 +1,16 @@
+object Test {
+ def main(args: Array[String]): Unit = {
+ val size = 100 * 1024
+ val doubled = (1 to size) ++ (1 to size)
+
+ println("Array: " + Array.tabulate(size)(x => x).distinct.size)
+ println("Vector: " + Vector.tabulate(size)(x => x).distinct.size)
+ println("List: " + List.tabulate(size)(x => x).distinct.size)
+ println("Stream: " + Stream.tabulate(size)(x => x).distinct.size)
+
+ println("Array: " + doubled.toArray.distinct.size)
+ println("Vector: " + doubled.toVector.distinct.size)
+ println("List: " + doubled.toList.distinct.size)
+ println("Stream: " + doubled.toStream.distinct.size)
+ }
+}