summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-05-20 14:25:02 +0000
committermichelou <michelou@epfl.ch>2008-05-20 14:25:02 +0000
commit3a0b0d40d7be5fb100a1b061aab54a4d4a51ae60 (patch)
treeb8bae307ad9df5c04ff7a8d68a9be755a1a6a748
parentc1f07338ed21e551446a5c98d262d738a9b7b0ce (diff)
downloadscala-3a0b0d40d7be5fb100a1b061aab54a4d4a51ae60.tar.gz
scala-3a0b0d40d7be5fb100a1b061aab54a4d4a51ae60.tar.bz2
scala-3a0b0d40d7be5fb100a1b061aab54a4d4a51ae60.zip
int -> Int, etc..
-rw-r--r--test/files/pos/Transactions.scala20
-rw-r--r--test/files/pos/bug245.scala12
-rw-r--r--test/files/run/Course-2002-09.scala26
-rw-r--r--test/files/run/boolexprs.scala11
-rw-r--r--test/files/run/boolord.scala2
-rw-r--r--test/files/run/implicits.scala2
-rw-r--r--test/files/run/lisp.scala59
-rw-r--r--test/files/run/misc.scala47
-rw-r--r--test/files/run/tuples.scala32
9 files changed, 103 insertions, 108 deletions
diff --git a/test/files/pos/Transactions.scala b/test/files/pos/Transactions.scala
index 8fb23268dc..ed989e178e 100644
--- a/test/files/pos/Transactions.scala
+++ b/test/files/pos/Transactions.scala
@@ -1,11 +1,11 @@
-package scala.concurrent;
+package scala.concurrent
-class AbortException extends RuntimeException;
+class AbortException extends RuntimeException
object Transaction {
private var cnt = 0L
- def nextId: long = synchronized {
- cnt = cnt + 1; cnt
+ def nextId: Long = synchronized {
+ cnt += 1; cnt
}
// Transaction status constants
@@ -20,9 +20,9 @@ object Transaction {
}
class Transaction {
- var status: int = _
+ var status: Int = _
- var id: long = _ // only for real transactions
+ var id: Long = _ // only for real transactions
var head: Transaction = this
var next: Transaction = null
@@ -54,10 +54,10 @@ class Transaction {
trait Transactional {
/** create a new snapshot */
- def checkPoint(): unit
+ def checkPoint(): Unit
/** copy back snapshot */
- def rollBack(): unit
+ def rollBack(): Unit
var readers: Transaction
var writer: Transaction
@@ -71,7 +71,7 @@ trait Transactional {
null
}
- def getter(thisTrans: Transaction): unit = {
+ def getter(thisTrans: Transaction) {
if (writer == thisTrans) return
var r = readers
while (r != null && r.head.status != Transaction.Running) { r = r.next; readers = r }
@@ -91,7 +91,7 @@ trait Transactional {
}
}
- def setter(thisTrans: Transaction): unit = {
+ def setter(thisTrans: Transaction) {
if (writer == thisTrans) return
synchronized {
val w = currentWriter()
diff --git a/test/files/pos/bug245.scala b/test/files/pos/bug245.scala
index b33dd9914f..570ac4178d 100644
--- a/test/files/pos/bug245.scala
+++ b/test/files/pos/bug245.scala
@@ -2,15 +2,15 @@ class Value {}
object Test {
- implicit def view(v: Value): int = 0;
+ implicit def view(v: Value): Int = 0
- def foo(i: Int): Int = 0;
+ def foo(i: Int): Int = 0
- def fun0 : Value = null;
- def fun0(i: Int ): Value = null;
+ def fun0 : Value = null
+ def fun0(i: Int ): Value = null
- def fun1(i: Int ): Value = null;
- def fun1(l: Long): Value = null;
+ def fun1(i: Int ): Value = null
+ def fun1(l: Long): Value = null
foo(fun0 );
foo(fun1(new Value));
diff --git a/test/files/run/Course-2002-09.scala b/test/files/run/Course-2002-09.scala
index 193edb9b7e..5b2adbc581 100644
--- a/test/files/run/Course-2002-09.scala
+++ b/test/files/run/Course-2002-09.scala
@@ -65,14 +65,14 @@ class Eq(a: Quantity, b: Quantity) extends Constraint {
case Pair(Some(x), _ ) => b.setValue(x, this);
case Pair(_ , Some(y)) => a.setValue(y, this);
}
- def dropValue: Unit = {
+ def dropValue {
a.forgetValue(this); b.forgetValue(this);
}
a connect this;
b connect this;
}
-class Constant(q: Quantity, v: double) extends Constraint {
+class Constant(q: Quantity, v: Double) extends Constraint {
def newValue: Unit = error("Constant.newValue");
def dropValue: Unit = error("Constant.dropValue");
q connect this;
@@ -82,7 +82,7 @@ class Constant(q: Quantity, v: double) extends Constraint {
class Probe(name: String, q: Quantity) extends Constraint {
def newValue: Unit = printProbe(q.getValue);
def dropValue: Unit = printProbe(None);
- private def printProbe(v: Option[double]): Unit = {
+ private def printProbe(v: Option[double]) {
val vstr = v match {
case Some(x) => x.toString()
case None => "?"
@@ -93,13 +93,13 @@ class Probe(name: String, q: Quantity) extends Constraint {
}
class Quantity() {
- private var value: Option[double] = None;
+ private var value: Option[Double] = None;
private var constraints: List[Constraint] = List();
private var informant: Constraint = null;
- def getValue: Option[double] = value;
+ def getValue: Option[Double] = value;
- def setValue(v: double, setter: Constraint) = value match {
+ def setValue(v: Double, setter: Constraint) = value match {
case Some(v1) =>
if (v != v1) error("Error! contradiction: " + v + " and " + v1);
case None =>
@@ -108,7 +108,7 @@ class Quantity() {
c.newValue;
}
}
- def setValue(v: double): Unit = setValue(v, NoConstraint);
+ def setValue(v: Double): Unit = setValue(v, NoConstraint);
def forgetValue(retractor: Constraint): Unit = {
if (retractor == informant) {
@@ -207,7 +207,7 @@ object M0 {
object M1 {
- def constant(x: double): Quantity = {
+ def constant(x: Double): Quantity = {
val q = new Quantity();
new Constant(q, x);
q
@@ -219,13 +219,13 @@ object M1 {
v + constant(32) === f;
}
- def show_c2f(c: Quantity, f: Quantity, v: int) = {
+ def show_c2f(c: Quantity, f: Quantity, v: Int) = {
c.setValue(v);
Console.println(c.str + " Celsius -> " + f.str + " Fahrenheits");
c.forgetValue;
}
- def show_f2c(c: Quantity, f: Quantity, v: int) = {
+ def show_f2c(c: Quantity, f: Quantity, v: Int) = {
f.setValue(v);
Console.println(f.str + " Fahrenheits -> " + c.str + " Celsius");
f.forgetValue;
@@ -252,14 +252,14 @@ object M2 {
val b = new Quantity();
val c = a * b;
- def set(q: Quantity, o: Option[int]): String = {
+ def set(q: Quantity, o: Option[Int]): String = {
o match {
case None => "?"
case Some(v) => q.setValue(v); v.toString()
};
}
- def show(x: Option[int], y: Option[int], z: Option[int]) = {
+ def show(x: Option[int], y: Option[Int], z: Option[int]) = {
Console.print("a = " +set(a,x)+ ", b = " +set(b,y)+ ", c = " +set(c,z));
Console.println(" => " + a.str + " * " + b.str + " = " + c.str);
a.forgetValue; b.forgetValue; c.forgetValue;
@@ -321,7 +321,7 @@ object M3 {
//############################################################################
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/boolexprs.scala b/test/files/run/boolexprs.scala
index 7080f84b56..f92a358e26 100644
--- a/test/files/run/boolexprs.scala
+++ b/test/files/run/boolexprs.scala
@@ -5,13 +5,13 @@
class Counter {
private var n: Int = 0;
- def incrThen(b: Boolean) = if (b) n = n + 1;
+ def incrThen(b: Boolean) = if (b) n += 1;
def value = n;
}
object Test1 {
var flag = false;
- def flip: boolean = { val tmp = flag; flag = !flag; tmp }
+ def flip: Boolean = { val tmp = flag; flag = !flag; tmp }
def run: Int = {
val c = new Counter;
c.incrThen(flip || flip);
@@ -34,7 +34,7 @@ object Test2 {
// Test code
object Test {
- def check_success(name: String, closure: => Int, expected: Int): Unit = {
+ def check_success(name: String, closure: => Int, expected: Int) {
Console.print("test " + name);
try {
val actual: Int = closure;
@@ -44,14 +44,13 @@ object Test {
Console.print(" failed: expected "+ expected +", found "+ actual);
}
} catch {
- case exception: Throwable => {
+ case exception: Throwable =>
Console.print(" raised exception " + exception);
- }
}
Console.println;
}
- def main(args: Array[String]): Unit = {
+ def main(args: Array[String]) {
check_success("Test1", Test1.run, 1);
check_success("Test2", Test2.run, 0);
Console.println;
diff --git a/test/files/run/boolord.scala b/test/files/run/boolord.scala
index 7a004d90f1..05d06ffea9 100644
--- a/test/files/run/boolord.scala
+++ b/test/files/run/boolord.scala
@@ -1,5 +1,5 @@
object Test {
- def main(args: Array[String]): unit = {
+ def main(args: Array[String]) {
Console.println("false < false = " + (false < false))
Console.println("false < true = " + (false < true))
Console.println("true < false = " + (true < false))
diff --git a/test/files/run/implicits.scala b/test/files/run/implicits.scala
index c45badc49f..3fd3561fe7 100644
--- a/test/files/run/implicits.scala
+++ b/test/files/run/implicits.scala
@@ -1,6 +1,6 @@
object A {
object B {
- implicit def int2string(x: int) = "["+x.toString+"]"
+ implicit def int2string(x: Int) = "["+x.toString+"]"
}
}
diff --git a/test/files/run/lisp.scala b/test/files/run/lisp.scala
index 8a559bc813..eeafadcc9b 100644
--- a/test/files/run/lisp.scala
+++ b/test/files/run/lisp.scala
@@ -8,15 +8,15 @@
class LispTokenizer(s: String) extends Iterator[String] {
private var i = 0;
- private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')';
+ private def isDelimiter(ch: Char) = ch <= ' ' || ch == '(' || ch == ')'
def hasNext: Boolean = {
- while (i < s.length() && s.charAt(i) <= ' ') { i = i + 1 }
+ while (i < s.length() && s.charAt(i) <= ' ') i += 1
i < s.length()
}
def next: String =
if (hasNext) {
val start = i
- if (isDelimiter(s charAt i)) i = i + 1
+ if (isDelimiter(s charAt i)) i += 1
else
do i = i + 1
while (!isDelimiter(s charAt i))
@@ -28,14 +28,14 @@ class LispTokenizer(s: String) extends Iterator[String] {
// Lisp Interface
trait Lisp {
- type Data;
+ type Data
- def string2lisp(s: String): Data;
- def lisp2string(s: Data): String;
+ def string2lisp(s: String): Data
+ def lisp2string(s: Data): String
- def evaluate(d: Data): Data;
- // !!! def evaluate(s: String): Data = evaluate(string2lisp(s));
- def evaluate(s: String): Data;
+ def evaluate(d: Data): Data
+ // !!! def evaluate(s: String): Data = evaluate(string2lisp(s))
+ def evaluate(s: String): Data
}
//############################################################################
@@ -43,7 +43,7 @@ trait Lisp {
object LispCaseClasses extends Lisp {
- import List.range;
+ import List.range
trait Data {
def elemsToString(): String = toString();
@@ -98,9 +98,9 @@ object LispCaseClasses extends Lisp {
x6: Data, x7: Data, x8: Data, x9: Data): Data =
CONS(x0, list(x1, x2, x3, x4, x5, x6, x7, x8, x9));
- var curexp: Data = null;
- var trace: Boolean = false;
- var indent: Int = 0;
+ var curexp: Data = null
+ var trace: Boolean = false
+ var indent: Int = 0
def lispError[a](msg: String): a =
error("error: " + msg + "\n" + curexp);
@@ -146,14 +146,14 @@ object LispCaseClasses extends Lisp {
val prevexp = curexp;
curexp = x;
if (trace) {
- for (val x <- range(1, indent)) Console.print(" ");
+ for (x <- range(1, indent)) Console.print(" ");
Console.println("===> " + x);
indent = indent + 1;
}
val result = eval1(x, env);
if (trace) {
indent = indent - 1;
- for (val x <- range(1, indent)) Console.print(" ");
+ for (x <- range(1, indent)) Console.print(" ");
Console.println("<=== " + result);
}
curexp = prevexp;
@@ -267,8 +267,8 @@ object LispAny extends Lisp {
case class Lambda(f: List[Data] => Data);
var curexp: Data = null;
- var trace: boolean = false;
- var indent: int = 0;
+ var trace: Boolean = false;
+ var indent: Int = 0;
def lispError[a](msg: String): a =
error("error: " + msg + "\n" + curexp);
@@ -291,8 +291,8 @@ object LispAny extends Lisp {
case _ => lispError("malformed list: " + x)
}
- def asInt(x: Data): int = x match {
- case y: int => y
+ def asInt(x: Data): Int = x match {
+ case y: Int => y
case _ => lispError("not an integer: " + x)
}
@@ -301,8 +301,7 @@ object LispAny extends Lisp {
case _ => lispError("not a string: " + x)
}
- def asBoolean(x: Data): boolean =
- if (x == 0) false else true;
+ def asBoolean(x: Data): Boolean = x != 0
def normalize(x: Data): Data = x match {
case 'and :: x :: y :: Nil =>
@@ -327,13 +326,13 @@ object LispAny extends Lisp {
val prevexp = curexp;
curexp = x;
if (trace) {
- for (val x <- range(1, indent)) Console.print(" ");
+ for (x <- range(1, indent)) Console.print(" ");
Console.println("===> " + x);
- indent = indent + 1;
+ indent += 1;
}
val result = eval1(x, env);
if (trace) {
- indent = indent - 1;
+ indent -= 1;
for (val x <- range(1, indent)) Console.print(" ");
Console.println("<=== " + result);
}
@@ -358,7 +357,7 @@ object LispAny extends Lisp {
apply(eval(y, env), z map (x => eval(x, env)))
case Lambda(_) => x
case y: String => x
- case y: int => x
+ case y: Int => x
case y => lispError("illegal term")
}
@@ -404,14 +403,14 @@ object LispAny extends Lisp {
.extend("=", Lambda{
case List(arg1, arg2) => if(arg1 == arg2) 1 else 0})
.extend("+", Lambda{
- case List(arg1: int, arg2: int) => arg1 + arg2
+ case List(arg1: Int, arg2: Int) => arg1 + arg2
case List(arg1: String, arg2: String) => arg1 + arg2})
.extend("-", Lambda{
- case List(arg1: int, arg2: int) => arg1 - arg2})
+ case List(arg1: Int, arg2: Int) => arg1 - arg2})
.extend("*", Lambda{
- case List(arg1: int, arg2: int) => arg1 * arg2})
+ case List(arg1: Int, arg2: Int) => arg1 * arg2})
.extend("/", Lambda{
- case List(arg1: int, arg2: int) => arg1 / arg2})
+ case List(arg1: Int, arg2: Int) => arg1 / arg2})
.extend("nil", Nil)
.extend("cons", Lambda{
case List(arg1, arg2) => arg1 :: asList(arg2)})
@@ -510,7 +509,7 @@ class LispUser(lisp: Lisp) {
// Main
object Test {
- def main(args: Array[String]): Unit = {
+ def main(args: Array[String]) {
new LispUser(LispCaseClasses).run;
new LispUser(LispAny).run;
()
diff --git a/test/files/run/misc.scala b/test/files/run/misc.scala
index 6229cd4510..a636ef99d8 100644
--- a/test/files/run/misc.scala
+++ b/test/files/run/misc.scala
@@ -2,14 +2,12 @@
object Test {
-def fac(n: Int): Int = if (n < 2) 1 else fac(n - 1) * n;
+ def fac(n: Int): Int = if (n < 2) 1 else fac(n - 1) * n;
-// Fibonacci
+ // Fibonacci
+ def fib(n: Int): Int = if (n < 2) 1 else fib(n - 1) + fib(n - 2);
-
-def fib(n: Int): Int = if (n < 2) 1 else fib(n - 1) + fib(n - 2);
-
-def show_fib(n: Int): Int = {
+ def show_fib(n: Int): Int = {
Console.print("### fib(");
Console.print(n);
Console.print(") = ");
@@ -19,34 +17,34 @@ def show_fib(n: Int): Int = {
Console.println;
Console.flush;
v
-}
+ }
-def id[X](x: X): X = x;
+ def id[X](x: X): X = x;
-def apply[X](f: X => X, x: X): X = f(x);
+ def apply[X](f: X => X, x: X): X = f(x);
-def id_obj(x: AnyRef): AnyRef = x;
+ def id_obj(x: AnyRef): AnyRef = x;
-def apply_obj(f: AnyRef => AnyRef, x: AnyRef): AnyRef = f(x);
+ def apply_obj(f: AnyRef => AnyRef, x: AnyRef): AnyRef = f(x);
-def id_any(x: scala.Any): scala.Any = x;
+ def id_any(x: scala.Any): scala.Any = x;
-def apply_any(f: scala.Any => scala.Any, x: scala.Any): scala.Any = f(x);
+ def apply_any(f: scala.Any => scala.Any, x: scala.Any): scala.Any = f(x);
-def id_int(x: Int): Int = x;
+ def id_int(x: Int): Int = x;
-def apply_int(f: Int => Int, x: Int): Int = f(x);
+ def apply_int(f: Int => Int, x: Int): Int = f(x);
-class MyClass() {
+ class MyClass() {
override def toString() = "=== MyClass::toString ===";
def test() = Console.println("=== MyClass::test ===");
-}
+ }
-class MySubclass() extends MyClass() {
+ class MySubclass() extends MyClass() {
override def toString() = "=== MySubclass::toString ===";
-}
+ }
-def foobar = {
+ def foobar = {
42;
42l;
23.5f;
@@ -107,9 +105,9 @@ def foobar = {
Console.println(apply_any(id_any, "identity").toString());
Console.println;
-};
+ };
-foobar;
+ foobar;
//############################################################################
@@ -218,7 +216,7 @@ Console.println;
case class Bar();
- case class Foo(i:int, j:char, c:Bar) ;
+ case class Foo(i: Int, j: Char, c: Bar) ;
Console.println(
true // Foo(3,'a',Bar()).caseElement( -1 ) == null // throws Exception now
@@ -231,8 +229,7 @@ Console.println;
//############################################################################
- def main(args: Array[String]): Unit = {
- ()
+ def main(args: Array[String]) {
}
//############################################################################
diff --git a/test/files/run/tuples.scala b/test/files/run/tuples.scala
index b03167adee..ff1b53fd11 100644
--- a/test/files/run/tuples.scala
+++ b/test/files/run/tuples.scala
@@ -1,30 +1,30 @@
import Function._
object Test extends Application {
- var xyz: (int, String, boolean) = _
+ var xyz: (Int, String, Boolean) = _
xyz = (1, "abc", true)
Console.println(xyz)
xyz match {
case (1, "abc", true) => Console.println("OK")
}
- def func(x : int, y : String, z : double) : unit = {
- Console.println("x = " + x + "; y = " + y + "; z = " + z);
- }
+ def func(x: Int, y: String, z: Double) {
+ Console.println("x = " + x + "; y = " + y + "; z = " + z);
+ }
- def params = (2, "xxx", 3.14159) // (*****)
+ sef params = (2, "xxx", 3.14159) // (*****)
- tupled(func _)(params) // call the function with all the params at once
- func(2, "xxx", 3.14159) // the same call
- (func _).apply(2, "xxx", 3.14159) // the same call
+ tupled(func _)(params) // call the function with all the params at once
+ func(2, "xxx", 3.14159) // the same call
+ (func _).apply(2, "xxx", 3.14159) // the same call
- // Composing a tuple
- def t = (1, "Hello", false)
+ // Composing a tuple
+ def t = (1, "Hello", false)
- // Decomposing a tuple
- val (i, s, b) = t
+ // Decomposing a tuple
+ val (i, s, b) = t
- // all the assertions are passed
- assert(i == 1)
- assert(s == "Hello")
- assert(b == false)
+ // all the assertions are passed
+ assert(i == 1)
+ assert(s == "Hello")
+ assert(b == false)
}