diff options
Diffstat (limited to 'test/files/run/forvaleq.scala')
-rw-r--r-- | test/files/run/forvaleq.scala | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala index 47bc545d47..a30c659ecc 100644 --- a/test/files/run/forvaleq.scala +++ b/test/files/run/forvaleq.scala @@ -7,7 +7,6 @@ import scala.{List=>L} object Test { // redefine some symbols to make it extra hard class List - class Pair class Tuple2 def List[A](as:A*) = 5 @@ -33,6 +32,20 @@ object Test { } { + // a test case with patterns + + val input = L.range(0,20) + val oddFirstTimesTwo = + for{val x <- input + val xf = firstDigit(x) + val yf = x - firstDigit(x) / 10 + val Pair(a, b) = Pair(xf - yf, xf + yf) + xf % 2 == 1} + yield a + b + Console.println(oddFirstTimesTwo) + } + + { // make sure it works on non-Ls // val input: Queue = Queue.Empty[int].incl(L.range(0,20)) @@ -42,7 +55,7 @@ object Test { val xf = firstDigit(x) xf % 2 == 1} yield x*2 - Console.println(oddFirstTimesTwo.toL) + Console.println(oddFirstTimesTwo.toList) } { |