diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/jvm/inner.scala | 29 | ||||
-rw-r--r-- | test/files/run/fors.check | 18 | ||||
-rw-r--r-- | test/files/run/fors.scala | 15 |
3 files changed, 50 insertions, 12 deletions
diff --git a/test/files/jvm/inner.scala b/test/files/jvm/inner.scala index 08dd4c4857..a8da5164a5 100644 --- a/test/files/jvm/inner.scala +++ b/test/files/jvm/inner.scala @@ -52,21 +52,26 @@ class A { } 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" + private val outputdir = System.getProperty("scalatest.output", "inner-jvm.obj") + private val scalalib = System.getProperty("scalatest.lib", "") + private val classpath = outputdir + File.pathSeparator + scalalib + private val javacmd = System.getProperty("javacmd", "java") + private val javac = javacmd + "c" + + def javac(src: String, fname: String) { + val tmpfilename = outputdir + File.separator + fname val tmpfile = new FileWriter(tmpfilename) tmpfile.write(src) tmpfile.close - exec("javac -d " + outputdir + " -classpath " + classpath + " " + tmpfilename) + exec(javac + " -d " + outputdir + " -classpath " + classpath + " " + tmpfilename) } + def java(cname: String) = + exec(javacmd + " -cp " + classpath + " " + cname) + /** 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); + private 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() @@ -96,9 +101,9 @@ public class tmpJavaInterraction { } } """ - def main(args: Array[String]): Unit = { - Scalatest.javac(program) - Scalatest.exec("java -cp " + Scalatest.classpath + " tmpJavaInterraction") + def main(args: Array[String]) { + Scalatest.javac(program, "tmpJavaInterraction.java") + Scalatest.java("tmpJavaInterraction") } } diff --git a/test/files/run/fors.check b/test/files/run/fors.check index b459f00b49..08ecc8ed5f 100644 --- a/test/files/run/fors.check +++ b/test/files/run/fors.check @@ -13,6 +13,15 @@ a b c b c b c + +<head><title>Scala</title></head> + + +<body>1 2 3</body> + + +<head><title>Scala</title></head> + testNew 3 1 2 3 @@ -26,3 +35,12 @@ testNew 0 2 4 6 8 0 2 4 6 8 a b c + + +<head><title>Scala</title></head> + + +<body>1 2 3</body> + + +<head><title>Scala</title></head> diff --git a/test/files/run/fors.scala b/test/files/run/fors.scala index cd84649c15..7465b01287 100644 --- a/test/files/run/fors.scala +++ b/test/files/run/fors.scala @@ -13,6 +13,12 @@ object Test extends Application { val ar = "abc".toCharArray + val xml = + <html> + <head><title>Scala</title></head> + <body>{xs}</body> + </html>; + /////////////////// old syntax /////////////////// def testOld { @@ -42,6 +48,11 @@ object Test extends Application { x.toInt > 97) print(x + " "); println for {val x <- ar x.toInt > 97} print(x + " "); println + + // sequences + for (val x <- xml.child) println(x) + for (val x <- xml.child; + x.label == "head") println(x) } /////////////////// new syntax /////////////////// @@ -74,6 +85,10 @@ object Test extends Application { // arrays for (x <- ar) print(x + " "); println + + // sequences + for (x <- xml.child) println(x) + for (x <- xml.child if x.label == "head") println(x) } //////////////////////////////////////////////////// |