diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-12-20 13:19:19 +1000 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-12-20 13:19:19 +1000 |
commit | 079e8dc61704a768792c6b210a5b0cd25522ee55 (patch) | |
tree | 37154f37a745c9c7535cbe0a7f6cef486beb5870 /test/files/run/t3236/Test.scala | |
parent | 56fb9172756d95ef903c36efcf54f1ae95c64b4b (diff) | |
parent | 23548c4301e48cb69f05cd01ceba418dc9c36d6c (diff) | |
download | scala-079e8dc61704a768792c6b210a5b0cd25522ee55.tar.gz scala-079e8dc61704a768792c6b210a5b0cd25522ee55.tar.bz2 scala-079e8dc61704a768792c6b210a5b0cd25522ee55.zip |
Merge remote-tracking branch 'origin/2.11.x' into merge/2.11.x-to-2.12.x-20161220
Conflicts:
bincompat-backward.whitelist.conf
build.xml
src/compiler/scala/tools/nsc/typechecker/Typers.scala
src/library/scala/collection/immutable/NumericRange.scala
Diffstat (limited to 'test/files/run/t3236/Test.scala')
-rw-r--r-- | test/files/run/t3236/Test.scala | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/files/run/t3236/Test.scala b/test/files/run/t3236/Test.scala new file mode 100644 index 0000000000..7e351e0b6b --- /dev/null +++ b/test/files/run/t3236/Test.scala @@ -0,0 +1,44 @@ +import scala.language.reflectiveCalls + +object Test extends App { + val theClass = classOf[AnnotationTest] + + def annotation[T <: java.lang.annotation.Annotation](annotationClass: Class[T], methodName: String): T = + theClass.getDeclaredMethod(methodName) + .getAnnotation[T](annotationClass) + + def check[T, U <: java.lang.annotation.Annotation { def value(): T } ](annotationClass: Class[U], methodName: String, expected: T): Unit = { + val a = annotation(annotationClass, methodName) + assert(a != null, s"No annotation of type $annotationClass found on method $methodName") + assert(a.value() == expected, s"Actual value of annotation $a on $methodName was not of expected value $expected") + } + + check(classOf[BooleanAnnotation], "test1", Constants.BooleanTrue) + check(classOf[ByteAnnotation], "test1", Constants.Byte) + check(classOf[CharAnnotation], "test1", Constants.Char) + check(classOf[ShortAnnotation], "test1", Constants.Short) + check(classOf[IntAnnotation], "test1", Constants.Int) + check(classOf[LongAnnotation], "test1", Constants.Long) + check(classOf[FloatAnnotation], "test1", Constants.Float) + check(classOf[DoubleAnnotation], "test1", Constants.Double) + check(classOf[StringAnnotation], "test1", Constants.String) + + check(classOf[BooleanAnnotation], "test2", Constants.InvertedBoolean) + check(classOf[ByteAnnotation], "test2", Constants.NegativeByte) + // no negative char possible + check(classOf[ShortAnnotation], "test2", Constants.NegativeShort) + check(classOf[IntAnnotation], "test2", Constants.NegativeInt) + check(classOf[LongAnnotation], "test2", Constants.NegativeLong) + check(classOf[FloatAnnotation], "test2", Constants.NegativeFloat) + check(classOf[DoubleAnnotation], "test2", Constants.NegativeDouble) + check(classOf[StringAnnotation], "test2", Constants.NegativeString) + + check(classOf[BooleanAnnotation], "test3", Constants.BooleanFalse) + check(classOf[ByteAnnotation], "test3", Constants.LiteralCharAsByte) + check(classOf[CharAnnotation], "test3", Constants.LiteralChar) + check(classOf[ShortAnnotation], "test3", Constants.LiteralCharAsShort) + check(classOf[IntAnnotation], "test3", Constants.LiteralCharAsInt) + check(classOf[LongAnnotation], "test3", Constants.LiteralCharAsLong) + + check(classOf[LongAnnotation], "test4", Constants.LiteralIntAsLong) +} |