summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2016-12-20 13:19:19 +1000
committerJason Zaugg <jzaugg@gmail.com>2016-12-20 13:19:19 +1000
commit079e8dc61704a768792c6b210a5b0cd25522ee55 (patch)
tree37154f37a745c9c7535cbe0a7f6cef486beb5870 /test/files/run
parent56fb9172756d95ef903c36efcf54f1ae95c64b4b (diff)
parent23548c4301e48cb69f05cd01ceba418dc9c36d6c (diff)
downloadscala-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')
-rw-r--r--test/files/run/t3236/AnnotationTest.scala33
-rw-r--r--test/files/run/t3236/BooleanAnnotation.java7
-rw-r--r--test/files/run/t3236/ByteAnnotation.java7
-rw-r--r--test/files/run/t3236/CharAnnotation.java7
-rw-r--r--test/files/run/t3236/Constants.java34
-rw-r--r--test/files/run/t3236/DoubleAnnotation.java7
-rw-r--r--test/files/run/t3236/FloatAnnotation.java7
-rw-r--r--test/files/run/t3236/IntAnnotation.java7
-rw-r--r--test/files/run/t3236/LongAnnotation.java7
-rw-r--r--test/files/run/t3236/ShortAnnotation.java7
-rw-r--r--test/files/run/t3236/StringAnnotation.java7
-rw-r--r--test/files/run/t3236/Test.scala44
12 files changed, 174 insertions, 0 deletions
diff --git a/test/files/run/t3236/AnnotationTest.scala b/test/files/run/t3236/AnnotationTest.scala
new file mode 100644
index 0000000000..c2f9ae7837
--- /dev/null
+++ b/test/files/run/t3236/AnnotationTest.scala
@@ -0,0 +1,33 @@
+trait AnnotationTest {
+ @BooleanAnnotation(Constants.BooleanTrue)
+ @ByteAnnotation(Constants.Byte)
+ @CharAnnotation(Constants.Char)
+ @ShortAnnotation(Constants.Short)
+ @IntAnnotation(Constants.Int)
+ @LongAnnotation(Constants.Long)
+ @FloatAnnotation(Constants.Float)
+ @DoubleAnnotation(Constants.Double)
+ @StringAnnotation(Constants.String)
+ def test1: Unit
+
+ @BooleanAnnotation(Constants.InvertedBoolean)
+ @ByteAnnotation(Constants.NegativeByte)
+ @ShortAnnotation(Constants.NegativeShort)
+ @IntAnnotation(Constants.NegativeInt)
+ @LongAnnotation(Constants.NegativeLong)
+ @FloatAnnotation(Constants.NegativeFloat)
+ @DoubleAnnotation(Constants.NegativeDouble)
+ @StringAnnotation(Constants.NegativeString)
+ def test2: Unit
+
+ @BooleanAnnotation(Constants.BooleanFalse)
+ @ByteAnnotation(Constants.LiteralCharAsByte)
+ @CharAnnotation(Constants.LiteralChar)
+ @ShortAnnotation(Constants.LiteralCharAsShort)
+ @IntAnnotation(Constants.LiteralCharAsInt)
+ @LongAnnotation(Constants.LiteralCharAsLong)
+ def test3: Unit
+
+ @LongAnnotation(Constants.LiteralIntAsLong)
+ def test4: Unit
+}
diff --git a/test/files/run/t3236/BooleanAnnotation.java b/test/files/run/t3236/BooleanAnnotation.java
new file mode 100644
index 0000000000..7e57a5e0db
--- /dev/null
+++ b/test/files/run/t3236/BooleanAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface BooleanAnnotation {
+ boolean value();
+}
diff --git a/test/files/run/t3236/ByteAnnotation.java b/test/files/run/t3236/ByteAnnotation.java
new file mode 100644
index 0000000000..c986fa5d27
--- /dev/null
+++ b/test/files/run/t3236/ByteAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ByteAnnotation {
+ byte value();
+}
diff --git a/test/files/run/t3236/CharAnnotation.java b/test/files/run/t3236/CharAnnotation.java
new file mode 100644
index 0000000000..1715f1b7de
--- /dev/null
+++ b/test/files/run/t3236/CharAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CharAnnotation {
+ char value();
+}
diff --git a/test/files/run/t3236/Constants.java b/test/files/run/t3236/Constants.java
new file mode 100644
index 0000000000..16b4001f76
--- /dev/null
+++ b/test/files/run/t3236/Constants.java
@@ -0,0 +1,34 @@
+public class Constants {
+ public static final boolean BooleanTrue = true;
+ public static final boolean BooleanFalse = false;
+ public static final boolean InvertedBoolean = !true;
+
+ public static final byte Byte = 23;
+ public static final byte NegativeByte = -42;
+ public static final byte LiteralCharAsByte = 'a';
+
+ public static final char Char = 33;
+ public static final char LiteralChar = 'b';
+
+ public static final short Short = 0x1234;
+ public static final short NegativeShort= -0x5678;
+ public static final short LiteralCharAsShort = 'c';
+
+ public static final int Int = 0xabcdef;
+ public static final int NegativeInt = -12345678;
+ public static final int LiteralCharAsInt = 'd';
+
+ public static final long Long = 0x1234567890abcdefL;
+ public static final long NegativeLong = -0xfedcba09876L;
+ public static final long LiteralCharAsLong = 'e';
+ public static final long LiteralIntAsLong = 0x12345678;
+
+ public static final float Float = 42.232323f;
+ public static final float NegativeFloat = -3.1415f;
+
+ public static final double Double = 23.4243598374594d;
+ public static final double NegativeDouble = -42.2324358934589734859d;
+
+ public static final String String = "testConstant";
+ public static final String NegativeString = "!#!$!grml%!%!$#@@@";
+}
diff --git a/test/files/run/t3236/DoubleAnnotation.java b/test/files/run/t3236/DoubleAnnotation.java
new file mode 100644
index 0000000000..1eb8223f4e
--- /dev/null
+++ b/test/files/run/t3236/DoubleAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface DoubleAnnotation {
+ double value();
+}
diff --git a/test/files/run/t3236/FloatAnnotation.java b/test/files/run/t3236/FloatAnnotation.java
new file mode 100644
index 0000000000..c723a25fad
--- /dev/null
+++ b/test/files/run/t3236/FloatAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface FloatAnnotation {
+ float value();
+}
diff --git a/test/files/run/t3236/IntAnnotation.java b/test/files/run/t3236/IntAnnotation.java
new file mode 100644
index 0000000000..2ffad8890c
--- /dev/null
+++ b/test/files/run/t3236/IntAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface IntAnnotation {
+ int value();
+}
diff --git a/test/files/run/t3236/LongAnnotation.java b/test/files/run/t3236/LongAnnotation.java
new file mode 100644
index 0000000000..9f80b41398
--- /dev/null
+++ b/test/files/run/t3236/LongAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface LongAnnotation {
+ long value();
+}
diff --git a/test/files/run/t3236/ShortAnnotation.java b/test/files/run/t3236/ShortAnnotation.java
new file mode 100644
index 0000000000..f0a35892c7
--- /dev/null
+++ b/test/files/run/t3236/ShortAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ShortAnnotation {
+ short value();
+}
diff --git a/test/files/run/t3236/StringAnnotation.java b/test/files/run/t3236/StringAnnotation.java
new file mode 100644
index 0000000000..0fdc1ead38
--- /dev/null
+++ b/test/files/run/t3236/StringAnnotation.java
@@ -0,0 +1,7 @@
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface StringAnnotation {
+ String value();
+}
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)
+}