From 10830eaae2955766378369b8d1bcc0e6963b9b7f Mon Sep 17 00:00:00 2001 From: Antonio Cunei Date: Fri, 15 May 2009 15:44:54 +0000 Subject: 1.4-related cleanup and reorganization. Removed a bunch of now useless 1.4 code, merged back jvm5-specific partest tests into the general jvm tests, documentation updates. --- test/pending/jvm/annotations.scala | 159 ++++++++++++++++++++++++++++++++++++ test/pending/jvm/t1464.check | 1 + test/pending/jvm5/annotations.scala | 159 ------------------------------------ test/pending/jvm5/t1464.check | 1 - test/pending/pos/misc/A.java | 13 +++ test/pending/pos/misc/B.scala | 7 ++ test/pending/pos/misc/J.java | 4 + test/pending/pos/misc/S.scala | 4 + test/pending/pos/t1745/J.java | 10 +++ test/pending/pos/t1745/S.scala | 7 ++ test/pending/pos5/misc/A.java | 13 --- test/pending/pos5/misc/B.scala | 7 -- test/pending/pos5/misc/J.java | 4 - test/pending/pos5/misc/S.scala | 4 - test/pending/pos5/t1745/J.java | 10 --- test/pending/pos5/t1745/S.scala | 7 -- 16 files changed, 205 insertions(+), 205 deletions(-) create mode 100644 test/pending/jvm/annotations.scala create mode 100644 test/pending/jvm/t1464.check delete mode 100644 test/pending/jvm5/annotations.scala delete mode 100644 test/pending/jvm5/t1464.check create mode 100644 test/pending/pos/misc/A.java create mode 100644 test/pending/pos/misc/B.scala create mode 100644 test/pending/pos/misc/J.java create mode 100644 test/pending/pos/misc/S.scala create mode 100644 test/pending/pos/t1745/J.java create mode 100644 test/pending/pos/t1745/S.scala delete mode 100644 test/pending/pos5/misc/A.java delete mode 100644 test/pending/pos5/misc/B.scala delete mode 100644 test/pending/pos5/misc/J.java delete mode 100644 test/pending/pos5/misc/S.scala delete mode 100644 test/pending/pos5/t1745/J.java delete mode 100644 test/pending/pos5/t1745/S.scala (limited to 'test/pending') diff --git a/test/pending/jvm/annotations.scala b/test/pending/jvm/annotations.scala new file mode 100644 index 0000000000..98b82edad4 --- /dev/null +++ b/test/pending/jvm/annotations.scala @@ -0,0 +1,159 @@ +object Test1 { + class Foo { + @remote + def foo: Unit = () + } + def run { + val method = classOf[Foo].getMethod("foo", Array()) + method.getExceptionTypes foreach println + } +} + +object Test2 { + import java.io.{BufferedReader,FileReader, IOException} + class Reader(fname: String) { + private val in = new BufferedReader(new FileReader(fname)) + + @throws(classOf[IOException]) + def read() = in.read() + } + def run { + val method = classOf[Reader].getMethod("read", Array()) + method.getExceptionTypes foreach 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 { + import java.lang.Deprecated + class Foo { + @Deprecated + def foo: Unit = () + } + def run { + val method = classOf[Foo].getMethod("foo", Array()) + val annotation = method.getAnnotation(classOf[Deprecated]) + 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-lang.org, mail=scala@lists.epfl.ch) + } +} +*/ +object Test4 { + import test.SourceAnnotation // defined in SourceAnnotation.java + @SourceAnnotation{val value = "http://scala-lang.org", + val mails = Array("scala@lists.epfl.ch", "scala-lounge@lists.epfl.ch")} + class Foo1 + @SourceAnnotation("http://bloodsuckers.com") { val mails = Array("you@bloodsuckers.com") } + class Foo2 + @SourceAnnotation("http://bloodsuckers.com") + class Foo3 + class Foo4 { + @SourceAnnotation("file:///dev/null") + val x = 1 + } + class Foo5 { + @SourceAnnotation("file:///dev/zero") + def bar: Int = 0 + } + class Foo6 @SourceAnnotation("primary constructor")(s: String) { + // to guarantee that primary constructor annotations + // are not applied to secondary constructors + def this() = this("") + } + class Foo7(s: String) { + @SourceAnnotation("secondary constructor") + def this() = this("") + } + class Foo8(@SourceAnnotation("constructor val") val n: Int) {} + def run { + import java.lang.annotation.Annotation + import java.lang.reflect.AnnotatedElement + def printSourceAnnotations(target: AnnotatedElement) { + //print SourceAnnotation in a predefined way to insure + // against difference in the JVMs (e.g. Sun's vs IBM's) + def printSourceAnnotation(a: Annotation) { + val ann = a.asInstanceOf[SourceAnnotation] + println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") + + ", value=" + ann.value + ")") + } + val anns = target.getAnnotations() + anns foreach printSourceAnnotation + if (anns.length > 0) { + println(target) + println + } + } + printSourceAnnotations(classOf[Foo1]) + printSourceAnnotations(classOf[Foo2]) + printSourceAnnotations(classOf[Foo3]) + classOf[Foo4].getDeclaredFields foreach printSourceAnnotations + classOf[Foo4].getDeclaredMethods foreach printSourceAnnotations + classOf[Foo5].getDeclaredMethods foreach printSourceAnnotations + classOf[Foo6].getDeclaredConstructors foreach printSourceAnnotations + classOf[Foo7].getDeclaredConstructors foreach printSourceAnnotations + classOf[Foo8].getDeclaredFields foreach printSourceAnnotations + classOf[Foo8].getDeclaredMethods foreach printSourceAnnotations + } +} + +object Test5 { + import scala.reflect.BeanProperty + import java.lang.Integer + + class Count { + // we use "Integer" instead of "Int" because of Java reflection + @BeanProperty + private var count: Integer = 0 + + private val getter = + getClass().getMethod("getCount", Array[java.lang.Class[T] forSome { type T }]()) + private val setter = + getClass().getMethod("setCount", Array(classOf[Integer])) + + def get = getter.invoke(this, Array()).asInstanceOf[Integer].intValue + def set(n: Int) = setter.invoke(this, Array(new Integer(n))) + } + def run { + val count = new Count + println(count.get) + count.set(99) + println(count.get) + } +} + +object Test { + def main(args: Array[String]) { + Test1.run + Test2.run + Test3.run // requires the use of -target:jvm-1.5 + Test4.run + Test5.run + } +} diff --git a/test/pending/jvm/t1464.check b/test/pending/jvm/t1464.check new file mode 100644 index 0000000000..c508d5366f --- /dev/null +++ b/test/pending/jvm/t1464.check @@ -0,0 +1 @@ +false diff --git a/test/pending/jvm5/annotations.scala b/test/pending/jvm5/annotations.scala deleted file mode 100644 index 98b82edad4..0000000000 --- a/test/pending/jvm5/annotations.scala +++ /dev/null @@ -1,159 +0,0 @@ -object Test1 { - class Foo { - @remote - def foo: Unit = () - } - def run { - val method = classOf[Foo].getMethod("foo", Array()) - method.getExceptionTypes foreach println - } -} - -object Test2 { - import java.io.{BufferedReader,FileReader, IOException} - class Reader(fname: String) { - private val in = new BufferedReader(new FileReader(fname)) - - @throws(classOf[IOException]) - def read() = in.read() - } - def run { - val method = classOf[Reader].getMethod("read", Array()) - method.getExceptionTypes foreach 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 { - import java.lang.Deprecated - class Foo { - @Deprecated - def foo: Unit = () - } - def run { - val method = classOf[Foo].getMethod("foo", Array()) - val annotation = method.getAnnotation(classOf[Deprecated]) - 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-lang.org, mail=scala@lists.epfl.ch) - } -} -*/ -object Test4 { - import test.SourceAnnotation // defined in SourceAnnotation.java - @SourceAnnotation{val value = "http://scala-lang.org", - val mails = Array("scala@lists.epfl.ch", "scala-lounge@lists.epfl.ch")} - class Foo1 - @SourceAnnotation("http://bloodsuckers.com") { val mails = Array("you@bloodsuckers.com") } - class Foo2 - @SourceAnnotation("http://bloodsuckers.com") - class Foo3 - class Foo4 { - @SourceAnnotation("file:///dev/null") - val x = 1 - } - class Foo5 { - @SourceAnnotation("file:///dev/zero") - def bar: Int = 0 - } - class Foo6 @SourceAnnotation("primary constructor")(s: String) { - // to guarantee that primary constructor annotations - // are not applied to secondary constructors - def this() = this("") - } - class Foo7(s: String) { - @SourceAnnotation("secondary constructor") - def this() = this("") - } - class Foo8(@SourceAnnotation("constructor val") val n: Int) {} - def run { - import java.lang.annotation.Annotation - import java.lang.reflect.AnnotatedElement - def printSourceAnnotations(target: AnnotatedElement) { - //print SourceAnnotation in a predefined way to insure - // against difference in the JVMs (e.g. Sun's vs IBM's) - def printSourceAnnotation(a: Annotation) { - val ann = a.asInstanceOf[SourceAnnotation] - println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") + - ", value=" + ann.value + ")") - } - val anns = target.getAnnotations() - anns foreach printSourceAnnotation - if (anns.length > 0) { - println(target) - println - } - } - printSourceAnnotations(classOf[Foo1]) - printSourceAnnotations(classOf[Foo2]) - printSourceAnnotations(classOf[Foo3]) - classOf[Foo4].getDeclaredFields foreach printSourceAnnotations - classOf[Foo4].getDeclaredMethods foreach printSourceAnnotations - classOf[Foo5].getDeclaredMethods foreach printSourceAnnotations - classOf[Foo6].getDeclaredConstructors foreach printSourceAnnotations - classOf[Foo7].getDeclaredConstructors foreach printSourceAnnotations - classOf[Foo8].getDeclaredFields foreach printSourceAnnotations - classOf[Foo8].getDeclaredMethods foreach printSourceAnnotations - } -} - -object Test5 { - import scala.reflect.BeanProperty - import java.lang.Integer - - class Count { - // we use "Integer" instead of "Int" because of Java reflection - @BeanProperty - private var count: Integer = 0 - - private val getter = - getClass().getMethod("getCount", Array[java.lang.Class[T] forSome { type T }]()) - private val setter = - getClass().getMethod("setCount", Array(classOf[Integer])) - - def get = getter.invoke(this, Array()).asInstanceOf[Integer].intValue - def set(n: Int) = setter.invoke(this, Array(new Integer(n))) - } - def run { - val count = new Count - println(count.get) - count.set(99) - println(count.get) - } -} - -object Test { - def main(args: Array[String]) { - Test1.run - Test2.run - Test3.run // requires the use of -target:jvm-1.5 - Test4.run - Test5.run - } -} diff --git a/test/pending/jvm5/t1464.check b/test/pending/jvm5/t1464.check deleted file mode 100644 index c508d5366f..0000000000 --- a/test/pending/jvm5/t1464.check +++ /dev/null @@ -1 +0,0 @@ -false diff --git a/test/pending/pos/misc/A.java b/test/pending/pos/misc/A.java new file mode 100644 index 0000000000..bc8ea48dd0 --- /dev/null +++ b/test/pending/pos/misc/A.java @@ -0,0 +1,13 @@ +package test; + +import static test.A.STATE.UNDEF; + +class A { + + public STATE state = UNDEF; + + protected static enum STATE { + UNDEF + } + +} \ No newline at end of file diff --git a/test/pending/pos/misc/B.scala b/test/pending/pos/misc/B.scala new file mode 100644 index 0000000000..a6889e3c8b --- /dev/null +++ b/test/pending/pos/misc/B.scala @@ -0,0 +1,7 @@ +package test + +class B { + + def myA = new A() + +} \ No newline at end of file diff --git a/test/pending/pos/misc/J.java b/test/pending/pos/misc/J.java new file mode 100644 index 0000000000..4805791154 --- /dev/null +++ b/test/pending/pos/misc/J.java @@ -0,0 +1,4 @@ +class J { + void f (@Override{ name = value } int x) {} + void g (String ... x) {} +} diff --git a/test/pending/pos/misc/S.scala b/test/pending/pos/misc/S.scala new file mode 100644 index 0000000000..c5bfb26f18 --- /dev/null +++ b/test/pending/pos/misc/S.scala @@ -0,0 +1,4 @@ +object Test extends J { + def h(xs: String*) {} + g("a", "b", "c") +} diff --git a/test/pending/pos/t1745/J.java b/test/pending/pos/t1745/J.java new file mode 100644 index 0000000000..8444eabb24 --- /dev/null +++ b/test/pending/pos/t1745/J.java @@ -0,0 +1,10 @@ +class J { + S1 s1; + S2 s2; + + String s = bar(S3.foo(), S3.bar("def")); + + private String bar(String s1, String s2) { + return s1 + s2; + } +} diff --git a/test/pending/pos/t1745/S.scala b/test/pending/pos/t1745/S.scala new file mode 100644 index 0000000000..70210ba502 --- /dev/null +++ b/test/pending/pos/t1745/S.scala @@ -0,0 +1,7 @@ +case class S1(n: Int) { } +case class S2(n: Int, p: Int) { } +class S3 { } +object S3 { + def foo() = "abc" + def bar[T](x: T): T = x +} \ No newline at end of file diff --git a/test/pending/pos5/misc/A.java b/test/pending/pos5/misc/A.java deleted file mode 100644 index bc8ea48dd0..0000000000 --- a/test/pending/pos5/misc/A.java +++ /dev/null @@ -1,13 +0,0 @@ -package test; - -import static test.A.STATE.UNDEF; - -class A { - - public STATE state = UNDEF; - - protected static enum STATE { - UNDEF - } - -} \ No newline at end of file diff --git a/test/pending/pos5/misc/B.scala b/test/pending/pos5/misc/B.scala deleted file mode 100644 index a6889e3c8b..0000000000 --- a/test/pending/pos5/misc/B.scala +++ /dev/null @@ -1,7 +0,0 @@ -package test - -class B { - - def myA = new A() - -} \ No newline at end of file diff --git a/test/pending/pos5/misc/J.java b/test/pending/pos5/misc/J.java deleted file mode 100644 index 4805791154..0000000000 --- a/test/pending/pos5/misc/J.java +++ /dev/null @@ -1,4 +0,0 @@ -class J { - void f (@Override{ name = value } int x) {} - void g (String ... x) {} -} diff --git a/test/pending/pos5/misc/S.scala b/test/pending/pos5/misc/S.scala deleted file mode 100644 index c5bfb26f18..0000000000 --- a/test/pending/pos5/misc/S.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test extends J { - def h(xs: String*) {} - g("a", "b", "c") -} diff --git a/test/pending/pos5/t1745/J.java b/test/pending/pos5/t1745/J.java deleted file mode 100644 index 8444eabb24..0000000000 --- a/test/pending/pos5/t1745/J.java +++ /dev/null @@ -1,10 +0,0 @@ -class J { - S1 s1; - S2 s2; - - String s = bar(S3.foo(), S3.bar("def")); - - private String bar(String s1, String s2) { - return s1 + s2; - } -} diff --git a/test/pending/pos5/t1745/S.scala b/test/pending/pos5/t1745/S.scala deleted file mode 100644 index 70210ba502..0000000000 --- a/test/pending/pos5/t1745/S.scala +++ /dev/null @@ -1,7 +0,0 @@ -case class S1(n: Int) { } -case class S2(n: Int, p: Int) { } -class S3 { } -object S3 { - def foo() = "abc" - def bar[T](x: T): T = x -} \ No newline at end of file -- cgit v1.2.3