From 7cd471c22306ba63836ab3b863a14e86d0813fd6 Mon Sep 17 00:00:00 2001 From: mihaylov Date: Tue, 10 Oct 2006 08:58:10 +0000 Subject: Moved Java-specific tests to test/files/jvm/ --- test/files/jvm/bigints.check | 5 ++ test/files/jvm/bigints.scala | 14 ++++++ test/files/jvm/inner.check | 7 +++ test/files/jvm/inner.scala | 105 +++++++++++++++++++++++++++++++++++++++++ test/files/run/bigints.check | 5 -- test/files/run/bigints.scala | 14 ------ test/files/run/implicits.scala | 0 test/files/run/inner.check | 7 --- test/files/run/inner.scala | 105 ----------------------------------------- 9 files changed, 131 insertions(+), 131 deletions(-) create mode 100644 test/files/jvm/bigints.check create mode 100644 test/files/jvm/bigints.scala create mode 100644 test/files/jvm/inner.check create mode 100644 test/files/jvm/inner.scala delete mode 100644 test/files/run/bigints.check delete mode 100644 test/files/run/bigints.scala mode change 100755 => 100644 test/files/run/implicits.scala delete mode 100644 test/files/run/inner.check delete mode 100644 test/files/run/inner.scala diff --git a/test/files/jvm/bigints.check b/test/files/jvm/bigints.check new file mode 100644 index 0000000000..fb50db6447 --- /dev/null +++ b/test/files/jvm/bigints.check @@ -0,0 +1,5 @@ +3 +true +false +true +true diff --git a/test/files/jvm/bigints.scala b/test/files/jvm/bigints.scala new file mode 100644 index 0000000000..f1328274c6 --- /dev/null +++ b/test/files/jvm/bigints.scala @@ -0,0 +1,14 @@ +object Test extends Application { + import BigInt._ + + val x: BigInt = 1 + val y = x + 1 + val z = 1 + y + System.out.println(z) + System.out.println(z <= 3) + System.out.println(3 < z) + System.out.println(z == 3) + System.out.println(3 == z) + +} + diff --git a/test/files/jvm/inner.check b/test/files/jvm/inner.check new file mode 100644 index 0000000000..230b1e2cdf --- /dev/null +++ b/test/files/jvm/inner.check @@ -0,0 +1,7 @@ +A.abc +1 +Hello +1 +1 +A.abc +Outer3: 1 2 3 diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala new file mode 100644 index 0000000000..08dd4c4857 --- /dev/null +++ b/test/files/jvm/inner.scala @@ -0,0 +1,105 @@ +//############################################################################ +// Test Java interaction with scala inner classes +//############################################################################ +// $Id$ + +import java.io.{BufferedReader, File, FileWriter, InputStreamReader} + +class A { + val abc = "A.abc" + + protected class B(x: Int, y: String) { + Console.println(abc); Console.println(x) + Console.println(y) + } + + trait Itf { + def method1(x: Int): Int + + trait Itf2 extends Itf { + def method2: Unit + } + } + + trait PlainTrait { + def method1(x: Int): Int + } + + class Impl(a: Int) extends Itf { + def method1(x: Int) = { + Console.println(x) + Console.println(a) + x + a + } + } + + class Impl2 extends Impl(1) with Itf#Itf2 { + def method2 = { + Console.println(abc) + } + } + + def newImpl: Itf = new Impl(1) + def newImpl2: Itf#Itf2 = new Impl2 + + class Outer1(arg1: Int) { + class Outer2(arg2: Int) { + class Outer3(arg3: Int) { + Console.println("Outer3: " + arg1 + " " + arg2 + " " + arg3); + } + } + } +} + +object Scalatest { + val outputdir = System.getProperty("scalatest.output", "inner-jvm.obj") + val scalalib = System.getProperty("scalatest.lib", "") + val classpath = outputdir + File.pathSeparator + scalalib + + def javac(src: String) = { + val tmpfilename = outputdir + File.separator + "tmpJavaInterraction.java" + val tmpfile = new FileWriter(tmpfilename) + tmpfile.write(src) + tmpfile.close + exec("javac -d " + outputdir + " -classpath " + classpath + " " + tmpfilename) + } + + /** Execute cmd, wait for the process to end and pipe it's output to stdout */ + def exec(cmd: String) = { + val proc = Runtime.getRuntime().exec(cmd); + val inp = new BufferedReader(new InputStreamReader(proc.getInputStream)) + val errp = new BufferedReader(new InputStreamReader(proc.getErrorStream)) + proc.waitFor() + while (inp.ready) Console.println(inp.readLine()) + while (errp.ready) Console.println(errp.readLine()) + } +} + + +object Test { + val program = """ +public class tmpJavaInterraction { + + public static void main(String[] args) { + A a = new A(); + A.B b = a.new B(1, "Hello"); + + A.Itf itf = a.newImpl(); + itf.method1(1); + + A.Itf.Itf2 itf2 = a.newImpl2(); + itf2.method2(); + + A.Outer1 o1 = a.new Outer1(1); + A.Outer1.Outer2 o2 = o1.new Outer2(2); + A.Outer1.Outer2.Outer3 or = o2.new Outer3(3); + } +} +""" + def main(args: Array[String]): Unit = { + Scalatest.javac(program) + Scalatest.exec("java -cp " + Scalatest.classpath + " tmpJavaInterraction") + } +} + +//############################################################################ diff --git a/test/files/run/bigints.check b/test/files/run/bigints.check deleted file mode 100644 index fb50db6447..0000000000 --- a/test/files/run/bigints.check +++ /dev/null @@ -1,5 +0,0 @@ -3 -true -false -true -true diff --git a/test/files/run/bigints.scala b/test/files/run/bigints.scala deleted file mode 100644 index f1328274c6..0000000000 --- a/test/files/run/bigints.scala +++ /dev/null @@ -1,14 +0,0 @@ -object Test extends Application { - import BigInt._ - - val x: BigInt = 1 - val y = x + 1 - val z = 1 + y - System.out.println(z) - System.out.println(z <= 3) - System.out.println(3 < z) - System.out.println(z == 3) - System.out.println(3 == z) - -} - diff --git a/test/files/run/implicits.scala b/test/files/run/implicits.scala old mode 100755 new mode 100644 diff --git a/test/files/run/inner.check b/test/files/run/inner.check deleted file mode 100644 index 230b1e2cdf..0000000000 --- a/test/files/run/inner.check +++ /dev/null @@ -1,7 +0,0 @@ -A.abc -1 -Hello -1 -1 -A.abc -Outer3: 1 2 3 diff --git a/test/files/run/inner.scala b/test/files/run/inner.scala deleted file mode 100644 index 08dd4c4857..0000000000 --- a/test/files/run/inner.scala +++ /dev/null @@ -1,105 +0,0 @@ -//############################################################################ -// Test Java interaction with scala inner classes -//############################################################################ -// $Id$ - -import java.io.{BufferedReader, File, FileWriter, InputStreamReader} - -class A { - val abc = "A.abc" - - protected class B(x: Int, y: String) { - Console.println(abc); Console.println(x) - Console.println(y) - } - - trait Itf { - def method1(x: Int): Int - - trait Itf2 extends Itf { - def method2: Unit - } - } - - trait PlainTrait { - def method1(x: Int): Int - } - - class Impl(a: Int) extends Itf { - def method1(x: Int) = { - Console.println(x) - Console.println(a) - x + a - } - } - - class Impl2 extends Impl(1) with Itf#Itf2 { - def method2 = { - Console.println(abc) - } - } - - def newImpl: Itf = new Impl(1) - def newImpl2: Itf#Itf2 = new Impl2 - - class Outer1(arg1: Int) { - class Outer2(arg2: Int) { - class Outer3(arg3: Int) { - Console.println("Outer3: " + arg1 + " " + arg2 + " " + arg3); - } - } - } -} - -object Scalatest { - val outputdir = System.getProperty("scalatest.output", "inner-jvm.obj") - val scalalib = System.getProperty("scalatest.lib", "") - val classpath = outputdir + File.pathSeparator + scalalib - - def javac(src: String) = { - val tmpfilename = outputdir + File.separator + "tmpJavaInterraction.java" - val tmpfile = new FileWriter(tmpfilename) - tmpfile.write(src) - tmpfile.close - exec("javac -d " + outputdir + " -classpath " + classpath + " " + tmpfilename) - } - - /** Execute cmd, wait for the process to end and pipe it's output to stdout */ - def exec(cmd: String) = { - val proc = Runtime.getRuntime().exec(cmd); - val inp = new BufferedReader(new InputStreamReader(proc.getInputStream)) - val errp = new BufferedReader(new InputStreamReader(proc.getErrorStream)) - proc.waitFor() - while (inp.ready) Console.println(inp.readLine()) - while (errp.ready) Console.println(errp.readLine()) - } -} - - -object Test { - val program = """ -public class tmpJavaInterraction { - - public static void main(String[] args) { - A a = new A(); - A.B b = a.new B(1, "Hello"); - - A.Itf itf = a.newImpl(); - itf.method1(1); - - A.Itf.Itf2 itf2 = a.newImpl2(); - itf2.method2(); - - A.Outer1 o1 = a.new Outer1(1); - A.Outer1.Outer2 o2 = o1.new Outer2(2); - A.Outer1.Outer2.Outer3 or = o2.new Outer3(3); - } -} -""" - def main(args: Array[String]): Unit = { - Scalatest.javac(program) - Scalatest.exec("java -cp " + Scalatest.classpath + " tmpJavaInterraction") - } -} - -//############################################################################ -- cgit v1.2.3