summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2005-10-05 08:28:41 +0000
committermihaylov <mihaylov@epfl.ch>2005-10-05 08:28:41 +0000
commitb57983c013bcc46d633c50eaadd8a52050cdf825 (patch)
tree445b50f0846fda9a61bd7297e77ba1fdf947941b /test
parentc9305ff74fc9e23d2a8f4c6a27a25e5562c048cc (diff)
downloadscala-b57983c013bcc46d633c50eaadd8a52050cdf825.tar.gz
scala-b57983c013bcc46d633c50eaadd8a52050cdf825.tar.bz2
scala-b57983c013bcc46d633c50eaadd8a52050cdf825.zip
Made platform independant
Diffstat (limited to 'test')
-rw-r--r--test/files/run/misc-msil.check33
-rw-r--r--test/files/run/misc.check2
-rw-r--r--test/files/run/misc.scala87
3 files changed, 70 insertions, 52 deletions
diff --git a/test/files/run/misc-msil.check b/test/files/run/misc-msil.check
new file mode 100644
index 0000000000..480a840b9a
--- /dev/null
+++ b/test/files/run/misc-msil.check
@@ -0,0 +1,33 @@
+### Hello
+### 17
+### Bye
+
+### fib(0) = 1
+### fib(1) = 1
+### fib(2) = 2
+### fib(3) = 3
+### fib(4) = 5
+=== MyClass::toString ===
+=== MySubclass::toString ===
+=== MyClass::test ===
+
+identity
+
+A.a = 1
+B.a = 5
+B.b = 2
+
+X.a = 4
+Y.a = 11
+Y.b = 5
+Y.b = 5
+
+X::foo
+
+Y::foo
+X::foo
+
+3
+3
+
+True
diff --git a/test/files/run/misc.check b/test/files/run/misc.check
index db16f96a94..9fa7b72d50 100644
--- a/test/files/run/misc.check
+++ b/test/files/run/misc.check
@@ -7,8 +7,6 @@
### fib(2) = 2
### fib(3) = 3
### fib(4) = 5
-Hello -> 32
-
=== MyClass::toString ===
=== MySubclass::toString ===
=== MyClass::test ===
diff --git a/test/files/run/misc.scala b/test/files/run/misc.scala
index 7548b1996e..900139e1cd 100644
--- a/test/files/run/misc.scala
+++ b/test/files/run/misc.scala
@@ -1,7 +1,5 @@
// $Id$
-import java.lang.System; // to avoid name clash with .NET's library
-
object Test {
def fac(n: Int): Int = if (n < 2) 1 else fac(n - 1) * n;
@@ -12,14 +10,14 @@ def fac(n: Int): Int = if (n < 2) 1 else fac(n - 1) * n;
def fib(n: Int): Int = if (n < 2) 1 else fib(n - 1) + fib(n - 2);
def show_fib(n: Int): Int = {
- System.out.print("### fib(");
- System.out.print(n);
- System.out.print(") = ");
- System.out.flush();
+ Console.print("### fib(");
+ Console.print(n);
+ Console.print(") = ");
+ Console.flush;
val v = fib(n);
- System.out.print(v);
- System.out.println();
- System.out.flush();
+ Console.print(v);
+ Console.println;
+ Console.flush;
v
}
@@ -27,9 +25,9 @@ def id[X](x: X): X = x;
def apply[X](f: X => X, x: X): X = f(x);
-def id_obj(x: java.lang.Object): java.lang.Object = x;
+def id_obj(x: Object): Object = x;
-def apply_obj(f: java.lang.Object => java.lang.Object, x: java.lang.Object): java.lang.Object = f(x);
+def apply_obj(f: Object => Object, x: Object): Object = f(x);
def id_any(x: scala.Any): scala.Any = x;
@@ -41,7 +39,7 @@ def apply_int(f: Int => Int, x: Int): Int = f(x);
class MyClass() {
override def toString() = "=== MyClass::toString ===";
- def test() = System.out.println("=== MyClass::test ===");
+ def test() = Console.println("=== MyClass::test ===");
}
class MySubclass() extends MyClass() {
@@ -58,14 +56,12 @@ def foobar = {
// !!! System
// java; // !!! why is this legal ? what does it return ?
// java.lang;
- // java.lang.System; // !!! return the Class object ?
- System.out;
- System.out.println("### Hello");
- System.out.print("### ");
- System.out.println(17);
- // !!! java.lang.System.out.println("### " + 13);
- System.out.println("### Bye");
- System.out.println();
+ //System.out;
+ Console.println("### Hello");
+ Console.print("### ");
+ Console.println(17);
+ Console.println("### Bye");
+ Console.println;
val x = 13;
x;
// !!! why are DefDef replaced by Block(Tree[0])? we should use Empty!
@@ -102,24 +98,15 @@ def foobar = {
show_fib(12);
*/
- val map: java.util.Map = new java.util.HashMap();
- // why do we insert type casts as[scala.Any]();
- map.put("Hello", new java.lang.Integer(32));
- System.out.println("Hello -> " + map.get("Hello"));
- // !!! apply(map.get, "Hello");
- System.out.println();
-
val myObj = new MyClass();
- System.out.println(myObj);
+ Console.println(myObj);
val mySub = new MySubclass();
- System.out.println(mySub);
- // java.lang.System.out.println(myObj.test()); // !!! strange type error
+ Console.println(mySub);
myObj.test();
- System.out.println();
+ Console.println;
- System.out.println(apply_any(id_any, "identity").toString());
- //apply[java.lang.String](id[java.lang.String], "identity")
- System.out.println();
+ Console.println(apply_any(id_any, "identity").toString());
+ Console.println;
};
foobar;
@@ -149,16 +136,16 @@ case class Y(y: Int, z: Int) extends X(y + z) {
val x: X = new X(4);
val y: Y = new Y(5,6);
- System.out.println("A.a = " + a.getA);
- System.out.println("B.a = " + b.getA);
- System.out.println("B.b = " + b.getB);
- System.out.println();
+ Console.println("A.a = " + a.getA);
+ Console.println("B.a = " + b.getA);
+ Console.println("B.b = " + b.getB);
+ Console.println;
- System.out.println("X.a = " + x.getX);
- System.out.println("Y.a = " + y.getX);
- System.out.println("Y.b = " + y.getY);
- System.out.println("Y.b = " + y.y);
- System.out.println();
+ Console.println("X.a = " + x.getX);
+ Console.println("Y.a = " + y.getX);
+ Console.println("Y.b = " + y.getY);
+ Console.println("Y.b = " + y.y);
+ Console.println;
}
//############################################################################
@@ -167,7 +154,7 @@ case class Y(y: Int, z: Int) extends X(y + z) {
class X() {
def foo = {
- System.out.println("X::foo");
+ Console.println("X::foo");
}
}
@@ -175,7 +162,7 @@ class X() {
class Y() extends X() {
override def foo = {
- System.out.println("Y::foo");
+ Console.println("Y::foo");
super.foo;
}
@@ -185,10 +172,10 @@ val x: X = new X();
val y: X = new Y();
x.foo;
-System.out.println();
+Console.println;
y.foo;
-System.out.println();
+Console.println;
}
//############################################################################
@@ -207,7 +194,7 @@ class O(a: Int) {
def foo = Y(2).bar
}
-System.out.println(new O(1).foo)
+Console.println(new O(1).foo)
}
{
@@ -224,10 +211,10 @@ class O(a: Int) {
def foo = Y(2).bar
}
-System.out.println(new O(1).foo)
+Console.println(new O(1).foo)
}
-System.out.println();
+Console.println;
case class Bar();