summaryrefslogtreecommitdiff
path: root/test/files/run/constructors.scala
diff options
context:
space:
mode:
authorschinz <schinz@epfl.ch>2003-08-28 09:08:36 +0000
committerschinz <schinz@epfl.ch>2003-08-28 09:08:36 +0000
commitf10b65baef4e685cc70a5cf91cfe5cd4a7cefa20 (patch)
treedc8da323313b3b2f8c60ea1fe7c0f81df05e180e /test/files/run/constructors.scala
parent4409444f4994d1337f78484f0a0e5dc593f013fc (diff)
downloadscala-f10b65baef4e685cc70a5cf91cfe5cd4a7cefa20.tar.gz
scala-f10b65baef4e685cc70a5cf91cfe5cd4a7cefa20.tar.bz2
scala-f10b65baef4e685cc70a5cf91cfe5cd4a7cefa20.zip
*** empty log message ***
Diffstat (limited to 'test/files/run/constructors.scala')
-rw-r--r--test/files/run/constructors.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/files/run/constructors.scala b/test/files/run/constructors.scala
new file mode 100644
index 0000000000..43d2da6af8
--- /dev/null
+++ b/test/files/run/constructors.scala
@@ -0,0 +1,29 @@
+// $Id$
+
+// Test constructors, including multiple ones.
+
+class A(x: Int, y: Int) {
+ def this(x: Int) = this(x, x);
+ def this() = this(1);
+ override def toString() = "x=" + x + " y=" + y;
+ class B(a: Int, b: Int, c: String) {
+ def this(str: String) = this(x, y, str);
+ override def toString() =
+ "x=" + x + " y=" + y + " a=" + a + " b=" + b + " c=" + c;
+ }
+}
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ val a1 = new A(1,2);
+ val a2 = new A(3);
+ val a3 = new A();
+ val b1 = new a1.B(1,2,"a");
+ val b2 = new a2.B("b");
+ System.out.println(a1);
+ System.out.println(a2);
+ System.out.println(a3);
+ System.out.println(b1);
+ System.out.println(b2);
+ }
+}