summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2003-08-12 12:29:22 +0000
committermichelou <michelou@epfl.ch>2003-08-12 12:29:22 +0000
commitda74821b08ed3d0e08b3056792bf526a8b27b031 (patch)
tree0645fc522fbc283fa626f501ce1e076b9397a4e1 /test
parent562f1f62e3a7db5efe14353f56ba816805907b7d (diff)
downloadscala-da74821b08ed3d0e08b3056792bf526a8b27b031.tar.gz
scala-da74821b08ed3d0e08b3056792bf526a8b27b031.tar.bz2
scala-da74821b08ed3d0e08b3056792bf526a8b27b031.zip
*** empty log message ***
Diffstat (limited to 'test')
-rw-r--r--test/files/run/overloads.check4
-rw-r--r--test/files/run/overloads.scala52
2 files changed, 56 insertions, 0 deletions
diff --git a/test/files/run/overloads.check b/test/files/run/overloads.check
new file mode 100644
index 0000000000..8cc9475ff3
--- /dev/null
+++ b/test/files/run/overloads.check
@@ -0,0 +1,4 @@
+ok: M1.f(3) = 11
+ok: M2.f(3) = 22
+ok: M1.f(Stack()) = 12
+ok: M2.f(Stack()) = 21
diff --git a/test/files/run/overloads.scala b/test/files/run/overloads.scala
new file mode 100644
index 0000000000..461633ce67
--- /dev/null
+++ b/test/files/run/overloads.scala
@@ -0,0 +1,52 @@
+//############################################################################
+// Overloads
+//############################################################################
+// $Id$
+
+//############################################################################
+
+object M1 {
+ def f[A](x: A) = 11;
+ def f[A <: StructuralEquality[A]](x: A) = 12;
+}
+
+object M2 {
+ def f[A <: StructuralEquality[A]](x: A) = 21;
+ def f[A](x: A) = 22;
+}
+
+object overloads {
+
+ def check(what: String, actual: Any, expected: Any): Unit = {
+ val success: Boolean = actual == expected;
+ System.out.print(if (success) "ok" else "KO");
+ var value: String = if (actual == null) "null" else actual.toString();
+ if (value == "\u0000") value = "\\u0000";
+ System.out.print(": " + what + " = " + value);
+ if (!success) System.out.print(" != " + expected);
+ System.out.println();
+ System.out.flush();
+ }
+
+ def test: Unit = {
+ val x = 3;
+ check("M1.f(" + x +")", M1.f(x), 11);
+ check("M2.f(" + x +")", M2.f(x), 22);
+ val y = new scala.collection.mutable.Stack[Int];
+ check("M1.f(" + y +")", M1.f(y), 12);
+ check("M2.f(" + y +")", M2.f(y), 21);
+ }
+
+}
+
+//############################################################################
+
+object Test {
+
+ def main(args: Array[String]): Unit = {
+ overloads.test;
+ }
+
+}
+
+//############################################################################