From a4796d889dbeb01ec015ed0fe768fccf7454b4c5 Mon Sep 17 00:00:00 2001 From: mihaylov Date: Mon, 3 Oct 2005 22:10:15 +0000 Subject: Made platform-independant --- test/files/run/Course-2002-03.scala | 126 ++++++++++++++++++------------------ test/files/run/lisp.scala | 52 +++++++-------- test/files/run/mixins.scala | 28 ++++---- 3 files changed, 102 insertions(+), 104 deletions(-) (limited to 'test') diff --git a/test/files/run/Course-2002-03.scala b/test/files/run/Course-2002-03.scala index c0e3cecfc6..7933514f9a 100644 --- a/test/files/run/Course-2002-03.scala +++ b/test/files/run/Course-2002-03.scala @@ -19,11 +19,11 @@ object M0 { val x = new Rational(1, 2); val y = new Rational(1, 3); - java.lang.System.out.println(x.numer); - java.lang.System.out.println(x.denom); - java.lang.System.out.println(makeString(x)); - java.lang.System.out.println(makeString(addRational(x,y))); - java.lang.System.out.println(); + Console.println(x.numer); + Console.println(x.denom); + Console.println(makeString(x)); + Console.println(makeString(addRational(x,y))); + Console.println; } //############################################################################ @@ -46,11 +46,11 @@ object M1 { val x = new Rational(1, 3); val y = new Rational(5, 7); val z = new Rational(3, 2); - java.lang.System.out.println(x); - java.lang.System.out.println(y); - java.lang.System.out.println(z); - java.lang.System.out.println(x.add(y).mul(z)); - java.lang.System.out.println(); + Console.println(x); + Console.println(y); + Console.println(z); + Console.println(x.add(y).mul(z)); + Console.println; } //############################################################################ @@ -83,11 +83,11 @@ object M2 { val x = new Rational(1, 3); val y = new Rational(5, 7); val z = new Rational(3, 2); - java.lang.System.out.println(x); - java.lang.System.out.println(y); - java.lang.System.out.println(z); - java.lang.System.out.println(x.add(y).mul(z)); - java.lang.System.out.println(); + Console.println(x); + Console.println(y); + Console.println(z); + Console.println(x.add(y).mul(z)); + Console.println; } //############################################################################ @@ -105,11 +105,11 @@ object M3 { val x = new Rational(66, 42); val y = new Rational(42, 66); - java.lang.System.out.println(x); - java.lang.System.out.println(y); - java.lang.System.out.println(x.max(y)); - java.lang.System.out.println(y.max(x)); - java.lang.System.out.println(); + Console.println(x); + Console.println(y); + Console.println(x.max(y)); + Console.println(y.max(x)); + Console.println; } //############################################################################ @@ -141,8 +141,8 @@ object M4 { val x = new Rational(1, 2); val y = new Rational(1, 3); - java.lang.System.out.println(x * x + y * y); - java.lang.System.out.println(); + Console.println(x * x + y * y); + Console.println; } //############################################################################ @@ -170,11 +170,11 @@ object M5 { } val x = new Empty incl 1 incl 2; - java.lang.System.out.println(x contains 0); - java.lang.System.out.println(x contains 1); - java.lang.System.out.println(x contains 2); - java.lang.System.out.println(x contains 3); - java.lang.System.out.println(); + Console.println(x contains 0); + Console.println(x contains 1); + Console.println(x contains 2); + Console.println(x contains 3); + Console.println; } //############################################################################ @@ -296,42 +296,42 @@ object M8 { val setx: IntSet = set0 incl -10 incl 5 incl 21 incl -1 incl 0 incl 3; val sety: IntSet = set0 incl 3 incl 7 incl -5 incl 0 incl-9 incl 8 incl-1; - java.lang.System.out.println("set0 = " + set0); - java.lang.System.out.println("set1 = " + (set1.toString())); - java.lang.System.out.println("set2 = " + set2); - java.lang.System.out.println("set3 = " + (set3.toString())); - java.lang.System.out.println("set4 = " + set4); - java.lang.System.out.println(); + Console.println("set0 = " + set0); + Console.println("set1 = " + (set1.toString())); + Console.println("set2 = " + set2); + Console.println("set3 = " + (set3.toString())); + Console.println("set4 = " + set4); + Console.println; - java.lang.System.out.println("set2 contains the following elements:"); - set2.foreach(java.lang.System.out.println); - java.lang.System.out.println(); + Console.println("set2 contains the following elements:"); + set2.foreach(Console.println); + Console.println; - java.lang.System.out.println("set3 contains the following elements:"); - set3 foreach java.lang.System.out.println; - java.lang.System.out.println(); + Console.println("set3 contains the following elements:"); + set3 foreach Console.println; + Console.println; - java.lang.System.out.println("set4 contains the following elements:"); + Console.println("set4 contains the following elements:"); set4.printOn(java.lang.System.out); - java.lang.System.out.println(); - - java.lang.System.out.println("2 <- set2: " + (set2 contains 2)); - java.lang.System.out.println("3 <- set2: " + set2.contains(3)); - java.lang.System.out.println(); - - java.lang.System.out.println("setx = " + setx); - java.lang.System.out.println("setx * 2 = " + (setx.map(x => 2 * x))); - java.lang.System.out.println(); - - java.lang.System.out.println("setx = " + setx); - java.lang.System.out.println("sety = " + sety); - java.lang.System.out.println("setx & sety = " + (setx.intersect(sety))); - java.lang.System.out.println("sety & setx = " + (sety.intersect(setx))); - java.lang.System.out.println("setx > 0 = " + (setx.filter(x => x > 0))); - java.lang.System.out.println("sety > 0 = " + (sety.filter(x => x > 0))); - java.lang.System.out.println("setx & sety = " + (setx.intersect2(sety))); - java.lang.System.out.println("sety & setx = " + (sety.intersect2(setx))); - java.lang.System.out.println(); + Console.println; + + Console.println("2 <- set2: " + (set2 contains 2)); + Console.println("3 <- set2: " + set2.contains(3)); + Console.println; + + Console.println("setx = " + setx); + Console.println("setx * 2 = " + (setx.map(x => 2 * x))); + Console.println; + + Console.println("setx = " + setx); + Console.println("sety = " + sety); + Console.println("setx & sety = " + (setx.intersect(sety))); + Console.println("sety & setx = " + (sety.intersect(setx))); + Console.println("setx > 0 = " + (setx.filter(x => x > 0))); + Console.println("sety > 0 = " + (sety.filter(x => x > 0))); + Console.println("setx & sety = " + (setx.intersect2(sety))); + Console.println("sety & setx = " + (sety.intersect2(setx))); + Console.println; } } @@ -364,10 +364,10 @@ object M9 { } def test = { - java.lang.System.out.println(new Rational(2,2).asString); - java.lang.System.out.println(new Rational(2,2).toString()); - java.lang.System.out.println(new Rational(2,2)); - java.lang.System.out.println(); + Console.println(new Rational(2,2).asString); + Console.println(new Rational(2,2).toString()); + Console.println(new Rational(2,2)); + Console.println; } } diff --git a/test/files/run/lisp.scala b/test/files/run/lisp.scala index e4a9cc652d..e44892d860 100644 --- a/test/files/run/lisp.scala +++ b/test/files/run/lisp.scala @@ -3,8 +3,6 @@ //############################################################################ // $Id$ -import java.lang.System; // to avoid name clash with .NET's library - //############################################################################ // Lisp Scanner @@ -150,15 +148,15 @@ object LispCaseClasses with Lisp { val prevexp = curexp; curexp = x; if (trace) { - for (val x <- range(1, indent)) System.out.print(" "); - System.out.println("===> " + x); + for (val 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)) System.out.print(" "); - System.out.println("<=== " + result); + for (val x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); } curexp = prevexp; result @@ -244,7 +242,7 @@ object LispCaseClasses with Lisp { if (token == "(") parseList else if (token == ")") error("unbalanced parentheses") else if ('0' <= token.charAt(0) && token.charAt(0) <= '9') - NUM(new java.lang.Integer(token).intValue()) + NUM(scala.runtime.compat.Platform.parseInt(token)) else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') STR(token.substring(1,token.length() - 1)) else SYM(token) @@ -301,7 +299,7 @@ object LispAny with Lisp { } def asString(x: Data): String = x match { - case y: java.lang.String => y + case y: String => y case _ => lispError("not a string: " + x) } @@ -331,15 +329,15 @@ object LispAny with Lisp { val prevexp = curexp; curexp = x; if (trace) { - for (val x <- range(1, indent)) System.out.print(" "); - System.out.println("===> " + x); + for (val 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)) System.out.print(" "); - System.out.println("<=== " + result); + for (val x <- range(1, indent)) Console.print(" "); + Console.println("<=== " + result); } curexp = prevexp; result @@ -435,7 +433,9 @@ object LispAny with Lisp { def parseExpr(token: String): Data = { if (token == "(") parseList else if (token == ")") error("unbalanced parentheses") - else if (Character.isDigit(token.charAt(0))) Integer.parseInt(token) + //else if (Character.isDigit(token.charAt(0))) + else if (scala.runtime.compat.Platform.isDigit(token.charAt(0))) + scala.runtime.compat.Platform.parseInt(token) else if (token.charAt(0) == '\"' && token.charAt(token.length()-1)=='\"') token.substring(1,token.length() - 1) else Symbol(token) @@ -459,30 +459,30 @@ class LispUser(lisp: Lisp) { def run = { - System.out.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[Object]); - System.out.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); - System.out.println(); + Console.println(string2lisp("(lambda (x) (+ (* x x) 1))").asInstanceOf[Object]); + Console.println(lisp2string(string2lisp("(lambda (x) (+ (* x x) 1))"))); + Console.println; - System.out.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); - System.out.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); - System.out.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); - System.out.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); - System.out.println("(null? '()) = " + evaluate("(null? (quote()))")); - System.out.println(); + Console.println("( '(1 2 3)) = " + evaluate(" (quote(1 2 3))")); + Console.println("(car '(1 2 3)) = " + evaluate("(car (quote(1 2 3)))")); + Console.println("(cdr '(1 2 3)) = " + evaluate("(cdr (quote(1 2 3)))")); + Console.println("(null? '(2 3)) = " + evaluate("(null? (quote(2 3)))")); + Console.println("(null? '()) = " + evaluate("(null? (quote()))")); + Console.println; - System.out.println("faculty(10) = " + evaluate( + Console.println("faculty(10) = " + evaluate( "(def (faculty n) " + "(if (= n 0) " + "1 " + "(* n (faculty (- n 1)))) " + "(faculty 10))")); - System.out.println("faculty(10) = " + evaluate( + Console.println("faculty(10) = " + evaluate( "(def (faculty n) " + "(cond " + "((= n 0) 1) " + "(else (* n (faculty (- n 1))))) " + "(faculty 10))")); - System.out.println("foobar = " + evaluate( + Console.println("foobar = " + evaluate( "(def (foo n) " + "(cond " + "((= n 0) \"a\")" + @@ -504,7 +504,7 @@ class LispUser(lisp: Lisp) { "(val v3 (+ (+ (foo 3) (foo 4)) (foo 5)) " + "(val v4 (foo 6) " + "(cons v1 (cons v2 (cons v3 (cons v4 nil))))))))))")); - System.out.println(); + Console.println; } } diff --git a/test/files/run/mixins.scala b/test/files/run/mixins.scala index 4fa23d3610..caab28fe26 100644 --- a/test/files/run/mixins.scala +++ b/test/files/run/mixins.scala @@ -2,8 +2,6 @@ // Test 1: "super" coming from mixins -import java.lang.System.out.println; - object Test1 { class A { def f = "A::f"; @@ -21,9 +19,9 @@ object Test1 { override def f = super[M1].f; } - def main(args: Array[String]): Unit = { + def test(): Unit = { val c = new C; - println(c.f); + Console.println(c.f); } } @@ -46,9 +44,9 @@ object Test2 { override def f = super[M1].f + " " + super[M2].f + " " + super[M3].f } - def main(args: Array[String]): Unit = { + def test(): Unit = { val h = new Host; - println(h.f) + Console.println(h.f) } } @@ -57,19 +55,19 @@ object Test2 { object Test3 { class A(x: Unit, y: Unit) { - println("A"); + Console.println("A"); } class B(x: Unit) { - println("B"); + Console.println("B"); } - class C with A({ println("one"); }, { println("two"); }) - with B({ println("three"); }) { - println("C"); + class C with A({ Console.println("one"); }, { Console.println("two"); }) + with B({ Console.println("three"); }) { + Console.println("C"); } - def main(args: Array[String]) = { + def test() = { val c = new C(); } } @@ -78,8 +76,8 @@ object Test3 { object Test { def main(args: Array[String]): Unit = { - Test1.main(args); - Test2.main(args); - Test3.main(args); + Test1.test(); + Test2.test(); + Test3.test(); } } -- cgit v1.2.3