summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2005-10-04 15:47:43 +0000
committermihaylov <mihaylov@epfl.ch>2005-10-04 15:47:43 +0000
commit5c27a536494c66b8b06d25e889122fc0e73dd017 (patch)
tree8344b11928bc71730b1486b9384509e4c2a2299b
parent2f697bbee2bc2fe144e490fa9a3fa27ad9c9e2cd (diff)
downloadscala-5c27a536494c66b8b06d25e889122fc0e73dd017.tar.gz
scala-5c27a536494c66b8b06d25e889122fc0e73dd017.tar.bz2
scala-5c27a536494c66b8b06d25e889122fc0e73dd017.zip
Made platform-independant
-rw-r--r--test/files/run/Course-2002-06.check52
-rw-r--r--test/files/run/Course-2002-06.scala36
-rw-r--r--test/files/run/arrays.scala44
-rw-r--r--test/files/run/runtime.scala70
4 files changed, 102 insertions, 100 deletions
diff --git a/test/files/run/Course-2002-06.check b/test/files/run/Course-2002-06.check
index 46ca1a607d..bd354594af 100644
--- a/test/files/run/Course-2002-06.check
+++ b/test/files/run/Course-2002-06.check
@@ -1,38 +1,38 @@
%!PS-Adobe-3.0 EPSF-3.0
%%Title: ProgrammationIV
%%Creator: LAMP
-%%BoundingBox: 0 0 595.2755905511812 841.8897637795276
+%%BoundingBox: 0 0 595.28 841.89
%%EndComments
/m {moveto} bind def
/l {lineto} bind def
-0.14173228346456693 setlinewidth
+0.14 setlinewidth
newpath
-42.51968503937008 165.82677165354326 m 297.6377952755906 165.82677165354326 l
-297.6377952755906 165.82677165354326 m 297.6377952755906 505.98425196850394 l
-297.6377952755906 505.98425196850394 m 42.51968503937008 505.98425196850394 l
-42.51968503937008 505.98425196850394 m 170.07874015748033 676.0629921259844 l
-170.07874015748033 676.0629921259844 m 297.6377952755906 505.98425196850394 l
-297.6377952755906 505.98425196850394 m 42.51968503937008 165.82677165354326 l
-42.51968503937008 165.82677165354326 m 42.51968503937008 505.98425196850394 l
-42.51968503937008 505.98425196850394 m 297.6377952755906 165.82677165354326 l
-297.6377952755906 165.82677165354326 m 425.19685039370086 165.82677165354326 l
-425.19685039370086 165.82677165354326 m 425.19685039370086 505.98425196850394 l
-425.19685039370086 505.98425196850394 m 297.6377952755906 505.98425196850394 l
-297.6377952755906 505.98425196850394 m 361.4173228346457 676.0629921259844 l
-361.4173228346457 676.0629921259844 m 425.19685039370086 505.98425196850394 l
-425.19685039370086 505.98425196850394 m 297.6377952755906 165.82677165354326 l
-297.6377952755906 165.82677165354326 m 297.6377952755906 505.98425196850394 l
-297.6377952755906 505.98425196850394 m 425.19685039370086 165.82677165354326 l
-425.19685039370086 676.0629921259844 m 552.7559055118111 676.0629921259844 l
-552.7559055118111 676.0629921259844 m 552.7559055118111 335.90551181102364 l
-552.7559055118111 335.90551181102364 m 425.19685039370086 335.90551181102364 l
-425.19685039370086 335.90551181102364 m 488.97637795275597 165.82677165354326 l
-488.97637795275597 165.82677165354326 m 552.7559055118111 335.90551181102364 l
-552.7559055118111 335.90551181102364 m 425.19685039370086 676.0629921259844 l
-425.19685039370086 676.0629921259844 m 425.19685039370086 335.90551181102364 l
-425.19685039370086 335.90551181102364 m 552.7559055118111 676.0629921259844 l
+42.52 165.83 m 297.64 165.83 l
+297.64 165.83 m 297.64 505.99 l
+297.64 505.99 m 42.52 505.99 l
+42.52 505.99 m 170.08 676.07 l
+170.08 676.07 m 297.64 505.99 l
+297.64 505.99 m 42.52 165.83 l
+42.52 165.83 m 42.52 505.99 l
+42.52 505.99 m 297.64 165.83 l
+297.64 165.83 m 425.2 165.83 l
+425.2 165.83 m 425.2 505.99 l
+425.2 505.99 m 297.64 505.99 l
+297.64 505.99 m 361.42 676.07 l
+361.42 676.07 m 425.2 505.99 l
+425.2 505.99 m 297.64 165.83 l
+297.64 165.83 m 297.64 505.99 l
+297.64 505.99 m 425.2 165.83 l
+425.2 676.07 m 552.76 676.07 l
+552.76 676.07 m 552.76 335.91 l
+552.76 335.91 m 425.2 335.91 l
+425.2 335.91 m 488.98 165.83 l
+488.98 165.83 m 552.76 335.91 l
+552.76 335.91 m 425.2 676.07 l
+425.2 676.07 m 425.2 335.91 l
+425.2 335.91 m 552.76 676.07 l
stroke
showpage
%%EOF
diff --git a/test/files/run/Course-2002-06.scala b/test/files/run/Course-2002-06.scala
index a1218429c2..ca816eda06 100644
--- a/test/files/run/Course-2002-06.scala
+++ b/test/files/run/Course-2002-06.scala
@@ -11,7 +11,7 @@ class Vector (_x: Double, _y: Double) {
def *(scalar: Double): Vector = new Vector(x * scalar, y * scalar);
def -(that: Vector): Vector = new Vector(x - that.x, y - that.y);
def /(scalar: Double): Vector = new Vector(x / scalar, y / scalar);
- def norm: Double = java.lang.Math.sqrt(x * x + y * y);
+ def norm: Double = scala.runtime.compat.Math.sqrt(x * x + y * y);
}
//############################################################################
@@ -85,7 +85,10 @@ abstract class Graphics(_width: Double, _height: Double) {
class PostScript (filename: String, _width: Double, _height: Double)
extends Graphics(_width, _height) {
/** Convert mm into 72th of inch.*/
- def mm2ps(x: Double) : Double = x * 72.0 / 25.4;
+ def mm2ps(x: Double) : Double = round(x * 72.0 / 25.4);
+
+ def round(x: Double): Double =
+ scala.runtime.compat.Math.floor(x * 100.0 + 0.5) / 100.0;
def scaleAndCenter(frm: Frame, ratio:Double): Frame = {
val currentRatio = frm.edgeX.norm / frm.edgeY.norm;
@@ -119,28 +122,29 @@ class PostScript (filename: String, _width: Double, _height: Double)
scaleAndCenter(new Frame(origin, edgeX, edgeY), width / height)
}
- /** File where to print.*/
- import java.io._;
- val out : PrintStream = new PrintStream(
- if (filename == "-") java.lang.System.out
- else new FileOutputStream(filename));
+// /** File where to print.*/
+// import java.io._;
+// val out : PrintStream = new PrintStream(
+// if (filename == "-") java.lang.System.out
+// else new FileOutputStream(filename));
def plotLine(x1: Double, y1: Double, x2: Double, y2: Double): Unit = {
- out.println(x1 + " " + y1 + " m " + x2 + " " + y2 + " l");
+ Console.println(round(x1) + " " + round(y1) + " m " +
+ round(x2) + " " + round(y2) + " l");
}
/** Print the PS header.*/
- out.println("%!PS-Adobe-3.0 EPSF-3.0\n%%Title: ProgrammationIV");
- out.println("%%Creator: LAMP");
- out.println("%%BoundingBox: 0 0 " + mm2ps(psWidth) + " " + mm2ps(psHeight));
- out.println("%%EndComments\n");
- out.println("/m {moveto} bind def\n/l {lineto} bind def\n");
- out.println(mm2ps(line_thickness) + " setlinewidth\nnewpath");
+ Console.println("%!PS-Adobe-3.0 EPSF-3.0\n%%Title: ProgrammationIV");
+ Console.println("%%Creator: LAMP");
+ Console.println("%%BoundingBox: 0 0 " + mm2ps(psWidth) + " " + mm2ps(psHeight));
+ Console.println("%%EndComments\n");
+ Console.println("/m {moveto} bind def\n/l {lineto} bind def\n");
+ Console.println(mm2ps(line_thickness) + " setlinewidth\nnewpath");
/** Terminate the PS document and close the file stream. */
def close : Unit = {
- out.println("stroke\nshowpage\n%%EOF");
- out.close();
+ Console.println("stroke\nshowpage\n%%EOF");
+ Console.flush;
}
}
diff --git a/test/files/run/arrays.scala b/test/files/run/arrays.scala
index 687b4c1a57..9e9c3c065b 100644
--- a/test/files/run/arrays.scala
+++ b/test/files/run/arrays.scala
@@ -5,17 +5,15 @@
//############################################################################
-import java.lang.System; // to avoid name clash with .NET's library
-
object Test {
//##########################################################################
// Types
type Strings = List[String];
- type Map = java.util.Map;
- type HashMap = java.util.HashMap;
- type TreeMap = java.util.TreeMap;
+ type Map = scala.collection.Map[Int, Any];
+ type HashMap = scala.collection.mutable.HashMap[Int, Any];
+ type TreeMap = scala.collection.immutable.TreeMap[Int, Any];
//##########################################################################
// Identity Functions
@@ -110,7 +108,7 @@ object Test {
val s1 = if (test1) "ok" else "KO";
val s2 = actual.toString();
val s3 = expected.toString();
- throw new Error(s0 + " - " + s1 + ": " + s2 + " != " + s3);
+ error(s0 + " - " + s1 + ": " + s2 + " != " + s3);
}
checks = checks + 1;
}
@@ -164,39 +162,41 @@ object Test {
//##########################################################################
// Values
+ import scala.runtime.compat.Math._;
+
val u0: Unit = ();
val u1: Unit = ();
val z0: Boolean = false;
val z1: Boolean = true;
- val b0: Byte = java.lang.Byte.MIN_VALUE;
+ val b0: Byte = MIN_BYTE;
val b1: Byte = 1;
- val b2: Byte = java.lang.Byte.MAX_VALUE;
+ val b2: Byte = MAX_BYTE;
- val s0: Short = java.lang.Short.MIN_VALUE;
+ val s0: Short = MIN_SHORT;
val s1: Short = 2;
- val s2: Short = java.lang.Short.MAX_VALUE;
+ val s2: Short = MAX_SHORT;
- val c0: Char = java.lang.Character.MIN_VALUE;
+ val c0: Char = MIN_CHAR;
val c1: Char = '3';
- val c2: Char = java.lang.Character.MAX_VALUE;
+ val c2: Char = MAX_CHAR;
- val i0: Int = java.lang.Integer.MIN_VALUE;
+ val i0: Int = MIN_INT;
val i1: Int = 4;
- val i2: Int = java.lang.Integer.MAX_VALUE;
+ val i2: Int = MAX_INT;
- val l0: Long = java.lang.Long.MIN_VALUE;
+ val l0: Long = MIN_LONG;
val l1: Int = 5;
- val l2: Long = java.lang.Long.MAX_VALUE;
+ val l2: Long = MAX_LONG;
- val f0: Float = java.lang.Float.MIN_VALUE;
+ val f0: Float = MIN_FLOAT;
val f1: Int = 6;
- val f2: Float = java.lang.Float.MAX_VALUE;
+ val f2: Float = MAX_FLOAT;
- val d0: Double = java.lang.Double.MIN_VALUE;
+ val d0: Double = MIN_DOUBLE;
val d1: Int = 7;
- val d2: Double = java.lang.Double.MAX_VALUE;
+ val d2: Double = MAX_DOUBLE;
val a0: Unit = ();
val a1: Boolean = false;
@@ -205,7 +205,7 @@ object Test {
val a4: String = "a-z";
val a5: Symbol = 'token;
val a6: HashMap = new HashMap();
- val a7: TreeMap = new TreeMap();
+ val a7: TreeMap = scala.collection.immutable.TreeMap.Empty;
val a8: Strings = List("a", "z");
val v0: Unit = ();
@@ -903,7 +903,7 @@ object Test {
//######################################################################
- System.out.println("checks: " + checks);
+ Console.println("checks: " + checks);
//######################################################################
}
diff --git a/test/files/run/runtime.scala b/test/files/run/runtime.scala
index 64f78db7c6..dac00a46ef 100644
--- a/test/files/run/runtime.scala
+++ b/test/files/run/runtime.scala
@@ -3,8 +3,6 @@
//############################################################################
// $Id$
-import java.lang.System; // to avoid name clash with .NET's library
-
//############################################################################
// serves as an entry point with the MSIL backend
@@ -20,14 +18,14 @@ object TestMain {
object Test0Test {
def println[A](xs: Array[A]): Unit = {
var i = 0;
- System.out.print("[");
+ Console.print("[");
while (i < xs.length) {
- if (i > 0) System.out.print(",");
- System.out.print(xs(i));
+ if (i > 0) Console.print(",");
+ Console.print(xs(i));
i = i + 1;
}
- System.out.print("]");
- System.out.println();
+ Console.print("]");
+ Console.println;
}
def main(args: Array[String]): Unit = {
@@ -63,7 +61,7 @@ package test1.bar {
class PrintStream() {
def println(): Unit = {
- java.lang.System.out.println();
+ Console.println;
}
}
@@ -72,21 +70,21 @@ package test1.bar {
object Test1Test {
def main(args: Array[String]): Unit = {
- {System.out.print(10)}; java.lang.System.out.println();
+ {Console.print(10)}; Console.println;
// {System.out.print(11); java}.lang.System.out.println();
// {System.out.print(12); java.lang}.System.out.println();
// {System.out.print(13); java.lang.System}.out.println();
- {System.out.print(14); java.lang.System.out}.println();
- {System.out.print(15); java.lang.System.out.println:(() => Unit)}();
- {System.out.print(16); java.lang.System.out.println()};
+ {Console.print(14); Console}.println;
+ {Console.print(15); (() => Console.println):(() => Unit)}();
+ {Console.print(16); Console.println};
- {System.out.print(20)}; test1.bar.System.out.println();
+ {Console.print(20)}; test1.bar.System.out.println();
// {System.out.print(21); test1}.bar.System.out.println();
// {System.out.print(22); test1.bar}.System.out.println();
- {System.out.print(23); test1.bar.System}.out.println();
- {System.out.print(24); test1.bar.System.out}.println();
- {System.out.print(25); test1.bar.System.out.println:(() => Unit)}();
- {System.out.print(26); test1.bar.System.out.println()};
+ {Console.print(23); test1.bar.System}.out.println();
+ {Console.print(24); test1.bar.System.out}.println();
+ {Console.print(25); test1.bar.System.out.println:(() => Unit)}();
+ {Console.print(26); test1.bar.System.out.println()};
}
}
@@ -97,23 +95,23 @@ object Test1Test {
package test2 {
class A {
- def run = System.out.println("A");
+ def run = Console.println("A");
}
class M0 extends A {
- override def run = { super.run; System.out.println("M0"); }
+ override def run = { super.run; Console.println("M0"); }
}
class M1 extends M0 {
- override def run = { super.run; System.out.println("M1"); }
+ override def run = { super.run; Console.println("M1"); }
}
class N0 extends A {
- override def run = { super.run; System.out.println("N0"); }
+ override def run = { super.run; Console.println("N0"); }
}
class N1 extends N0 {
- override def run = { super.run; System.out.println("N1"); }
+ override def run = { super.run; Console.println("N1"); }
}
object M0N0 extends M0 with N0;
@@ -125,10 +123,10 @@ package test2 {
object Test2Test {
def main(args: Array[String]): Unit = {
- test2.M0N0.run; System.out.println();
- test2.N0M0.run; System.out.println();
- test2.M1N0.run; System.out.println();
- test2.N1M0.run; System.out.println();
+ test2.M0N0.run; Console.println;
+ test2.N0M0.run; Console.println;
+ test2.M1N0.run; Console.println;
+ test2.N1M0.run; Console.println;
}
}
@@ -137,10 +135,10 @@ object Test2Test {
object Test3Test {
- class Foo { override def equals(that: Any) = throw new Error("abort"); }
+ class Foo { override def equals(that: Any) = error("abort"); }
def check(expected: Boolean, actual1: Boolean, actual2: Boolean): Unit =
- System.out.println(
+ Console.println(
if ((actual1 == expected) && (actual2 == !expected)) "Ok" else "KO: "
+ "expected: " + expected + " - " + (!expected) + ", "
+ "found: " + actual1 + " - " + actual1);
@@ -179,19 +177,19 @@ object Test3Test {
object Test {
var errors: Int = 0;
def test(name: String, test: => Unit): Unit = {
- System.out.println("<<< " + name);
+ Console.println("<<< " + name);
try {
test;
} catch {
case exception => {
- val name: String = Thread.currentThread().getName();
- System.out.print("Exception in thread \"" + name + "\" " + exception);
- System.out.println();
+ //val name: String = Thread.currentThread().getName();
+ Console.print("Exception in thread \"" + name + "\" " + exception);
+ Console.println;
errors = errors + 1;
}
}
- System.out.println(">>> " + name);
- System.out.println();
+ Console.println(">>> " + name);
+ Console.println;
}
def main(args: Array[String]): Unit = {
@@ -202,8 +200,8 @@ object Test {
test("Test3" , Test3Test.main(args));
if (errors > 0) {
- System.out.println();
- System.out.println(errors + " error" + (if (errors > 1) "s" else ""));
+ Console.println;
+ Console.println(errors + " error" + (if (errors > 1) "s" else ""));
}
}
}