diff options
Diffstat (limited to 'test/files/run/misc.scala')
-rw-r--r-- | test/files/run/misc.scala | 87 |
1 files changed, 37 insertions, 50 deletions
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(); |