From a4baf28d203959457d82762e27ffbb7104dc0a07 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 10 Jun 2008 08:46:06 +0000 Subject: int -> Int, etc.. --- test/files/jvm5/bug680.scala | 2 +- test/files/pos/bug267.scala | 26 +++--- test/files/pos/bug361.scala | 8 +- test/files/pos/bug767.scala | 24 +++--- test/files/pos/bug927.scala | 4 +- test/files/pos/code.scala | 2 +- test/files/pos/constfold.scala | 2 +- test/files/pos/gosh.scala | 62 +++++++------- test/files/pos/mixins.scala | 14 +-- test/files/pos/traits.scala | 16 ++-- test/files/pos/unapply.scala | 10 +-- test/files/run/Course-2002-05.scala | 68 +++++++-------- test/files/run/Course-2002-07.scala | 165 ++++++++++++++++++------------------ test/files/run/bug216.scala | 2 +- test/files/run/forvaleq.scala | 66 +++++++-------- test/files/run/literals.check | 12 +-- test/files/run/literals.scala | 38 ++++----- test/files/run/retsynch.scala | 4 +- 18 files changed, 262 insertions(+), 263 deletions(-) (limited to 'test') diff --git a/test/files/jvm5/bug680.scala b/test/files/jvm5/bug680.scala index 31c359ed8c..b0b0c9f7c0 100644 --- a/test/files/jvm5/bug680.scala +++ b/test/files/jvm5/bug680.scala @@ -1,5 +1,5 @@ object Test { - def main(args:Array[String]): unit = { + def main(args:Array[String]) { val sb = new java.lang.StringBuilder() // use Java 1.5 sb.setLength(0) } diff --git a/test/files/pos/bug267.scala b/test/files/pos/bug267.scala index 92282f77a2..d7eae9b8d6 100644 --- a/test/files/pos/bug267.scala +++ b/test/files/pos/bug267.scala @@ -1,4 +1,4 @@ -package expAbstractData; +package expAbstractData /** A base class consisting of * - a root trait (i.e. abstract class) `Exp' with an `eval' function @@ -6,29 +6,29 @@ package expAbstractData; * - a concrete instance class `Num' of `Exp' for numeric literals */ trait Base { - type exp <: Exp; + type exp <: Exp trait Exp { - def eval: int + def eval: Int } - class Num(v: int) extends Exp { self: exp => - val value = v; + class Num(v: Int) extends Exp { self: exp => + val value = v def eval = value } } object testBase extends Application with Base { - type exp = Exp; + type exp = Exp val term = new Num(2); - Console.println(term.eval); + Console.println(term.eval) } /** Data extension: An extension of `Base' with `Plus' expressions */ trait BasePlus extends Base { class Plus(l: exp, r: exp) extends Exp { self: exp => - val left = l; - val right = r; + val left = l + val right = r def eval = left.eval + right.eval } } @@ -36,13 +36,13 @@ trait BasePlus extends Base { /** Operation extension: An extension of `Base' with 'show' methods. */ trait Show extends Base { - type exp <: Exp1; + type exp <: Exp1 trait Exp1 extends Exp { - def show: String; + def show: String } - class Num1(v: int) extends Num(v) with Exp1 { self: exp with Num1 => - def show = value.toString(); + class Num1(v: Int) extends Num(v) with Exp1 { self: exp with Num1 => + def show = value.toString() } } diff --git a/test/files/pos/bug361.scala b/test/files/pos/bug361.scala index 1e490c3812..f44fb32d47 100644 --- a/test/files/pos/bug361.scala +++ b/test/files/pos/bug361.scala @@ -1,18 +1,18 @@ // $Id$ -class Bug361Global extends Bug361Trees; +class Bug361Global extends Bug361Trees abstract class Bug361Trees { self: Bug361Global => abstract class Tree { - var pos: int = 0; + var pos: Int = 0 } object posAssigner { - def atPos[T <: Tree](pos: int, tree: T): T = { + def atPos[T <: Tree](pos: Int, tree: T): T = { tree.pos = pos; tree } } - def atPos[T <: Tree](pos: int)(tree: T): T = posAssigner.atPos(pos, tree); + def atPos[T <: Tree](pos: Int)(tree: T): T = posAssigner.atPos(pos, tree) } diff --git a/test/files/pos/bug767.scala b/test/files/pos/bug767.scala index 05dd97f556..0c4067f022 100644 --- a/test/files/pos/bug767.scala +++ b/test/files/pos/bug767.scala @@ -1,18 +1,18 @@ abstract class AbsCell { - type T = Node - val init: T - private var value: T = init - def get: T = value - def set (x: T): unit = { value = x } + type T = Node + val init: T + private var value: T = init + def get: T = value + def set (x: T) { value = x } - class Node { - val foo = 1 - } + class Node { + val foo = 1 + } } object inner { - def main(args: Array[String]): Unit = { - val cell = new AbsCell { val init = new Node() } - cell.set(new cell.type#T()) // nullpointer exception - } + def main(args: Array[String]) { + val cell = new AbsCell { val init = new Node() } + cell.set(new cell.type#T()) // nullpointer exception + } } diff --git a/test/files/pos/bug927.scala b/test/files/pos/bug927.scala index 6ab932e23b..1a906cd9bc 100644 --- a/test/files/pos/bug927.scala +++ b/test/files/pos/bug927.scala @@ -1,11 +1,11 @@ object Test { - def sum(stream: Stream[int]): int = + def sum(stream: Stream[Int]): Int = stream match { case Stream.empty => 0 case Stream.cons(hd, tl) => hd + sum(tl) } - val str: Stream[int] = Stream.fromIterator(List(1,2,3).elements) + val str: Stream[Int] = Stream.fromIterator(List(1,2,3).elements) assert(sum(str) == 6) } diff --git a/test/files/pos/code.scala b/test/files/pos/code.scala index 421b0fb5bf..110e01c619 100644 --- a/test/files/pos/code.scala +++ b/test/files/pos/code.scala @@ -1,3 +1,3 @@ class Test { - val fun: reflect.Code[int => int] = x => x + 1; + val fun: reflect.Code[Int => Int] = x => x + 1; } diff --git a/test/files/pos/constfold.scala b/test/files/pos/constfold.scala index 0082b8cd5f..d42ada76d3 100644 --- a/test/files/pos/constfold.scala +++ b/test/files/pos/constfold.scala @@ -1,6 +1,6 @@ object A { val x = 2; - val y = x.asInstanceOf[byte]; + val y = x.asInstanceOf[Byte]; val z = 1.0 / 2; val s = "z is " + z; } diff --git a/test/files/pos/gosh.scala b/test/files/pos/gosh.scala index c4cd3df80b..183ce9df1d 100644 --- a/test/files/pos/gosh.scala +++ b/test/files/pos/gosh.scala @@ -1,44 +1,44 @@ object ShapeTest extends Application { - class Point(x : int, y : int) { - override def toString() = "[" + x + "," + y + "]" - } + class Point(x: Int, y: Int) { + override def toString() = "[" + x + "," + y + "]" + } - abstract class Shape { - def draw() : unit - } + abstract class Shape { + def draw(): Unit + } - class Line(s : Point, e : Point) extends Shape { - def draw() : unit = { Console.println("draw line " + s + "," + e) } - } + class Line(s: Point, e: Point) extends Shape { + def draw() { Console.println("draw line " + s + "," + e) } + } - abstract class Foo { - type T <: Object + abstract class Foo { + type T <: Object - def show(o : T) : unit - def print() : unit = {Console.println("in Foo")} - } + def show(o: T): Unit + def print() { Console.println("in Foo") } + } - abstract class ShapeFoo extends Foo { - type T <: Shape - def show(o : T) : unit = { o.draw() } - override def print() : unit = {Console.println("in ShapeFoo")} - } + abstract class ShapeFoo extends Foo { + type T <: Shape + def show(o: T) { o.draw() } + override def print() { Console.println("in ShapeFoo") } + } - class LineFoo extends ShapeFoo { - type T = Line - override def print() : unit = {Console.println("in LineFoo")} - } + class LineFoo extends ShapeFoo { + type T = Line + override def print() { Console.println("in LineFoo") } + } - val p1 = new Point(1,4) - val p2 = new Point(12, 28) + val p1 = new Point(1,4) + val p2 = new Point(12, 28) - val l1 = new Line(p1, p2) + val l1 = new Line(p1, p2) - val l = new ShapeFoo{ // ** // - type T = Line // ** // - override def print() : unit = {Console.println("in LineFoo")} // ** // - } - l.show(l1) // ** // + val l = new ShapeFoo { // ** // + type T = Line // ** // + override def print() { Console.println("in LineFoo") } // ** // + } + l.show(l1) // ** // } diff --git a/test/files/pos/mixins.scala b/test/files/pos/mixins.scala index 2b403a25e8..846d6a41bc 100644 --- a/test/files/pos/mixins.scala +++ b/test/files/pos/mixins.scala @@ -1,21 +1,21 @@ -package mixins; +package mixins abstract class Super { - def foo: int; + def foo: Int } trait Mixin extends Super { - abstract override def foo = super.foo; + abstract override def foo = super.foo } trait MixinSub extends Super with Mixin { - abstract override def foo: int = super.foo; + abstract override def foo: Int = super.foo } trait MixinSubSub extends MixinSub { - abstract override def foo = super.foo; + abstract override def foo = super.foo } class Sub extends Super { - def foo: int = 1 + def foo: Int = 1 } class Base extends Sub with MixinSubSub { - override def foo = super.foo; + override def foo = super.foo } trait Mixin1 extends Sub with MixinSubSub {} class Base1 extends Mixin1 {} diff --git a/test/files/pos/traits.scala b/test/files/pos/traits.scala index 1418757442..8dcd9c0b5f 100644 --- a/test/files/pos/traits.scala +++ b/test/files/pos/traits.scala @@ -1,17 +1,17 @@ object Test { - type Color = int; + type Color = Int trait Shape { override def equals(other: Any) = true } trait Bordered extends Shape { - val thickness: int; + val thickness: Int override def equals(other: Any) = other match { case that: Bordered => this.thickness == that.thickness case _ => false } } trait Colored extends Shape { - val color: Color; + val color: Color override def equals(other: Any) = other match { case that: Colored => this.color == that.color case _ => false @@ -28,13 +28,13 @@ object Test { } val bcs1 = new BorderedColoredShape { - val thickness = 1; - val color = 0; + val thickness = 1 + val color = 0 } val bcs2 = new BorderedColoredShape { - val thickness = 2; - val color = 0; + val thickness = 2 + val color = 0 } - Console.println(bcs1 == bcs1); + Console.println(bcs1 == bcs1) Console.println(bcs1 == bcs2) } diff --git a/test/files/pos/unapply.scala b/test/files/pos/unapply.scala index 49f7181350..6651e64362 100644 --- a/test/files/pos/unapply.scala +++ b/test/files/pos/unapply.scala @@ -1,6 +1,6 @@ object Test { val xs = List(1) - val f: int = { + val f: Int = { xs match { case List(x) => x } @@ -9,16 +9,16 @@ object Test { // the following comes from ticket #230 trait Foo { - def name : String - def unapply(x : String) : Option[Unit] = { - if(x == name) Some(()) else None + def name: String + def unapply(x: String): Option[Unit] = { + if (x == name) Some(()) else None } } object Bar extends Foo { def name = "bar" } object Baz extends Foo { def name = "baz" } object Test_ { - def matcher(s : String) = s match { + def matcher(s: String) = s match { case Bar(x) => println("bar") case Baz(x) => println("baz") // ^ diff --git a/test/files/run/Course-2002-05.scala b/test/files/run/Course-2002-05.scala index abf9978ac6..917084fc97 100644 --- a/test/files/run/Course-2002-05.scala +++ b/test/files/run/Course-2002-05.scala @@ -4,7 +4,7 @@ // $Id$ object M0 { - def partition[a](xs: List[a], pred: a => boolean): Pair[List[a], List[a]] = { + def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = { if (xs.isEmpty) Pair(List(),List()) else { @@ -16,7 +16,7 @@ object M0 { } } - def quicksort[a] (less : (a,a) => boolean) (xs : List[a]) : List[a] = { + def quicksort[a] (less : (a,a) => Boolean) (xs : List[a]) : List[a] = { if (xs.isEmpty) xs else { @@ -27,22 +27,22 @@ object M0 { } def test = { - Console.println(partition[int](List(1,2,3,4,5,6,7,8), (x => x < 0))); - Console.println(partition[int](List(1,2,3,4,5,6,7,8), (x => x < 5))); - Console.println(partition[int](List(1,2,3,4,5,6,7,8), (x => x < 9))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 0))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 5))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 9))); Console.println; - Console.println(partition[int](List(8,7,6,5,4,3,2,1), (x => x < 0))); - Console.println(partition[int](List(8,7,6,5,4,3,2,1), (x => x < 5))); - Console.println(partition[int](List(8,7,6,5,4,3,2,1), (x => x < 9))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 0))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 5))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 9))); Console.println; - Console.println(partition[int](List(7,2,1,5,4,3,8,6), (x => x < 0))); - Console.println(partition[int](List(7,2,1,5,4,3,8,6), (x => x < 5))); - Console.println(partition[int](List(7,2,1,5,4,3,8,6), (x => x < 9))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 0))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 5))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 9))); Console.println; - Console.println(quicksort[int]((x,y) => x < y)(List(7,2,1,5,4,3,8,6))); + Console.println(quicksort[Int]((x,y) => x < y)(List(7,2,1,5,4,3,8,6))); Console.println; } } @@ -50,13 +50,13 @@ object M0 { //############################################################################ object M1 { - def partition[a](xs: List[a], pred: a => boolean): Pair[List[a], List[a]] = { + def partition[a](xs: List[a], pred: a => Boolean): Pair[List[a], List[a]] = { xs.foldRight[Pair[List[a], List[a]]](Pair(List(), List())) { (x, p) => if (pred (x)) Pair(x :: p._1, p._2) else Pair(p._1, x :: p._2) } } - def quicksort[a] (less : (a,a) => boolean) (xs : List[a]) : List[a] = { + def quicksort[a] (less : (a,a) => Boolean) (xs : List[a]) : List[a] = { if (xs.isEmpty) xs else { @@ -67,22 +67,22 @@ object M1 { } def test = { - Console.println(partition[int](List(1,2,3,4,5,6,7,8), (x => x < 0))); - Console.println(partition[int](List(1,2,3,4,5,6,7,8), (x => x < 5))); - Console.println(partition[int](List(1,2,3,4,5,6,7,8), (x => x < 9))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 0))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 5))); + Console.println(partition[Int](List(1,2,3,4,5,6,7,8), (x => x < 9))); Console.println; - Console.println(partition[int](List(8,7,6,5,4,3,2,1), (x => x < 0))); - Console.println(partition[int](List(8,7,6,5,4,3,2,1), (x => x < 5))); - Console.println(partition[int](List(8,7,6,5,4,3,2,1), (x => x < 9))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 0))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 5))); + Console.println(partition[Int](List(8,7,6,5,4,3,2,1), (x => x < 9))); Console.println; - Console.println(partition[int](List(7,2,1,5,4,3,8,6), (x => x < 0))); - Console.println(partition[int](List(7,2,1,5,4,3,8,6), (x => x < 5))); - Console.println(partition[int](List(7,2,1,5,4,3,8,6), (x => x < 9))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 0))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 5))); + Console.println(partition[Int](List(7,2,1,5,4,3,8,6), (x => x < 9))); Console.println; - Console.println(quicksort[int]((x,y) => x < y)(List(7,2,1,5,4,3,8,6))); + Console.println(quicksort[Int]((x,y) => x < y)(List(7,2,1,5,4,3,8,6))); Console.println; } } @@ -91,7 +91,7 @@ object M1 { object M2 { - def powerset[a] (s : List[a]) : List[List[a]] = { + def powerset[a] (s: List[a]): List[List[a]] = { if (s.isEmpty) List(List()) else { @@ -115,20 +115,20 @@ object M2 { object M3 { - def abs(x: int) = if (x < 0) 0 - x else x; + def abs(x: Int) = if (x < 0) 0 - x else x; def range(lo: Int, hi: Int): List[Int] = if (lo > hi) List() else lo :: range(lo + 1, hi); - type Placement = List[Pair[int,int]]; + type Placement = List[(Int, Int)]; - def queens(n: int): List[Placement] = { - def placeQueens(row: int): List[Placement] = { + def queens(n: Int): List[Placement] = { + def placeQueens(row: Int): List[Placement] = { if (row == 0) List(List()) else { - def isSafe(column: int, placement: Placement): boolean = + def isSafe(column: Int, placement: Placement): Boolean = placement forall { pos => (pos._2 != column && abs(pos._2 - column) != row - pos._1) @@ -145,7 +145,7 @@ object M3 { placeQueens(n) } - def test = { + def test { Console.println("queens(1) = " + queens(1)); Console.println("queens(2) = " + queens(2)); Console.println("queens(3) = " + queens(3)); @@ -158,7 +158,7 @@ object M3 { object M4 { - def abs(x: int) = if (x < 0) 0 - x else x; + def abs(x: Int) = if (x < 0) 0 - x else x; def range(lo: Int, hi: Int): List[Int] = if (lo > hi) List() @@ -190,7 +190,7 @@ object M4 { placeQueens(n); } - def test = { + def test { Console.println("queens(1) = " + queens(1)); Console.println("queens(2) = " + queens(2)); Console.println("queens(3) = " + queens(3)); @@ -202,7 +202,7 @@ object M4 { //############################################################################ object Test { - def main(args: Array[String]): unit = { + def main(args: Array[String]) { M0.test; M1.test; M2.test; diff --git a/test/files/run/Course-2002-07.scala b/test/files/run/Course-2002-07.scala index b084a35e73..d33e269805 100644 --- a/test/files/run/Course-2002-07.scala +++ b/test/files/run/Course-2002-07.scala @@ -6,45 +6,45 @@ object M0 { trait Expr { - def isNumber: boolean; - def isSum: boolean; - def numValue: int; + def isNumber: Boolean; + def isSum: Boolean; + def numValue: Int; def leftOp: Expr; def rightOp: Expr; } - class Number(n: int) extends Expr { - def isNumber: boolean = true; - def isSum: boolean = false; - def numValue: int = n; + class Number(n: Int) extends Expr { + def isNumber: Boolean = true; + def isSum: Boolean = false; + def numValue: Int = n; def leftOp: Expr = error("Number.leftOp"); def rightOp: Expr = error("Number.rightOp"); } class Sum(e1: Expr, e2: Expr) extends Expr { - def isNumber: boolean = false; - def isSum: boolean = true; - def numValue: int = error("Sum.numValue"); + def isNumber: Boolean = false; + def isSum: Boolean = true; + def numValue: Int = error("Sum.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } class Prod(e1: Expr, e2: Expr) extends Expr { - def isNumber: boolean = false; - def isSum: boolean = false; - def numValue: int = error("Prod.numValue"); + def isNumber: Boolean = false; + def isSum: Boolean = false; + def numValue: Int = error("Prod.numValue"); def leftOp: Expr = e1; def rightOp: Expr = e2; } class Var(x: String) extends Expr { - def isNumber: boolean = false; - def isSum: boolean = false; - def numValue: int = error("Var.numValue"); + def isNumber: Boolean = false; + def isSum: Boolean = false; + def numValue: Int = error("Var.numValue"); def leftOp: Expr = error("Var.leftOp"); def rightOp: Expr = error("Var.rightOp"); } - def eval(e: Expr): int = { + def eval(e: Expr): Int = { if (e.isNumber) e.numValue else if (e.isSum) eval(e.leftOp) + eval(e.rightOp) else error("unknown expression") @@ -69,13 +69,13 @@ object M0 { object M1 { trait Expr { - def eval: int; + def eval: Int; } - class Number(n: int) extends Expr { - def eval: int = n; + class Number(n: Int) extends Expr { + def eval: Int = n; } class Sum(e1: Expr, e2: Expr) extends Expr { - def eval: int = e1.eval + e2.eval; + def eval: Int = e1.eval + e2.eval; } def test = { @@ -96,10 +96,10 @@ object M1 { object M2 { trait Expr; - case class Number(n: int) extends Expr; + case class Number(n: Int) extends Expr; case class Sum(e1: Expr, e2: Expr) extends Expr; - def eval(e: Expr): int = e match { + def eval(e: Expr): Int = e match { case Number(n) => n case Sum(e1, e2) => eval(e1) + eval(e2) } @@ -120,12 +120,12 @@ object M2 { object M3 { trait Expr { - def eval: int = this match { + def eval: Int = this match { case Number(n) => n case Sum(e1, e2) => e1.eval + e2.eval } } - case class Number(n: int) extends Expr; + case class Number(n: Int) extends Expr; case class Sum(e1: Expr, e2: Expr) extends Expr; def test = { @@ -160,18 +160,18 @@ object M4 { test_concat(List(List(),List(),List())); test_concat(List(List(1,2,3,4,5,6))); - test_concat(List(List(1,2,3,4,5,6),List[int]())); // !!! [int] + test_concat(List(List(1,2,3,4,5,6),List[Int]())); // !!! [int] test_concat(List(List(1,2,3),List(4,5,6))); - test_concat(List(List[int](),List(1,2,3,4,5,6))); // !!! [int] - test_concat(List(List(1,2,3,4,5,6),List[int](),List[int]())); // !!! [int] - test_concat(List(List(1,2,3,4,5),List(6),List[int]())); // !!! [int] - test_concat(List(List(1,2,3),List(4,5,6),List[int]())); // !!! [int] - test_concat(List(List(1),List(2,3,4,5,6),List[int]())); // !!! [int] - test_concat(List(List[int](),List(1,2,3,4,5,6),List[int]())); // !!! [int] - test_concat(List(List[int](),List(1,2,3,4,5),List(6))); // !!! [int] - test_concat(List(List[int](),List(1,2,3),List(4,5,6))); // !!! [int] - test_concat(List(List[int](),List(1),List(2,3,4,5,6))); // !!! [int] - test_concat(List(List[int](),List[int](),List(1,2,3,4,5,6))); // !!! [int] + test_concat(List(List[Int](),List(1,2,3,4,5,6))); // !!! [int] + test_concat(List(List(1,2,3,4,5,6),List[Int](),List[Int]())); // !!! [int] + test_concat(List(List(1,2,3,4,5),List(6),List[Int]())); // !!! [int] + test_concat(List(List(1,2,3),List(4,5,6),List[Int]())); // !!! [int] + test_concat(List(List(1),List(2,3,4,5,6),List[Int]())); // !!! [int] + test_concat(List(List[Int](),List(1,2,3,4,5,6),List[Int]())); // !!! [int] + test_concat(List(List[Int](),List(1,2,3,4,5),List(6))); // !!! [int] + test_concat(List(List[Int](),List(1,2,3),List(4,5,6))); // !!! [int] + test_concat(List(List[Int](),List(1),List(2,3,4,5,6))); // !!! [int] + test_concat(List(List[Int](),List[Int](),List(1,2,3,4,5,6))); // !!! [int] test_concat(List(List(1,2),List(3,4),List(5,6))); Console.println; } @@ -259,7 +259,6 @@ object M7 { Console.println(heads(xss).toString + " = heads(" + xss + ")"); // !!! .toString } - def test = { test_heads(List()); test_heads(List(List())); @@ -267,21 +266,21 @@ object M7 { test_heads(List(List(),List(),List())); test_heads(List(List(1,2,3,4,5,6))); - test_heads(List(List(1,2,3,4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3,4,5,6))); // !!! [int] - test_heads(List(List(1,2,3,4,5,6),List[int](),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3,4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List[int](),List(1,2,3,4,5,6))); // !!! [int] + test_heads(List(List(1,2,3,4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3,4,5,6))); // !!! [int] + test_heads(List(List(1,2,3,4,5,6),List[Int](),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3,4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List[Int](),List(1,2,3,4,5,6))); // !!! [int] - test_heads(List(List(1),List(2,3,4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1),List(2,3,4,5,6))); // !!! [int] + test_heads(List(List(1),List(2,3,4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1),List(2,3,4,5,6))); // !!! [int] test_heads(List(List(1,2,3),List(4,5,6))); - test_heads(List(List(1,2,3),List(4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3),List(4,5,6))); // !!! [int] + test_heads(List(List(1,2,3),List(4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3),List(4,5,6))); // !!! [int] - test_heads(List(List(1,2,3,4,5),List(6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3,4,5),List(6))); // !!! [int] + test_heads(List(List(1,2,3,4,5),List(6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3,4,5),List(6))); // !!! [int] test_heads(List(List(1,2),List(3,4),List(5,6))); @@ -313,21 +312,21 @@ object M8 { test_heads(List(List(),List(),List())); test_heads(List(List(1,2,3,4,5,6))); - test_heads(List(List(1,2,3,4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3,4,5,6))); // !!! [int] - test_heads(List(List(1,2,3,4,5,6),List[int](),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3,4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List[int](),List(1,2,3,4,5,6))); // !!! [int] + test_heads(List(List(1,2,3,4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3,4,5,6))); // !!! [int] + test_heads(List(List(1,2,3,4,5,6),List[Int](),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3,4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List[Int](),List(1,2,3,4,5,6))); // !!! [int] - test_heads(List(List(1),List(2,3,4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1),List(2,3,4,5,6))); // !!! [int] + test_heads(List(List(1),List(2,3,4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1),List(2,3,4,5,6))); // !!! [int] test_heads(List(List(1,2,3),List(4,5,6))); - test_heads(List(List(1,2,3),List(4,5,6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3),List(4,5,6))); // !!! + test_heads(List(List(1,2,3),List(4,5,6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3),List(4,5,6))); // !!! - test_heads(List(List(1,2,3,4,5),List(6),List[int]())); // !!! [int] - test_heads(List(List[int](),List(1,2,3,4,5),List(6))); // !!! [int] + test_heads(List(List(1,2,3,4,5),List(6),List[Int]())); // !!! [int] + test_heads(List(List[Int](),List(1,2,3,4,5),List(6))); // !!! [int] test_heads(List(List(1,2),List(3,4),List(5,6))); @@ -348,7 +347,7 @@ object M9 { case Prod(e1, e2) => Sum(Prod(e1, e2 derive v), Prod(e2, e1 derive v)) } } - case class Number(x: int) extends Expr { + case class Number(x: Int) extends Expr { override def toString = "Number(" + x + ")"; // !!! remove ! } case class Var(name: String) extends Expr { @@ -391,7 +390,7 @@ object MA { case Prod(e1, e2) => e1 * (e2 derive v) + e2 * (e1 derive v) } } - case class Number(x: int) extends Expr { + case class Number(x: Int) extends Expr { override def toString = x.toString } case class Var(name: String) extends Expr { @@ -410,15 +409,15 @@ object MA { } } - def eval(e: Expr): int = e match { + def eval(e: Expr): Int = e match { case Number(n) => n case Var(_) => error("cannot evaluate variable") case Sum(e1, e2) => eval(e1) + eval(e2) case Prod(e1, e2) => eval(e1) * eval(e2) } - def evalvars(xs: List[Pair[String,int]]): Expr => Int = { - def loop(e: Expr): int = e match { + def evalvars(xs: List[(String,Int)]): Expr => Int = { + def loop(e: Expr): Int = e match { case Number(n) => n case Var(name) => lookup(xs,name) case Sum(e1, e2) => loop(e1) + loop(e2) @@ -451,10 +450,10 @@ object MA { object Utils { - private def power0(x: int, y: int): int = + private def power0(x: Int, y: Int): Int = if (y == 1) x else if (y % 2 == 0) power0(x*x,y/2) else x*power0(x, y-1); - def power(x: int, y: int): int = Pair(x,y) match { + def power(x: Int, y: Int): Int = (x,y) match { case Pair(0,0) => error("power(0,0)") case Pair(0,_) => 0 case Pair(1,_) => 1 @@ -464,13 +463,13 @@ object Utils { case Pair(_,_) => if (y < 0) 1/power0(x,y) else power0(x,y) } - def lookup(entries: List[Pair[String,int]], key: String):int = entries match{ + def lookup(entries: List[(String,Int)], key: String): Int = entries match { case List() => error("no value for " + key) case Pair(k,v) :: _ if (k == key) => v case _ :: rest => lookup(rest, key) } - def compare(xs: List[String], ys: List[String]): int = Pair(xs,ys) match{ + def compare(xs: List[String], ys: List[String]): Int = (xs, ys) match { case Pair(List(), List()) => 0 case Pair(List(), _ ) => -1 case Pair(_ , List()) => +1 @@ -489,7 +488,7 @@ object MB { trait Expr { - private def count: int = this match { + private def count: Int = this match { case Lit(n) => n case Mul(Lit(n),_) => n case _ => 1 @@ -508,9 +507,9 @@ object MB { case _ => List() } - private def +< (that: Expr): boolean = (this + 0 case Pair(_ , Add(_,_)) => 0 case Pair(_ , _ ) => compare(this.vars,that.vars) @@ -528,9 +527,9 @@ object MB { } } else that + this; - private def *< (that: Expr): boolean = (this * 0 case Pair(_ , Mul(_,_)) => 0 case Pair(Add(_,_), Add(_,_)) => 0 @@ -558,7 +557,7 @@ object MB { case Pair(_ , _ ) => Mul(this,that) } else that * this; - def ^ (that: int): Expr = Pair(this,that) match { + def ^ (that: Int): Expr = (this,that) match { case Pair(_ ,1) => this case Pair(Lit(i) ,n) => Lit(power(i,n)) case Pair(Var(_) ,n) => Pow(this,n) @@ -575,7 +574,7 @@ object MB { case Pow(e1, i2) => Lit(i2) * (e1 derive v) * (e1 ^ (i2 - 1)) } - def evaluate(vars: List[Pair[String,int]]): int = this match { + def evaluate(vars: List[(String,Int)]): Int = this match { case Lit(cst) => cst case Var (name) => lookup(vars, name) case Add (l, r) => l.evaluate(vars) + r.evaluate(vars) @@ -583,7 +582,7 @@ object MB { case Pow(l, r) => power(l.evaluate(vars), r) } - def equ(that: Expr): boolean = Pair(this,that) match { + def equ(that: Expr): Boolean = Pair(this,that) match { case Pair(Lit(l) ,Lit(r)) => l == r case Pair(Var(l) ,Var(r)) => l == r case Pair(Add(ll,lr),Add(rl,rr)) => (ll equ rl) && (lr equ rr) @@ -594,7 +593,7 @@ object MB { } - case class Lit(x: int) extends Expr { + case class Lit(x: Int) extends Expr { override def toString = x.toString } @@ -616,7 +615,7 @@ object MB { } } - case class Pow(e1: Expr, i2: int) extends Expr { + case class Pow(e1: Expr, i2: Int) extends Expr { override def toString = { def factorToString(e: Expr) = e match { case Add(_, _) => "(" + e.toString + ")" @@ -668,8 +667,8 @@ object MB { Console.println("f0(x) = " + f0); Console.println; - def check(n: String, f: Expr, x: int, e: int) = { - val a: int = f.evaluate(List(Pair("x",x))); + def check(n: String, f: Expr, x: Int, e: Int) { + val a: Int = f.evaluate(List(Pair("x",x))); val s: String = if (a == e) "ok" else "KO(" + e + ")"; Console.println(n + "(" + x + ") = " + a + " " + s); } @@ -704,7 +703,7 @@ object MB { //############################################################################ object Test { - def main(args: Array[String]): unit = { + def main(args: Array[String]) { M0.test; M1.test; M2.test; diff --git a/test/files/run/bug216.scala b/test/files/run/bug216.scala index 8f67c7b024..b046f51f47 100644 --- a/test/files/run/bug216.scala +++ b/test/files/run/bug216.scala @@ -1,6 +1,6 @@ object Test extends Application { object m { - val f = { x: unit => () } + val f = { x: Unit => () } Console.println("OK") } m; diff --git a/test/files/run/forvaleq.scala b/test/files/run/forvaleq.scala index a30c659ecc..1e4fd33dbc 100644 --- a/test/files/run/forvaleq.scala +++ b/test/files/run/forvaleq.scala @@ -1,4 +1,4 @@ -// test "val foo =" clauses in for comprehensions +// test "foo = expr" clauses in for comprehensions // $Id$ import scala.collection.immutable.Queue @@ -8,13 +8,13 @@ object Test { // redefine some symbols to make it extra hard class List class Tuple2 - def List[A](as:A*) = 5 + def List[A](as: A*) = 5 - def firstDigit(x:int): int = + def firstDigit(x: Int): Int = x match { case 0 => 0 - case _ if(x<0) => firstDigit(-x) - case _ if(x<10) => x + case _ if (x<0) => firstDigit(-x) + case _ if (x<10) => x case _ => firstDigit(x / 10) } @@ -24,38 +24,38 @@ object Test { val input = L.range(0,20) val oddFirstTimesTwo = - for{val x <- input - val xf = firstDigit(x) - xf % 2 == 1} + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} yield x*2 - Console.println(oddFirstTimesTwo) + println(oddFirstTimesTwo) } { // a test case with patterns - val input = L.range(0,20) + 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} + for {x <- input + xf = firstDigit(x) + yf = x - firstDigit(x) / 10 + (a, b) = (xf - yf, xf + yf) + if xf % 2 == 1} yield a + b - Console.println(oddFirstTimesTwo) + 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).elements + val input = L.range(0, 20).elements val oddFirstTimesTwo = - for{val x <- input - val xf = firstDigit(x) - xf % 2 == 1} + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} yield x*2 - Console.println(oddFirstTimesTwo.toList) + println(oddFirstTimesTwo.toList) } { @@ -63,30 +63,30 @@ object Test { val input = L.range(0,20) val oddFirstTimesTwo = - for{val x <- input - val xf = firstDigit(x) - xf % 2 == 1} + for {x <- input + xf = firstDigit(x) + if xf % 2 == 1} yield xf*2 - Console.println(oddFirstTimesTwo) + println(oddFirstTimesTwo) } { // make sure the function is only called once - var count: int = 0 + var count: Int = 0 - def fdct(x: int) = { - count = count + 1 + def fdct(x: Int) = { + count += 1 firstDigit(x) } val input = L.range(0,20) - for{val x <- input - val xf = fdct(x) - xf % 2 == 1} + for {x <- input + xf = fdct(x) + if xf % 2 == 1} yield xf - Console.println("called " + count + " times") + println("called " + count + " times") } - def main(args: Array[String]): Unit = () + def main(args: Array[String]) {} } diff --git a/test/files/run/literals.check b/test/files/run/literals.check index 030e3350c1..f53c879dea 100644 --- a/test/files/run/literals.check +++ b/test/files/run/literals.check @@ -1,6 +1,6 @@ test '\u0024' == '$' was successful test '\u005f' == '_' was successful -test 65.asInstanceOf[char] == 'A' was successful +test 65.asInstanceOf[Char] == 'A' was successful test "\141\142" == "ab" was successful test "\0x61\0x62".trim() == "x61\0x62" was successful @@ -34,7 +34,7 @@ test 0xffffffff == -1 was successful test 1l == 1L was successful test 1L == 1l was successful -test 1.asInstanceOf[long] == 1l was successful +test 1.asInstanceOf[Long] == 1l was successful test 0777777777777777777777L == 9223372036854775807L was successful test 01000000000000000000000L == -9223372036854775808L was successful test 01777777777777777777777L == -1L was successful @@ -49,8 +49,8 @@ test 0f == 0.0f was successful test 3.14f == 3.14f was successful test 6.022e23f == 6.022e23f was successful test 09f == 9.0f was successful -test 1.asInstanceOf[float] == 1.0 was successful -test 1l.asInstanceOf[float] == 1.0 was successful +test 1.asInstanceOf[Float] == 1.0 was successful +test 1l.asInstanceOf[Float] == 1.0 was successful test 1e1 == 10.0 was successful test 2. == 2.0 was successful @@ -61,8 +61,8 @@ test 0d == 0.0 was successful test 3.14 == 3.14 was successful test 1e-9d == 1.0e-9 was successful test 1e137 == 1.0e137 was successful -test 1.asInstanceOf[double] == 1.0 was successful -test 1l.asInstanceOf[double] == 1.0 was successful +test 1.asInstanceOf[Double] == 1.0 was successful +test 1l.asInstanceOf[Double] == 1.0 was successful test "".length() was successful test ggg == 3 was successful diff --git a/test/files/run/literals.scala b/test/files/run/literals.scala index 8f7eea55b5..213eca1bb8 100644 --- a/test/files/run/literals.scala +++ b/test/files/run/literals.scala @@ -15,37 +15,37 @@ object Test { def \u03b1\u03b1(that: GGG) = i + that.i } - def check_success[a](name: String, closure: => a, expected: a): Unit = { - Console.print("test " + name) + def check_success[a](name: String, closure: => a, expected: a) { + print("test " + name) try { val actual: a = closure if (actual == expected) { - Console.print(" was successful"); + print(" was successful"); } else { - Console.print(" failed: expected "+ expected +", found "+ actual); + print(" failed: expected "+ expected +", found "+ actual); } } catch { case exception: Throwable => { - Console.print(" raised exception " + exception); + print(" raised exception " + exception); } } - Console.println; + println } - def main(args: Array[String]) = { + def main(args: Array[String]) { // char check_success("'\\u0024' == '$'", '\u0024', '$') check_success("'\\u005f' == '_'", '\u005f', '_') - check_success("65.asInstanceOf[char] == 'A'", 65.asInstanceOf[char], 'A') + check_success("65.asInstanceOf[Char] == 'A'", 65.asInstanceOf[Char], 'A') check_success("\"\\141\\142\" == \"ab\"", "\141\142", "ab") check_success("\"\\0x61\\0x62\".trim() == \"x61\\0x62\"", "\0x61\0x62".substring(1), "x61\0x62") - Console.println + println // boolean check_success("(65 : Byte) == 'A'", (65: Byte) == 'A', true) // contrib #176 - Console.println + println // int check_success("01 == 1", 01, 1) @@ -78,12 +78,12 @@ object Test { check_success("0x80000000 == -2147483648", 0x80000000, -2147483648) check_success("0xffffffff == -1", 0xffffffff, -1) - Console.println + println // long check_success("1l == 1L", 1l, 1L) check_success("1L == 1l", 1L, 1l) - check_success("1.asInstanceOf[long] == 1l", 1.asInstanceOf[long], 1l) + check_success("1.asInstanceOf[Long] == 1l", 1.asInstanceOf[Long], 1l) check_success("0777777777777777777777L == 9223372036854775807L", 0777777777777777777777L, 9223372036854775807L) @@ -99,7 +99,7 @@ object Test { check_success("0xffffffffffffffffL == -1L", 0xffffffffffffffffL, -1L) - Console.println + println // see JLS at address: // http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#230798 @@ -112,10 +112,10 @@ object Test { check_success("3.14f == 3.14f", 3.14f, 3.14f) check_success("6.022e23f == 6.022e23f", 6.022e23f, 6.022e23f) check_success("09f == 9.0f", 09f, 9.0f) - check_success("1.asInstanceOf[float] == 1.0", 1.asInstanceOf[float], 1.0f) - check_success("1l.asInstanceOf[float] == 1.0", 1l.asInstanceOf[float], 1.0f) + check_success("1.asInstanceOf[Float] == 1.0", 1.asInstanceOf[Float], 1.0f) + check_success("1l.asInstanceOf[Float] == 1.0", 1l.asInstanceOf[Float], 1.0f) - Console.println + println // double check_success("1e1 == 10.0", 1e1, 10.0) @@ -127,10 +127,10 @@ object Test { check_success("3.14 == 3.14", 3.14, 3.14) check_success("1e-9d == 1.0e-9", 1e-9d, 1.0e-9) check_success("1e137 == 1.0e137", 1e137, 1.0e137) - check_success("1.asInstanceOf[double] == 1.0", 1.asInstanceOf[double], 1.0) - check_success("1l.asInstanceOf[double] == 1.0", 1l.asInstanceOf[double], 1.0) + check_success("1.asInstanceOf[Double] == 1.0", 1.asInstanceOf[Double], 1.0) + check_success("1l.asInstanceOf[Double] == 1.0", 1l.asInstanceOf[Double], 1.0) - Console.println + println check_success("\"\".length()", "\u001a".length(), 1) val ggg = GGG(1) \u03b1\u03b1 GGG(2) diff --git a/test/files/run/retsynch.scala b/test/files/run/retsynch.scala index d6398cf28e..7735df7d96 100644 --- a/test/files/run/retsynch.scala +++ b/test/files/run/retsynch.scala @@ -1,6 +1,6 @@ object Test { - def abs(x:int): int = synchronized { - if(x > 0) + def abs(x: Int): Int = synchronized { + if (x > 0) return x return -x } -- cgit v1.2.3