diff options
author | Paul Phillips <paulp@improving.org> | 2012-09-20 14:07:01 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-09-20 14:07:01 -0700 |
commit | cc6f5f97f8a4290391a69ac96f134cb3e8ed4381 (patch) | |
tree | f2aa4f428719b7a8c8afd9959161f43b26a2c06d /test/files/run/t4835.scala | |
parent | c8e6f8e64c4d9967cee41486cc2e324da0262976 (diff) | |
parent | 08de8afde6c99fb1739eb9730e6fce4eef54f296 (diff) | |
download | scala-cc6f5f97f8a4290391a69ac96f134cb3e8ed4381.tar.gz scala-cc6f5f97f8a4290391a69ac96f134cb3e8ed4381.tar.bz2 scala-cc6f5f97f8a4290391a69ac96f134cb3e8ed4381.zip |
Merge remote-tracking branch 'paulp/topic/gitattributes' into 2.10.x
Diffstat (limited to 'test/files/run/t4835.scala')
-rw-r--r-- | test/files/run/t4835.scala | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/test/files/run/t4835.scala b/test/files/run/t4835.scala index 50d161be40..c964e42e7c 100644 --- a/test/files/run/t4835.scala +++ b/test/files/run/t4835.scala @@ -1,38 +1,38 @@ -/*
- * Test case for SI-4835. This tests confirm that the fix
- * doesn't break laziness. To test memory consumption,
- * I need to confirm that OutOfMemoryError doesn't occur.
- * I could create such tests. However, such tests consume
- * too much time and memory.
- */
-object Test {
- private final val INFINITE = -1
- def testStreamIterator(num: Int, stream: Stream[Int]): Unit = {
- val iter = stream.iterator
- print(num)
- // if num == -1, then steram is infinite sequence
- if (num == INFINITE) {
- for(i <- 0 until 10) {
- print(" " + iter.next())
- }
- } else {
- while(iter.hasNext) {
- print(" " + iter.next())
- }
- }
- println()
- }
-
- def main(args: Array[String]): Unit = {
- import Stream.{from, cons, empty}
- testStreamIterator(INFINITE, from(0))
- testStreamIterator(INFINITE, from(0).filter(_ % 2 == 1))
- testStreamIterator(1, Stream(1))
- testStreamIterator(2, Stream(1, 2))
- //Stream with side effect
- testStreamIterator(2, cons(1, cons({ print(" A"); 2}, empty)))
- testStreamIterator(3, Stream(1, 2, 3))
- //Stream with side effect
- testStreamIterator(3, cons(1, cons({ print(" A"); 2}, cons({ print(" B"); 3}, Stream.empty))))
- }
-}
+/* + * Test case for SI-4835. This tests confirm that the fix + * doesn't break laziness. To test memory consumption, + * I need to confirm that OutOfMemoryError doesn't occur. + * I could create such tests. However, such tests consume + * too much time and memory. + */ +object Test { + private final val INFINITE = -1 + def testStreamIterator(num: Int, stream: Stream[Int]): Unit = { + val iter = stream.iterator + print(num) + // if num == -1, then steram is infinite sequence + if (num == INFINITE) { + for(i <- 0 until 10) { + print(" " + iter.next()) + } + } else { + while(iter.hasNext) { + print(" " + iter.next()) + } + } + println() + } + + def main(args: Array[String]): Unit = { + import Stream.{from, cons, empty} + testStreamIterator(INFINITE, from(0)) + testStreamIterator(INFINITE, from(0).filter(_ % 2 == 1)) + testStreamIterator(1, Stream(1)) + testStreamIterator(2, Stream(1, 2)) + //Stream with side effect + testStreamIterator(2, cons(1, cons({ print(" A"); 2}, empty))) + testStreamIterator(3, Stream(1, 2, 3)) + //Stream with side effect + testStreamIterator(3, cons(1, cons({ print(" A"); 2}, cons({ print(" B"); 3}, Stream.empty)))) + } +} |