diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/protectedacc.scala | 2 | ||||
-rw-r--r-- | test/files/jvm/xmlstuff.scala | 2 | ||||
-rw-r--r-- | test/files/neg/for-comprehension-old.check | 25 | ||||
-rw-r--r-- | test/files/neg/for-comprehension-old.scala | 11 | ||||
-rw-r--r-- | test/files/neg/t4163.check | 4 | ||||
-rw-r--r-- | test/files/neg/t4163.scala | 2 | ||||
-rw-r--r-- | test/files/pos/bug0029.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t2413/TestScalac.scala | 2 | ||||
-rw-r--r-- | test/files/run/Course-2002-08.scala | 12 | ||||
-rw-r--r-- | test/files/run/Course-2002-13.scala | 11 | ||||
-rw-r--r-- | test/files/run/bug1192.scala | 2 | ||||
-rw-r--r-- | test/files/run/forvaleq.scala | 14 | ||||
-rw-r--r-- | test/files/run/lazy-leaks.scala | 2 | ||||
-rw-r--r-- | test/files/run/mapConserve.scala | 2 | ||||
-rw-r--r-- | test/files/run/t1939.scala | 2 |
15 files changed, 65 insertions, 30 deletions
diff --git a/test/files/jvm/protectedacc.scala b/test/files/jvm/protectedacc.scala index c3b07a0a7e..89e70b90d8 100644 --- a/test/files/jvm/protectedacc.scala +++ b/test/files/jvm/protectedacc.scala @@ -82,7 +82,7 @@ package p { Console.println("meth1(1) = " + meth1(1)); Console.println("meth1(1.0) = " + meth1(1.0)); // test accesses from closures - for (val x <- 1 until 3) + for (x <- 1 until 3) Console.println("meth2(1)(1) = " + meth2(1)("prefix: ")); Console.println("meth3 = " + meth3.getClass); diff --git a/test/files/jvm/xmlstuff.scala b/test/files/jvm/xmlstuff.scala index 08aa716352..f2ad0307b1 100644 --- a/test/files/jvm/xmlstuff.scala +++ b/test/files/jvm/xmlstuff.scala @@ -27,7 +27,7 @@ object Test { <bar value="5" gi='go'/> </foo>; - val pelems_1 = for( val x <- p \ "bar"; val y <- p \ "baz" ) yield { + val pelems_1 = for (x <- p \ "bar"; y <- p \ "baz" ) yield { Text(x.attributes("value").toString + y.attributes("bazValue").toString+ "!") }; val pelems_2 = new NodeSeq { val theSeq = List(Text("38!"),Text("58!")) }; diff --git a/test/files/neg/for-comprehension-old.check b/test/files/neg/for-comprehension-old.check new file mode 100644 index 0000000000..ec54d619b4 --- /dev/null +++ b/test/files/neg/for-comprehension-old.check @@ -0,0 +1,25 @@ +for-comprehension-old.scala:2: error: assignment in for comprehension must be preceded by `val` + for (x <- 1 to 5 ; y = x) yield x+y // fail + ^ +for-comprehension-old.scala:4: error: val in for comprehension must be followed by assignment + for (val x <- 1 to 5 ; y = x) yield x+y // fail + ^ +for-comprehension-old.scala:4: error: assignment in for comprehension must be preceded by `val` + for (val x <- 1 to 5 ; y = x) yield x+y // fail + ^ +for-comprehension-old.scala:5: error: val in for comprehension must be followed by assignment + for (val x <- 1 to 5 ; val y = x) yield x+y // fail + ^ +for-comprehension-old.scala:7: error: assignment in for comprehension must be preceded by `val` + for (z <- 1 to 2 ; x <- 1 to 5 ; y = x) yield x+y // fail + ^ +for-comprehension-old.scala:9: error: val in for comprehension must be followed by assignment + for (z <- 1 to 2 ; val x <- 1 to 5 ; y = x) yield x+y // fail + ^ +for-comprehension-old.scala:9: error: assignment in for comprehension must be preceded by `val` + for (z <- 1 to 2 ; val x <- 1 to 5 ; y = x) yield x+y // fail + ^ +for-comprehension-old.scala:10: error: val in for comprehension must be followed by assignment + for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail + ^ +8 errors found diff --git a/test/files/neg/for-comprehension-old.scala b/test/files/neg/for-comprehension-old.scala new file mode 100644 index 0000000000..476e99808e --- /dev/null +++ b/test/files/neg/for-comprehension-old.scala @@ -0,0 +1,11 @@ +class A { + for (x <- 1 to 5 ; y = x) yield x+y // fail + for (x <- 1 to 5 ; val y = x) yield x+y // ok + for (val x <- 1 to 5 ; y = x) yield x+y // fail + for (val x <- 1 to 5 ; val y = x) yield x+y // fail + + for (z <- 1 to 2 ; x <- 1 to 5 ; y = x) yield x+y // fail + for (z <- 1 to 2 ; x <- 1 to 5 ; val y = x) yield x+y // ok + for (z <- 1 to 2 ; val x <- 1 to 5 ; y = x) yield x+y // fail + for (z <- 1 to 2 ; val x <- 1 to 5 ; val y = x) yield x+y // fail +} diff --git a/test/files/neg/t4163.check b/test/files/neg/t4163.check index d275117833..e94c4fae7c 100644 --- a/test/files/neg/t4163.check +++ b/test/files/neg/t4163.check @@ -1,6 +1,6 @@ t4163.scala:4: error: '<-' expected but '=' found. - x = 3 - ^ + val x = 3 + ^ t4163.scala:5: error: illegal start of simple expression y <- 0 to 100 ^ diff --git a/test/files/neg/t4163.scala b/test/files/neg/t4163.scala index 25ce5522a4..bb4c65f18d 100644 --- a/test/files/neg/t4163.scala +++ b/test/files/neg/t4163.scala @@ -1,7 +1,7 @@ class Bug { val z = ( for { - x = 3 + val x = 3 y <- 0 to 100 } yield y ).toArray diff --git a/test/files/pos/bug0029.scala b/test/files/pos/bug0029.scala index 0af45ab62d..937b6d70c0 100644 --- a/test/files/pos/bug0029.scala +++ b/test/files/pos/bug0029.scala @@ -1,3 +1,3 @@ object Main { - def f[a]: List[List[a]] = for (val l1 <- Nil; val l2 <- Nil) yield l1 + def f[a]: List[List[a]] = for (l1 <- Nil; l2 <- Nil) yield l1 } diff --git a/test/files/pos/t2413/TestScalac.scala b/test/files/pos/t2413/TestScalac.scala index 098e852dd7..0f395e6c74 100644 --- a/test/files/pos/t2413/TestScalac.scala +++ b/test/files/pos/t2413/TestScalac.scala @@ -18,6 +18,6 @@ class Foo extends TestJava { val aVal = repeatParam("1","2","3") */ // THIS YIELDS TO CRASH - for (a <- 1 to 4 ; anotherVal = repeatParam("1","2","3")) + for (a <- 1 to 4 ; val anotherVal = repeatParam("1","2","3")) yield anotherVal } diff --git a/test/files/run/Course-2002-08.scala b/test/files/run/Course-2002-08.scala index 2e4b5111a9..2423bbc36a 100644 --- a/test/files/run/Course-2002-08.scala +++ b/test/files/run/Course-2002-08.scala @@ -135,9 +135,9 @@ object M3 { object M4 { def test = { - for (val i <- range(1, 4)) { Console.print(i + " ") }; + for (i <- range(1, 4)) { Console.print(i + " ") }; Console.println; - Console.println(for (val i <- range(1, 4)) yield i); + Console.println(for (i <- range(1, 4)) yield i); Console.println; } } @@ -561,14 +561,14 @@ class Main() extends CircuitSimulator() { val outNum = 1 << n; val in = new Wire(); - val ctrl = for (val x <- range(0,n)) yield { new Wire() }; - val out = for (val x <- range(0,outNum)) yield { new Wire() }; + val ctrl = for (x <- range(0,n)) yield { new Wire() }; + val out = for (x <- range(0,outNum)) yield { new Wire() }; demux(in, ctrl.reverse, out.reverse); probe("in", in); - for (val Pair(x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) } - for (val Pair(x,o) <- range(0,outNum) zip out) { probe("out" + x, o) } + for (Pair(x,c) <- range(0,n) zip ctrl) { probe("ctrl" + x, c) } + for (Pair(x,o) <- range(0,outNum) zip out) { probe("out" + x, o) } in.setSignal(true); run; diff --git a/test/files/run/Course-2002-13.scala b/test/files/run/Course-2002-13.scala index c016d41a90..c266af8c32 100644 --- a/test/files/run/Course-2002-13.scala +++ b/test/files/run/Course-2002-13.scala @@ -116,7 +116,7 @@ object Programs { (lhs.tyvars ::: (rhs flatMap (t => t.tyvars))).distinct; def newInstance = { var s: Subst = List(); - for (val a <- tyvars) { s = Binding(a, newVar(a)) :: s } + for (a <- tyvars) { s = Binding(a, newVar(a)) :: s } Clause(lhs map s, rhs map (t => t map s)) } override def toString() = @@ -141,9 +141,9 @@ object Programs { if (solve1(qs, s).isEmpty) Stream.cons(s, Stream.empty) else Stream.empty case q :: query1 => - for (val clause <- list2stream(clauses); - val s1 <- tryClause(clause.newInstance, q, s); - val s2 <- solve1(query1, s1)) yield s2 + for (clause <- list2stream(clauses); + s1 <- tryClause(clause.newInstance, q, s); + s2 <- solve1(query1, s1)) yield s2 } def solve1(query: List[Term], s: Subst): Stream[Subst] = { @@ -154,8 +154,7 @@ object Programs { def tryClause(c: Clause, q: Term, s: Subst): Stream[Subst] = { if (debug) Console.println("trying " + c); - for (val s1 <- option2stream(unify(q, c.lhs, s)); - val s2 <- solve1(c.rhs, s1)) yield s2; + for (s1 <- option2stream(unify(q, c.lhs, s)); s2 <- solve1(c.rhs, s1)) yield s2; } solve1(query, List()) diff --git a/test/files/run/bug1192.scala b/test/files/run/bug1192.scala index a32cbf5c98..3222bb0a37 100644 --- a/test/files/run/bug1192.scala +++ b/test/files/run/bug1192.scala @@ -1,7 +1,7 @@ object Test extends App { val v1: Array[Array[Int]] = Array(Array(1, 2), Array(3, 4)) def f[T](w: Array[Array[T]]) { - for (val r <- w) println(r.deep.toString) + for (r <- w) println(r.deep.toString) } f(v1) } diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala index 8c1824a769..40dbfd099a 100644 --- a/test/files/run/forvaleq.scala +++ b/test/files/run/forvaleq.scala @@ -24,7 +24,7 @@ object Test { val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input - xf = firstDigit(x) + val xf = firstDigit(x) if xf % 2 == 1} yield x*2 println(oddFirstTimesTwo) @@ -36,9 +36,9 @@ object Test { val input = L.range(0, 20) val oddFirstTimesTwo = for {x <- input - xf = firstDigit(x) - yf = x - firstDigit(x) / 10 - (a, b) = (xf - yf, xf + yf) + val xf = firstDigit(x) + val yf = x - firstDigit(x) / 10 + val (a, b) = (xf - yf, xf + yf) if xf % 2 == 1} yield a + b println(oddFirstTimesTwo) @@ -51,7 +51,7 @@ object Test { val input = L.range(0, 20).iterator val oddFirstTimesTwo = for {x <- input - xf = firstDigit(x) + val xf = firstDigit(x) if xf % 2 == 1} yield x*2 println(oddFirstTimesTwo.toList) @@ -63,7 +63,7 @@ object Test { val input = L.range(0,20) val oddFirstTimesTwo = for {x <- input - xf = firstDigit(x) + val xf = firstDigit(x) if xf % 2 == 1} yield xf*2 println(oddFirstTimesTwo) @@ -80,7 +80,7 @@ object Test { val input = L.range(0,20) for {x <- input - xf = fdct(x) + val xf = fdct(x) if xf % 2 == 1} yield xf diff --git a/test/files/run/lazy-leaks.scala b/test/files/run/lazy-leaks.scala index e3db55aa09..22a3770d07 100644 --- a/test/files/run/lazy-leaks.scala +++ b/test/files/run/lazy-leaks.scala @@ -9,7 +9,7 @@ object Test extends App // This test requires 4 Mb of RAM if Lazy is discarding thunks // It consumes 4 Gb of RAM if Lazy is not discarding thunks - for (val idx <- Iterator.range(0, 1024)) { + for (idx <- Iterator.range(0, 1024)) { val data = new Array[Int](1024*1024) val lz: Lazy = new Lazy(data.length) buffer += lz diff --git a/test/files/run/mapConserve.scala b/test/files/run/mapConserve.scala index a285113b11..176e38bed4 100644 --- a/test/files/run/mapConserve.scala +++ b/test/files/run/mapConserve.scala @@ -30,7 +30,7 @@ object Test { def main(args: Array[String]) { for (length <- 0 to maxListLength; bitmap <- 0 until (1 << length); - data = List.range(0, length) map { x: Int => + val data = List.range(0, length) map { x: Int => if ((bitmap & (1 << x)) != 0) BigInt(x+16) else BigInt(x) }) diff --git a/test/files/run/t1939.scala b/test/files/run/t1939.scala index 7626e8bc1a..5a36348761 100644 --- a/test/files/run/t1939.scala +++ b/test/files/run/t1939.scala @@ -25,7 +25,7 @@ object Test extends App { def f(ts: List[tType]): Unit = { - for (t <- ts; m = t.module) {} + for (t <- ts; val m = t.module) {} ts.map(t => t.module).foreach { _ => () } // ts.map(t => (t : T).module).foreach { _ => () } // runs successfully } |