summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-04-30 13:49:22 +0000
committermichelou <michelou@epfl.ch>2007-04-30 13:49:22 +0000
commit7f27845c6d16c9dcc15cf90c780ac4fd596a4f4f (patch)
tree863365f5f67769fbc1619b6d9323275e2a501e3b /test
parent12a2b3b7ebd680b7a461209c505ccab82b86b66b (diff)
downloadscala-7f27845c6d16c9dcc15cf90c780ac4fd596a4f4f.tar.gz
scala-7f27845c6d16c9dcc15cf90c780ac4fd596a4f4f.tar.bz2
scala-7f27845c6d16c9dcc15cf90c780ac4fd596a4f4f.zip
fixed tests run/bridges.scala and jvm/inner.sca...
fixed tests run/bridges.scala and jvm/inner.scala on IBM J9
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/inner.scala29
-rw-r--r--test/files/run/fors.check18
-rw-r--r--test/files/run/fors.scala15
-rwxr-xr-xtest/scalatest14
4 files changed, 62 insertions, 14 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)
}
////////////////////////////////////////////////////
diff --git a/test/scalatest b/test/scalatest
index 54ba57fbca..d4cf45ae76 100755
--- a/test/scalatest
+++ b/test/scalatest
@@ -252,13 +252,22 @@ test_run_res() {
# Tests the JVM backend.
+# NB. property '-Djavacmd=$JAVACMD' is e.g used by jvm/inner.scala
test_run_jvm() {
+ javaopts=$JAVA_OPTS;
+ if [ -f "$os_srcbase".javaopts ]; then
+ javaopts="$javaopts `cat "$os_srcbase".javaopts`"
+ if [ "$JAVA5" = "false" ]; then
+ # -Xss option available in Java versions 1.5 or newer
+ javaopts=`echo "$javaopts" | sed -e "s/-Xss[0-9]*[MmKk]//g"`
+ fi
+ fi
rm -rf "$dstbase".obj &&
mkdir -p "$dstbase".obj &&
- $SCALAC -d "$os_dstbase".obj -cp "$JVM_EXT_CLASSPATH" "$@" "$os_srcbase".scala &&
+ env JAVACMD="$JAVACMD" JAVA_OPTS="$javaopts" $SCALAC -d "$os_dstbase".obj -cp "$JVM_EXT_CLASSPATH" "$@" "$os_srcbase".scala &&
scala_lib=`get_os_filename "$SCALA_LIB"` &&
classpath=`get_os_pathlist "$os_dstbase".obj:$CLASSPATH` &&
- $SCALA -Dscalatest.output=$os_dstbase.obj -Dscalatest.lib=$scala_lib -classpath $classpath:$JVM_EXT_CLASSPATH Test "jvm" &&
+ $SCALA -Djavacmd="$JAVACMD" -Dscalatest.output=$os_dstbase.obj -Dscalatest.lib=$scala_lib -classpath $classpath:$JVM_EXT_CLASSPATH Test "jvm" &&
rm -rf "$dstbase".obj;
}
@@ -620,6 +629,7 @@ SCALA_LIB="$LATEST_LIB";
[ -x "$JAVACMD" ] || JAVACMD=java;
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="-Xmx256M -Xms16M";
case `$JAVACMD \-version 2>&1 | xargs` in
+ *1.5.*IBM* ) JAVA5="true"; IBM_J9="true";;
*1.[5-7].* ) JAVA5="true";;
*1.4.*GNU* ) JAVA5="false"; GIJ="true"; JAVA_OPTS="--mx256m --ms16m";;
* ) JAVA5="false";;