From 4308d3971bc031afcd31a9b4c78b3b06ec80242f Mon Sep 17 00:00:00 2001 From: mihaylov Date: Wed, 5 Jul 2006 12:36:25 +0000 Subject: Created a directory test/files/jvm5/ for test c... Created a directory test/files/jvm5/ for test cases that run only on JVM 1.5 --- test/files/jvm5/attributes.check | 2 + test/files/jvm5/attributes.scala | 85 ++++++++++++++++++++++++++++++++++++++++ test/files/run/attributes.check | 2 - test/files/run/attributes.scala | 85 ---------------------------------------- test/scalatest | 19 ++++++++- 5 files changed, 105 insertions(+), 88 deletions(-) create mode 100644 test/files/jvm5/attributes.check create mode 100644 test/files/jvm5/attributes.scala delete mode 100644 test/files/run/attributes.check delete mode 100644 test/files/run/attributes.scala diff --git a/test/files/jvm5/attributes.check b/test/files/jvm5/attributes.check new file mode 100644 index 0000000000..2793231eac --- /dev/null +++ b/test/files/jvm5/attributes.check @@ -0,0 +1,2 @@ +class java.rmi.RemoteException +class java.io.IOException diff --git a/test/files/jvm5/attributes.scala b/test/files/jvm5/attributes.scala new file mode 100644 index 0000000000..051355a947 --- /dev/null +++ b/test/files/jvm5/attributes.scala @@ -0,0 +1,85 @@ +object Test1 { + class Foo { + [remote] + def foo: Unit = () + } + def run: Unit = { + val method = classOf[Foo].getMethod("foo", Array()) + method.getExceptionTypes foreach Console.println + } +} + +object Test2 { + import java.io._ + class Reader(fname: String) { + private val in = new BufferedReader(new FileReader(fname)) + [throws(classOf[IOException])] + def read() = in.read() + } + def run: Unit = { + val method = classOf[Reader].getMethod("read", Array()) + method.getExceptionTypes foreach Console.println + } +} + +/* Java: +public class Main { + @Deprecated + public void foo() {} + public static void main(String[] args) throws Exception { + Method method = Class.forName("test.Main").getMethod("foo", new Class[]{}); + Annotation annotation = method.getAnnotation(Deprecated.class); + System.out.println(annotation); // @java.lang.Deprecated() + } +} +*/ +object Test3 { + class Foo { + [Deprecated] + def foo: Unit = () + } + def run: Unit = { + val method = classOf[Foo].getMethod("foo", Array()) + val annotation = method.getAnnotation(classOf[Deprecated]) + Console.println(annotation) + } +} + +/* Java: +@Retention(value=RetentionPolicy.RUNTIME) +@interface Source { + public String url(); + public String mail(); +} +@Source(url="http://scala.epfl.ch", mail="scala@lists.epfl.ch") +class Foo {} +public class Main { + public static void main(String[] args) throws Exception { + Class clazz = Class.forName("test.Foo"); + Annotation[] annotations = clazz.getAnnotations(); + for (int i = 0; i < annotations.length; i++) + System.out.println(annotations[i]); + // @test.Main$Source(url=http://scala.epfl.ch, mail=scala@lists.epfl.ch) + } +} +*/ +object Test4 { + import java.lang.annotation._ + [Retention(RetentionPolicy.RUNTIME)] + class Source(url: String, mail: String) extends Attribute + [Source("http://scala.epfl.ch", "scala@lists.epfl.ch")] + class Foo + def run: Unit = { + val clazz = classOf[Foo] + clazz.getAnnotations foreach Console.println + } +} + +object Test { + def main(args: Array[String]): Unit = { + Test1.run + Test2.run + //Test3.run // requires the use of -target:jvm-1.5 + //Test4.run + } +} diff --git a/test/files/run/attributes.check b/test/files/run/attributes.check deleted file mode 100644 index 2793231eac..0000000000 --- a/test/files/run/attributes.check +++ /dev/null @@ -1,2 +0,0 @@ -class java.rmi.RemoteException -class java.io.IOException diff --git a/test/files/run/attributes.scala b/test/files/run/attributes.scala deleted file mode 100644 index 051355a947..0000000000 --- a/test/files/run/attributes.scala +++ /dev/null @@ -1,85 +0,0 @@ -object Test1 { - class Foo { - [remote] - def foo: Unit = () - } - def run: Unit = { - val method = classOf[Foo].getMethod("foo", Array()) - method.getExceptionTypes foreach Console.println - } -} - -object Test2 { - import java.io._ - class Reader(fname: String) { - private val in = new BufferedReader(new FileReader(fname)) - [throws(classOf[IOException])] - def read() = in.read() - } - def run: Unit = { - val method = classOf[Reader].getMethod("read", Array()) - method.getExceptionTypes foreach Console.println - } -} - -/* Java: -public class Main { - @Deprecated - public void foo() {} - public static void main(String[] args) throws Exception { - Method method = Class.forName("test.Main").getMethod("foo", new Class[]{}); - Annotation annotation = method.getAnnotation(Deprecated.class); - System.out.println(annotation); // @java.lang.Deprecated() - } -} -*/ -object Test3 { - class Foo { - [Deprecated] - def foo: Unit = () - } - def run: Unit = { - val method = classOf[Foo].getMethod("foo", Array()) - val annotation = method.getAnnotation(classOf[Deprecated]) - Console.println(annotation) - } -} - -/* Java: -@Retention(value=RetentionPolicy.RUNTIME) -@interface Source { - public String url(); - public String mail(); -} -@Source(url="http://scala.epfl.ch", mail="scala@lists.epfl.ch") -class Foo {} -public class Main { - public static void main(String[] args) throws Exception { - Class clazz = Class.forName("test.Foo"); - Annotation[] annotations = clazz.getAnnotations(); - for (int i = 0; i < annotations.length; i++) - System.out.println(annotations[i]); - // @test.Main$Source(url=http://scala.epfl.ch, mail=scala@lists.epfl.ch) - } -} -*/ -object Test4 { - import java.lang.annotation._ - [Retention(RetentionPolicy.RUNTIME)] - class Source(url: String, mail: String) extends Attribute - [Source("http://scala.epfl.ch", "scala@lists.epfl.ch")] - class Foo - def run: Unit = { - val clazz = classOf[Foo] - clazz.getAnnotations foreach Console.println - } -} - -object Test { - def main(args: Array[String]): Unit = { - Test1.run - Test2.run - //Test3.run // requires the use of -target:jvm-1.5 - //Test4.run - } -} diff --git a/test/scalatest b/test/scalatest index 77c6cdb289..74f934a920 100755 --- a/test/scalatest +++ b/test/scalatest @@ -421,6 +421,10 @@ test_add_file() { esac; case "$1" in run | */run | */run/* | run/* ) FILES_RUN="$FILES_RUN $1";; + jvm5 | */jvm5 | */jvm5* | jvm5/* ) + if [ "$JAVA5" = "true" ]; then + FILES_JVM="$FILES_JVM $1" + fi;; jvm | */jvm | */jvm/* | jvm/* ) FILES_JVM="$FILES_JVM $1";; pos | */pos | */pos/* | pos/* ) FILES_POS="$FILES_POS $1";; neg | */neg | */neg/* | neg/* ) FILES_NEG="$FILES_NEG $1";; @@ -511,6 +515,11 @@ fi; BIN_DIR="$LATEST/" # BIN_DIR should have a trailing / when needed, so that # it can also be set to the empty string +case `${JAVACMD:=java} \-version 2>&1 | head -1` in + *1.5*) JAVA5="true";; + *) JAVA5="false";; +esac; + DIFF="diff"; case `uname` in @@ -549,6 +558,10 @@ while [ $# -gt 0 ]; do esac; done; +if [ "$JAVA5" = "true" ]; then + FLAGS="$FLAGS -target:jvm-1.5" +fi; + if [ -z "$ERRORS" ]; then abort "illegal non-numerical argument for option --errors"; fi; @@ -563,7 +576,11 @@ if [ "$TEST_ALL" = "true" ]; then run ) FILES_RUN="$FILES_RUN $SRCDIR/run";; esac; case "$TEST_TYPE" in - auto | jvm ) FILES_JVM="$FILES_JVM $SRCDIR/run $SRCDIR/jvm";; + auto | jvm ) + FILES_JVM="$FILES_JVM $SRCDIR/run $SRCDIR/jvm" + if [ "$JAVA5" = "true" ]; then + FILES_JVM="$FILES_JVM $SRCDIR/jvm5"; + fi;; esac; case "$TEST_TYPE" in auto | pos ) FILES_POS="$FILES_POS $SRCDIR/pos";; -- cgit v1.2.3