Cleanup deprecated symbol usages in testData
This commit is contained in:
@@ -17,15 +17,15 @@ enum class E {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val e = javaClass<E>()
|
||||
val e = E::class.java
|
||||
|
||||
val e1 = e.getDeclaredField(E.E1.toString()).getAnnotations()
|
||||
if (e1.size() != 1) return "Fail E1 size: ${e1.toList()}"
|
||||
if (e1[0].annotationType() != javaClass<First>()) return "Fail E1: ${e1.toList()}"
|
||||
if (e1.size != 1) return "Fail E1 size: ${e1.toList()}"
|
||||
if (e1[0].annotationClass.java != First::class.java) return "Fail E1: ${e1.toList()}"
|
||||
|
||||
val e2 = e.getDeclaredField(E.E2.toString()).getAnnotations()
|
||||
if (e2.size() != 1) return "Fail E2 size: ${e2.toList()}"
|
||||
if (e2[0].annotationType() != javaClass<Second>()) return "Fail E2: ${e2.toList()}"
|
||||
if (e2.size != 1) return "Fail E2 size: ${e2.toList()}"
|
||||
if (e2[0].annotationClass.java != Second::class.java) return "Fail E2: ${e2.toList()}"
|
||||
|
||||
return (e2[0] as Second).value
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ fun foo0(block: () -> Unit) = block.javaClass
|
||||
fun foo1(block: (String) -> Unit) = block.javaClass
|
||||
|
||||
fun testMethod(method: Method, name: String) {
|
||||
assertEquals("OK", method.getAnnotation(javaClass<Ann>()).x, "On method of test named `$name`")
|
||||
assertEquals("OK", method.getAnnotation(Ann::class.java).x, "On method of test named `$name`")
|
||||
|
||||
for ((index, annotations) in method.getParameterAnnotations().withIndex()) {
|
||||
val ann = annotations.filterIsInstance<Ann>().single()
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ annotation class Ann(val x: String)
|
||||
fun foo0(block: () -> Unit) = block.javaClass
|
||||
|
||||
fun testMethod(method: Method, name: String) {
|
||||
assertEquals("OK", method.getAnnotation(javaClass<Ann>()).x, "On method of test named `$name`")
|
||||
assertEquals("OK", method.getAnnotation(Ann::class.java).x, "On method of test named `$name`")
|
||||
|
||||
for ((index, annotations) in method.getParameterAnnotations().withIndex()) {
|
||||
val ann = annotations.filterIsInstance<Ann>().single()
|
||||
|
||||
+4
-4
@@ -15,18 +15,18 @@ fun test(name: String, annotations: Array<out Annotation>) {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val foo = javaClass<A>().getDeclaredMethods().first { it.getName() == "foo" }
|
||||
val foo = A::class.java.getDeclaredMethods().first { it.getName() == "foo" }
|
||||
test("foo", foo.getDeclaredAnnotations())
|
||||
|
||||
val fooDefault = javaClass<A>().getDeclaredMethods().first { it.getName() == "foo\$default" }
|
||||
val fooDefault = A::class.java.getDeclaredMethods().first { it.getName() == "foo\$default" }
|
||||
test("foo", foo.getDeclaredAnnotations())
|
||||
|
||||
val (secondary, secondaryDefault) = javaClass<A>().getDeclaredConstructors().partition { it.getParameterTypes().size() == 3 }
|
||||
val (secondary, secondaryDefault) = A::class.java.getDeclaredConstructors().partition { it.getParameterTypes().size == 3 }
|
||||
|
||||
test("secondary", secondary[0].getDeclaredAnnotations())
|
||||
test("secondary\$default", secondaryDefault[0].getDeclaredAnnotations())
|
||||
|
||||
val (primary, primaryDefault) = javaClass<B>().getConstructors().partition { it.getParameterTypes().size() == 3 }
|
||||
val (primary, primaryDefault) = B::class.java.getConstructors().partition { it.getParameterTypes().size == 3 }
|
||||
|
||||
test("primary", primary[0].getDeclaredAnnotations())
|
||||
test("primary\$default", primaryDefault[0].getDeclaredAnnotations())
|
||||
|
||||
+3
-3
@@ -12,14 +12,14 @@ annotation class Ann(
|
||||
)
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann.i != 1) return "fail: annotation parameter i should be 1, but was ${ann.i}"
|
||||
if (ann.s != "a") return "fail: annotation parameter s should be \"a\", but was ${ann.s}"
|
||||
val annSimpleName = ann.a.annotationType().getSimpleName()
|
||||
val annSimpleName = ann.a.annotationClass.java.getSimpleName()
|
||||
if (annSimpleName != "Ann2") return "fail: annotation parameter a should be of class Ann2, but was $annSimpleName"
|
||||
if (ann.e != MyEnum.A) return "fail: annotation parameter e should be MyEnum.A, but was ${ann.e}"
|
||||
if (ann.c.java != javaClass<A>()) return "fail: annotation parameter c should be of class A, but was ${ann.c}"
|
||||
if (ann.c.java != A::class.java) return "fail: annotation parameter c should be of class A, but was ${ann.c}"
|
||||
if (ann.ia[0] != 1 || ann.ia[1] != 2) return "fail: annotation parameter ia should be [1, 2], but was ${ann.ia}"
|
||||
if (ann.sa[0] != "a" || ann.sa[1] != "b") return "fail: annotation parameter ia should be [\"a\", \"b\"], but was ${ann.sa}"
|
||||
return "OK"
|
||||
|
||||
+4
-4
@@ -17,11 +17,11 @@ class Delegate {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val e = javaClass<MyClass>()
|
||||
val e = MyClass::class.java
|
||||
|
||||
val e1 = e.getDeclaredMethod("setX", javaClass<String>()).getAnnotations()
|
||||
if (e1.size() != 1) return "Fail E1 size: ${e1.toList()}"
|
||||
if (e1[0].annotationType() != javaClass<First>()) return "Fail: ${e1.toList()}"
|
||||
val e1 = e.getDeclaredMethod("setX", String::class.java).getAnnotations()
|
||||
if (e1.size != 1) return "Fail E1 size: ${e1.toList()}"
|
||||
if (e1[0].annotationClass.java != First::class.java) return "Fail: ${e1.toList()}"
|
||||
|
||||
return MyClass().x
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
@Ann(Foo.i, Foo.s, Foo.f, Foo.d, Foo.l, Foo.b, Foo.bool, Foo.c, Foo.str) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann.i != 2) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
if (ann.s != 2.toShort()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
@Ann(i, s, f, d, l, b, bool, c, str) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann.i != 2) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
if (ann.s != 2.toShort()) return "fail: annotation parameter i should be 2, but was ${ann.i}"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
@Ann(A.B.i) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann.i != 1) return "fail: annotation parameter i should be 1, but was ${ann.i}"
|
||||
return "OK"
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ annotation class Ann(
|
||||
)
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann.b != 1.toByte()) return "fail: annotation parameter b should be 1, but was ${ann.b}"
|
||||
if (ann.s != 1.toShort()) return "fail: annotation parameter s should be 1, but was ${ann.s}"
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
@Ann(i) class MyClass
|
||||
|
||||
fun box(): String {
|
||||
val ann = javaClass<MyClass>().getAnnotation(javaClass<Ann>())
|
||||
val ann = MyClass::class.java.getAnnotation(Ann::class.java)
|
||||
if (ann == null) return "fail: cannot find Ann on MyClass}"
|
||||
if (ann.i != 1) return "fail: annotation parameter i should be 1, but was ${ann.i}"
|
||||
return "OK"
|
||||
|
||||
+11
-11
@@ -16,25 +16,25 @@ annotation class Ann(vararg val p: Int)
|
||||
@Ann(p = *intArrayOf(1, 2)) class MyClass10
|
||||
|
||||
fun box(): String {
|
||||
test(javaClass<MyClass1>(), "")
|
||||
test(javaClass<MyClass2>(), "1")
|
||||
test(javaClass<MyClass3>(), "12")
|
||||
test(MyClass1::class.java, "")
|
||||
test(MyClass2::class.java, "1")
|
||||
test(MyClass3::class.java, "12")
|
||||
|
||||
test(javaClass<MyClass4>(), "")
|
||||
test(javaClass<MyClass5>(), "1")
|
||||
test(javaClass<MyClass6>(), "12")
|
||||
test(MyClass4::class.java, "")
|
||||
test(MyClass5::class.java, "1")
|
||||
test(MyClass6::class.java, "12")
|
||||
|
||||
test(javaClass<MyClass7>(), "1")
|
||||
test(MyClass7::class.java, "1")
|
||||
|
||||
test(javaClass<MyClass8>(), "")
|
||||
test(javaClass<MyClass9>(), "1")
|
||||
test(javaClass<MyClass10>(), "12")
|
||||
test(MyClass8::class.java, "")
|
||||
test(MyClass9::class.java, "1")
|
||||
test(MyClass10::class.java, "12")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
fun test(klass: Class<*>, expected: String) {
|
||||
val ann = klass.getAnnotation(javaClass<Ann>())
|
||||
val ann = klass.getAnnotation(Ann::class.java)
|
||||
if (ann == null) throw AssertionError("fail: cannot find Ann on ${klass}")
|
||||
|
||||
var result = ""
|
||||
|
||||
Reference in New Issue
Block a user