summaryrefslogtreecommitdiff
path: root/test/files/jvm5
diff options
context:
space:
mode:
authormihaylov <mihaylov@epfl.ch>2007-06-24 19:53:39 +0000
committermihaylov <mihaylov@epfl.ch>2007-06-24 19:53:39 +0000
commit1b887be0a16c53e6e01b523abf5b963672b82861 (patch)
tree8974dd840d09a1fd90f5d5effea756fe7ac91d44 /test/files/jvm5
parent490050f68930960488305f8c44c16d33530f791b (diff)
downloadscala-1b887be0a16c53e6e01b523abf5b963672b82861.tar.gz
scala-1b887be0a16c53e6e01b523abf5b963672b82861.tar.bz2
scala-1b887be0a16c53e6e01b523abf5b963672b82861.zip
Added annotations tests for fields and methods
Diffstat (limited to 'test/files/jvm5')
-rw-r--r--test/files/jvm5/annotations.check15
-rw-r--r--test/files/jvm5/annotations.scala34
2 files changed, 42 insertions, 7 deletions
diff --git a/test/files/jvm5/annotations.check b/test/files/jvm5/annotations.check
index 9219c7bdb5..449d3d9ab8 100644
--- a/test/files/jvm5/annotations.check
+++ b/test/files/jvm5/annotations.check
@@ -2,7 +2,22 @@ class java.rmi.RemoteException
class java.io.IOException
@java.lang.Deprecated()
@test.SourceAnnotation(mails={scala@lists.epfl.ch,scala-lounge@lists.epfl.ch}, value=http://scala-lang.org)
+class Test4$Foo1
+
@test.SourceAnnotation(mails={you@bloodsuckers.com}, value=http://bloodsuckers.com)
+class Test4$Foo2
+
@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=http://bloodsuckers.com)
+class Test4$Foo3
+
+@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/null)
+private int Test4$Foo4.x
+
+@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/null)
+public int Test4$Foo4.x()
+
+@test.SourceAnnotation(mails={bill.gates@bloodsuckers.com}, value=file:///dev/zero)
+public int Test4$Foo4.bar()
+
0
99
diff --git a/test/files/jvm5/annotations.scala b/test/files/jvm5/annotations.scala
index 121cb152b8..c850796e59 100644
--- a/test/files/jvm5/annotations.scala
+++ b/test/files/jvm5/annotations.scala
@@ -74,15 +74,35 @@ object Test4 {
class Foo2
@SourceAnnotation("http://bloodsuckers.com")
class Foo3
+ class Foo4 {
+ @SourceAnnotation("file:///dev/null")
+ val x = 1
+ @SourceAnnotation("file:///dev/zero")
+ def bar: Int = 0
+ }
def run {
- def printSourceAnnotation(a: Any) {
- val ann = a.asInstanceOf[SourceAnnotation]
- Console.println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") +
- ", value=" + ann.value + ")")
+ 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]
+ Console.println("@test.SourceAnnotation(mails=" + ann.mails.deepMkString("{", ",", "}") +
+ ", value=" + ann.value + ")")
+ }
+ val anns = target.getAnnotations()
+ anns foreach printSourceAnnotation
+ if (anns.length > 0) {
+ Console.println(target)
+ Console.println
+ }
}
- classOf[Foo1].getAnnotations foreach printSourceAnnotation
- classOf[Foo2].getAnnotations foreach printSourceAnnotation
- classOf[Foo3].getAnnotations foreach printSourceAnnotation
+ printSourceAnnotations(classOf[Foo1])
+ printSourceAnnotations(classOf[Foo2])
+ printSourceAnnotations(classOf[Foo3])
+ classOf[Foo4].getDeclaredFields foreach printSourceAnnotations
+ classOf[Foo4].getDeclaredMethods foreach printSourceAnnotations
}
}