summaryrefslogtreecommitdiff
path: root/test/files/jvm5/annotations.scala
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/annotations.scala
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/annotations.scala')
-rw-r--r--test/files/jvm5/annotations.scala34
1 files changed, 27 insertions, 7 deletions
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
}
}