diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2010-09-01 13:43:34 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2010-09-01 13:43:34 +0000 |
commit | f52089a07e3dcd276d36531ca6af0d706e1ee0cd (patch) | |
tree | e432c406f2fffd5a52c8864f7b10142e91ecce47 /test/files | |
parent | 27c9348ba828374df3e36b86103cf70abd82647e (diff) | |
download | scala-f52089a07e3dcd276d36531ca6af0d706e1ee0cd.tar.gz scala-f52089a07e3dcd276d36531ca6af0d706e1ee0cd.tar.bz2 scala-f52089a07e3dcd276d36531ca6af0d706e1ee0cd.zip |
Merged revisions 22114,22141-22142,22196,22486-...
Merged revisions
22114,22141-22142,22196,22486-22487,22526-22527,22869,22871 via svnmerge
from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r22114 | prokopec | 2010-06-01 18:15:40 +0200 (Tue, 01 Jun 2010) | 1 line
Fixes #3496. No review.
........
r22141 | prokopec | 2010-06-02 18:31:56 +0200 (Wed, 02 Jun 2010) | 4 lines
Partially solves the problem for #3502. review by extempore
This commit reimplements filter for Streams, but does not reimplement
map in StreamWithFilter.
The problem is that GC can't collect instances of Streams residing on the stack if there are multiple references to the Stream (more than a single one on the stack on which a Stream method is invoked). In the case of a StreamWithFilter, being an inner class, there is always an `$outer` reference to the outer object, so there is little GC can do. Possible solution - change the return type of WithFilter to something else (in TraversableLike) to allow it to return objects that don't have to subclass TraversableLike.WithFilter, and reimplement the withFilter method in Stream to simply call `filter` method - in the case of Streams, `withFilter` has little sense in either case...
........
r22142 | prokopec | 2010-06-02 19:09:39 +0200 (Wed, 02 Jun 2010) | 1 line
Fixes #3508. No review is necessary.
........
r22196 | prokopec | 2010-06-08 18:17:58 +0200 (Tue, 08 Jun 2010) | 1 line
Fixes #3461. No review.p
........
r22486 | prokopec | 2010-07-05 11:25:39 +0200 (Mon, 05 Jul 2010) | 1 line
Fixes #3580. Review by extempore.
........
r22487 | prokopec | 2010-07-05 12:08:32 +0200 (Mon, 05 Jul 2010) | 1 line
Fixes #3584. No review.
........
r22526 | prokopec | 2010-07-09 13:31:34 +0200 (Fri, 09 Jul 2010) | 1 line
closes #3603. no review
........
r22527 | prokopec | 2010-07-09 17:06:01 +0200 (Fri, 09 Jul 2010) | 1 line
Closes #3493. Review by extempore.
........
r22869 | prokopec | 2010-08-31 12:29:42 +0200 (Tue, 31 Aug 2010) | 1 line
Fixes #3684. Closes #3684. No review.
........
r22871 | prokopec | 2010-08-31 13:27:46 +0200 (Tue, 31 Aug 2010) | 1 line
Fix for #3684. No review
........
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/t3493.scala | 15 | ||||
-rw-r--r-- | test/files/run/t3496.scala | 15 | ||||
-rw-r--r-- | test/files/run/t3502.scala | 24 | ||||
-rw-r--r-- | test/files/run/t3508.scala | 11 | ||||
-rw-r--r-- | test/files/run/t3580.scala | 17 | ||||
-rw-r--r-- | test/files/run/t3603.scala | 18 |
6 files changed, 100 insertions, 0 deletions
diff --git a/test/files/run/t3493.scala b/test/files/run/t3493.scala new file mode 100644 index 0000000000..aafe7a3a4a --- /dev/null +++ b/test/files/run/t3493.scala @@ -0,0 +1,15 @@ + + + + +object Test { + + def main(args: Array[String]) { + import scala.collection.immutable._ + val x = TreeSet("a", "b", "c", "d") + val x2 = x + "e" + assert(x2.toString == "TreeSet(a, b, c, d, e)") + assert(x2.toString == runtime.ScalaRunTime.stringOf(x2).trim) + } + +} diff --git a/test/files/run/t3496.scala b/test/files/run/t3496.scala new file mode 100644 index 0000000000..e1aa032ab1 --- /dev/null +++ b/test/files/run/t3496.scala @@ -0,0 +1,15 @@ + + + + +// ticket #3496 +object Test { + + def main(args: Array[String]) { + val s = Stream.from(1) + s.take(5) + s.drop(5) + s.splitAt(5) + } + +} diff --git a/test/files/run/t3502.scala b/test/files/run/t3502.scala new file mode 100644 index 0000000000..cc78e54c86 --- /dev/null +++ b/test/files/run/t3502.scala @@ -0,0 +1,24 @@ + + + + + +// ticket #3502 +object Test { + + object GeneratePrimeFactorsLazy extends (Int => List[Int]) { + override def apply(n:Int) = { + val s = Stream.range(2, n / 2).filter(n % _ == 0) + //val s = for (i <- Stream.range(2, n / 2); if n % i == 0) yield i + s.headOption.map(x => x :: apply(n / x)).getOrElse(List(n)) + } + } + + def main(args:Array[String]) { + // a prime number + //val num = 623456789 + val num = 2796203 + assert(GeneratePrimeFactorsLazy(num) == List(num)) + } + +} diff --git a/test/files/run/t3508.scala b/test/files/run/t3508.scala new file mode 100644 index 0000000000..01d976ba0d --- /dev/null +++ b/test/files/run/t3508.scala @@ -0,0 +1,11 @@ + + +import collection.immutable._ + + +// ticket #3508 +object Test { + def main(args: Array[String]) { + assert(Stream.tabulate(123)(_ + 1).toList == List.tabulate(123)(_ + 1)) + } +} diff --git a/test/files/run/t3580.scala b/test/files/run/t3580.scala new file mode 100644 index 0000000000..50ff6c4551 --- /dev/null +++ b/test/files/run/t3580.scala @@ -0,0 +1,17 @@ + + + + + +object Test { + + class Empty extends Traversable[Nothing] { + def foreach[U](f: Nothing => U) {} + } + + def main(args: Array[String]) { + val t = new Empty + t.toStream + } + +} diff --git a/test/files/run/t3603.scala b/test/files/run/t3603.scala new file mode 100644 index 0000000000..a89cb7080a --- /dev/null +++ b/test/files/run/t3603.scala @@ -0,0 +1,18 @@ + + + +object Test { + + def main(args: Array[String]) { + import collection.immutable._ + + val intmap = IntMap(1 -> 1, 2 -> 2) + val intres = intmap.map { case (a, b) => (a, b.toString) } + assert(intres.isInstanceOf[IntMap[_]]) + + val longmap = LongMap(1L -> 1, 2L -> 2) + val longres = longmap.map { case (a, b) => (a, b.toString) } + assert(longres.isInstanceOf[LongMap[_]]) + } + +} |