From 635bc9c17b0d35e9cf8029cf24aee8d3594a143f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 2 Jan 2011 17:40:25 +0000 Subject: Misc uninteresting tidbits to take some weight ... Misc uninteresting tidbits to take some weight off overly large patches in progress. No review. --- test/files/run/Course-2002-05.scala | 6 +++--- test/files/run/bug978.scala | 6 +++--- test/files/run/enums.scala | 4 ++-- test/files/run/fors.scala | 42 ++++++++++++++++++------------------- 4 files changed, 29 insertions(+), 29 deletions(-) (limited to 'test') diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala index a1d71e2818..e6764b92c8 100644 --- a/test/files/run/Course-2002-05.scala +++ b/test/files/run/Course-2002-05.scala @@ -178,9 +178,9 @@ object M4 { isSafe(col, p.tail, delta + 1))); for ( - val placement <- placeQueens(row - 1); - val col <- columns; - isSafe(col, placement, 1) + placement <- placeQueens(row - 1); + col <- columns; + if isSafe(col, placement, 1) ) yield { col :: placement } diff --git a/test/files/run/bug978.scala b/test/files/run/bug978.scala index 72dfdbae0a..a2df87b0ed 100644 --- a/test/files/run/bug978.scala +++ b/test/files/run/bug978.scala @@ -13,14 +13,14 @@ object Test extends Application { // val set = new collection.jcl.HashSet[Foo] val max = 200 - for (val x <- 1 to max) + for (x <- 1 to max) set += new Foo(x) testRemove(2) testExists(2) def testRemove(m: Int) { - for (val x <- 1 to max; x % m == 0) { + for (x <- 1 to max; if x % m == 0) { val f = new Foo(x) set -= f assert(!(set contains f)) @@ -29,7 +29,7 @@ object Test extends Application { } def testExists(m: Int) { - for (val x <- 1 to max; x % m == 1) { + for (x <- 1 to max; if x % m == 1) { val f = new Foo(x) assert(set contains f, "For element: " + f + " set: " + set) } diff --git a/test/files/run/enums.scala b/test/files/run/enums.scala index fcca8d3438..6dda8cbc6e 100644 --- a/test/files/run/enums.scala +++ b/test/files/run/enums.scala @@ -29,7 +29,7 @@ object Test2 { } def run: Int = { - val it = for (val s <- ThreadState.values; s.id != 0) yield s; + val it = for (s <- ThreadState.values; if s.id != 0) yield s; it.toList.length } } @@ -41,7 +41,7 @@ object Test3 { } def run: Int = { - val it = for (val d <- Direction.values; d.toString() startsWith "N") yield d; + val it = for (d <- Direction.values; if d.toString() startsWith "N") yield d; it.toList.length } } diff --git a/test/files/run/fors.scala b/test/files/run/fors.scala index 868a05369b..2cd4cf135c 100644 --- a/test/files/run/fors.scala +++ b/test/files/run/fors.scala @@ -24,34 +24,34 @@ object Test extends Application { println("\ntestOld") // lists - for (val x <- xs) print(x + " "); println - for (val x <- xs; - x % 2 == 0) print(x + " "); println - for {val x <- xs - x % 2 == 0} print(x + " "); println + for (x <- xs) print(x + " "); println + for (x <- xs; + if x % 2 == 0) print(x + " "); println + for {x <- xs + if x % 2 == 0} print(x + " "); println var n = 0 - for (val _ <- xs) n += 1; println(n) - for (val (x, y) <- xs zip ys) print(x + " "); println - for (val p @ (x, y) <- xs zip ys) print(p._1 + " "); println + for (_ <- xs) n += 1; println(n) + for ((x, y) <- xs zip ys) print(x + " "); println + for (p @ (x, y) <- xs zip ys) print(p._1 + " "); println // iterators - for (val x <- it) print(x + " "); println - for (val x <- it; - x % 2 == 0) print(x + " "); println - for {val x <- it - x % 2 == 0} print(x + " "); println + for (x <- it) print(x + " "); println + for (x <- it; + if x % 2 == 0) print(x + " "); println + for {x <- it + if x % 2 == 0} print(x + " "); println // arrays - for (val x <- ar) print(x + " "); println - for (val x <- ar; - x.toInt > 97) print(x + " "); println - for {val x <- ar - x.toInt > 97} print(x + " "); println + for (x <- ar) print(x + " "); println + for (x <- ar; + if x.toInt > 97) print(x + " "); println + for {x <- ar + if x.toInt > 97} print(x + " "); println // sequences - for (val x <- xml.child) println(x) - for (val x <- xml.child; - x.label == "head") println(x) + for (x <- xml.child) println(x) + for (x <- xml.child; + if x.label == "head") println(x) } /////////////////// new syntax /////////////////// -- cgit v1.2.3