summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-06-10 08:46:06 +0000
committermichelou <michelou@epfl.ch>2008-06-10 08:46:06 +0000
commita4baf28d203959457d82762e27ffbb7104dc0a07 (patch)
tree7b249d126396b87cd937da6cd564000b8a6051de /test/files/run
parent113c79559555dd408ea76da5f462025536cbd7d6 (diff)
downloadscala-a4baf28d203959457d82762e27ffbb7104dc0a07.tar.gz
scala-a4baf28d203959457d82762e27ffbb7104dc0a07.tar.bz2
scala-a4baf28d203959457d82762e27ffbb7104dc0a07.zip
int -> Int, etc..
Diffstat (limited to 'test/files/run')
-rw-r--r--test/files/run/Course-2002-05.scala68
-rw-r--r--test/files/run/Course-2002-07.scala165
-rw-r--r--test/files/run/bug216.scala2
-rw-r--r--test/files/run/forvaleq.scala66
-rw-r--r--test/files/run/literals.check12
-rw-r--r--test/files/run/literals.scala38
-rw-r--r--test/files/run/retsynch.scala4
7 files changed, 177 insertions, 178 deletions
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 +<? that) < 0;
- private def +<= (that: Expr): boolean = (this +<? that) <= 0;
- private def +<? (that: Expr): int = Pair(this,that) match {
+ private def +< (that: Expr): Boolean = (this +<? that) < 0;
+ private def +<= (that: Expr): Boolean = (this +<? that) <= 0;
+ private def +<? (that: Expr): Int = Pair(this,that) match {
case Pair(Add(_,_), _ ) => 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 *<? that) < 0;
- private def *<= (that: Expr): boolean = (this *<? that) <= 0;
- private def *<? (that: Expr): int = Pair(this,that) match {
+ private def *< (that: Expr): Boolean = (this *<? that) < 0;
+ private def *<= (that: Expr): Boolean = (this *<? that) <= 0;
+ private def *<? (that: Expr): Int = Pair(this,that) match {
case Pair(Mul(_,_), _ ) => 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
}