summaryrefslogtreecommitdiff
path: root/test/files/run/forvaleq.scala
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-11-02 14:34:35 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-11-02 14:34:35 +0000
commitb6778be91900b8161e705dc2598ef7af86842b0b (patch)
treed15e8ec18a37eec212f50f1ace27714d7e7d4d34 /test/files/run/forvaleq.scala
parentac6c76f26d884a94d0c9ff54f055d3f9ab750bac (diff)
downloadscala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.gz
scala-b6778be91900b8161e705dc2598ef7af86842b0b.tar.bz2
scala-b6778be91900b8161e705dc2598ef7af86842b0b.zip
Begone t1737...
Diffstat (limited to 'test/files/run/forvaleq.scala')
-rw-r--r--test/files/run/forvaleq.scala30
1 files changed, 15 insertions, 15 deletions
diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala
index 8c1824a769..2a958802b6 100644
--- a/test/files/run/forvaleq.scala
+++ b/test/files/run/forvaleq.scala
@@ -2,7 +2,7 @@
import scala.collection.immutable.Queue
import scala.{List=>L}
-
+
object Test {
// redefine some symbols to make it extra hard
class List
@@ -16,11 +16,11 @@ object Test {
case _ if (x<10) => x
case _ => firstDigit(x / 10)
}
-
-
+
+
{
- // a basic test case
-
+ // a basic test case
+
val input = L.range(0,20)
val oddFirstTimesTwo =
for {x <- input
@@ -32,7 +32,7 @@ object Test {
{
// a test case with patterns
-
+
val input = L.range(0, 20)
val oddFirstTimesTwo =
for {x <- input
@@ -43,10 +43,10 @@ object Test {
yield a + b
println(oddFirstTimesTwo)
}
-
+
{
// make sure it works on non-Ls
-
+
// val input: Queue = Queue.Empty[int].incl(L.range(0,20))
val input = L.range(0, 20).iterator
val oddFirstTimesTwo =
@@ -54,36 +54,36 @@ object Test {
xf = firstDigit(x)
if xf % 2 == 1}
yield x*2
- println(oddFirstTimesTwo.toList)
+ println(oddFirstTimesTwo.toList)
}
-
+
{
// yield the computed value
-
+
val input = L.range(0,20)
val oddFirstTimesTwo =
for {x <- input
xf = firstDigit(x)
if xf % 2 == 1}
yield xf*2
- println(oddFirstTimesTwo)
+ println(oddFirstTimesTwo)
}
{
// make sure the function is only called once
var count: Int = 0
-
+
def fdct(x: Int) = {
count += 1
firstDigit(x)
}
-
+
val input = L.range(0,20)
for {x <- input
xf = fdct(x)
if xf % 2 == 1}
yield xf
-
+
println("called " + count + " times")
}