diff options
author | Donna Malayeri <lindydonna@gmail.com> | 2009-11-23 15:16:25 +0000 |
---|---|---|
committer | Donna Malayeri <lindydonna@gmail.com> | 2009-11-23 15:16:25 +0000 |
commit | 3045b84c8c36d25a3936a114e77a2ae1488ec313 (patch) | |
tree | 4ae98861ce772d8bec8cb5dc974bee47cce8d904 /test/files/run/bug2552.scala | |
parent | 85befd69274d53fb2a4e7b9cdbd8fed8f3171e42 (diff) | |
download | scala-3045b84c8c36d25a3936a114e77a2ae1488ec313.tar.gz scala-3045b84c8c36d25a3936a114e77a2ae1488ec313.tar.bz2 scala-3045b84c8c36d25a3936a114e77a2ae1488ec313.zip |
Closed #2552.
Diffstat (limited to 'test/files/run/bug2552.scala')
-rw-r--r-- | test/files/run/bug2552.scala | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/test/files/run/bug2552.scala b/test/files/run/bug2552.scala new file mode 100644 index 0000000000..911d98decc --- /dev/null +++ b/test/files/run/bug2552.scala @@ -0,0 +1,34 @@ +object Test extends Application { + def testTakeWhile = { + val numbers = Iterator.range(0, 50) + val zeroTo9 = numbers.takeWhile(x => { println("p(" + x + ")"); x < 10 } ) + + zeroTo9.foreach(println _) + + val zeroTo1 = Iterator.range(0, 20).takeWhile(x => { println("p(" + x + ")"); x < 2 } ) + + println(zeroTo1.hasNext) + println(zeroTo1.hasNext) + println(zeroTo1.next) + println(zeroTo1.hasNext) + println(zeroTo1.next) + println(zeroTo1.hasNext) + println(zeroTo1.hasNext) + } + + def testFilter = { + val predicate = (x: Int) => { println("p(" + x + ")"); x % 2 == 0 } + + val evens = Iterator.range(0, 10).filter(predicate) + + println(evens.hasNext) + println(evens.hasNext) + println(evens.next) + + evens.foreach(println _) + } + + testTakeWhile + testFilter +} + |