From f10b65baef4e685cc70a5cf91cfe5cd4a7cefa20 Mon Sep 17 00:00:00 2001 From: schinz Date: Thu, 28 Aug 2003 09:08:36 +0000 Subject: *** empty log message *** --- test/files/run/constructors.check | 5 +++++ test/files/run/constructors.scala | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 test/files/run/constructors.check create mode 100644 test/files/run/constructors.scala (limited to 'test') diff --git a/test/files/run/constructors.check b/test/files/run/constructors.check new file mode 100644 index 0000000000..0743b7e296 --- /dev/null +++ b/test/files/run/constructors.check @@ -0,0 +1,5 @@ +x=1 y=2 +x=3 y=3 +x=1 y=1 +x=1 y=2 a=1 b=2 c=a +x=3 y=3 a=3 b=3 c=b 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); + } +} -- cgit v1.2.3