Support reflection tests on Android
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
|
||||
// WITH_REFLECT
|
||||
package test
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
@@ -11,9 +12,9 @@ class A {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("class A", "${A::class}")
|
||||
assertEquals("class A\$Nested", "${A.Nested::class}")
|
||||
assertEquals("class A\$Companion", "${A.Companion::class}")
|
||||
assertEquals("class test.A", "${A::class}")
|
||||
assertEquals("class test.A\$Nested", "${A.Nested::class}")
|
||||
assertEquals("class test.A\$Companion", "${A.Companion::class}")
|
||||
|
||||
assertEquals("class kotlin.Any", "${Any::class}")
|
||||
assertEquals("class kotlin.Int", "${Int::class}")
|
||||
|
||||
+7
-6
@@ -1,5 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM_IR, JS_IR, JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
package test
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -12,16 +13,16 @@ open class B<U> : A<U>()
|
||||
class C : B<String>()
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("fun A<T>.foo(T): kotlin.Unit", A<Double>::foo.toString())
|
||||
assertEquals("fun B<U>.foo(U): kotlin.Unit", B<Float>::foo.toString())
|
||||
assertEquals("fun C.foo(kotlin.String): kotlin.Unit", C::foo.toString())
|
||||
assertEquals("fun test.A<T>.foo(T): kotlin.Unit", A<Double>::foo.toString())
|
||||
assertEquals("fun test.B<U>.foo(U): kotlin.Unit", B<Float>::foo.toString())
|
||||
assertEquals("fun test.C.foo(kotlin.String): kotlin.Unit", C::foo.toString())
|
||||
|
||||
val afoo = A::class.members.single { it.name == "foo" }
|
||||
assertEquals("fun A<T>.foo(T): kotlin.Unit", afoo.toString())
|
||||
assertEquals("fun test.A<T>.foo(T): kotlin.Unit", afoo.toString())
|
||||
val bfoo = B::class.members.single { it.name == "foo" }
|
||||
assertEquals("fun B<U>.foo(U): kotlin.Unit", bfoo.toString())
|
||||
assertEquals("fun test.B<U>.foo(U): kotlin.Unit", bfoo.toString())
|
||||
val cfoo = C::class.members.single { it.name == "foo" }
|
||||
assertEquals("fun C.foo(kotlin.String): kotlin.Unit", cfoo.toString())
|
||||
assertEquals("fun test.C.foo(kotlin.String): kotlin.Unit", cfoo.toString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+5
-4
@@ -1,5 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM_IR, JS_IR, JS, NATIVE
|
||||
// WITH_REFLECT
|
||||
package test
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -21,13 +22,13 @@ interface I3 {
|
||||
interface I : I2, I1, I3
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("fun I.f(): kotlin.Unit", I::f.toString())
|
||||
assertEquals("val I.x: kotlin.Int", I::x.toString())
|
||||
assertEquals("fun test.I.f(): kotlin.Unit", I::f.toString())
|
||||
assertEquals("val test.I.x: kotlin.Int", I::x.toString())
|
||||
|
||||
val f = I::class.members.single { it.name == "f" }
|
||||
assertEquals("fun I.f(): kotlin.Unit", f.toString())
|
||||
assertEquals("fun test.I.f(): kotlin.Unit", f.toString())
|
||||
val x = I::class.members.single { it.name == "x" }
|
||||
assertEquals("val I.x: kotlin.Int", x.toString())
|
||||
assertEquals("val test.I.x: kotlin.Int", x.toString())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+4
-2
@@ -5,6 +5,8 @@
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.reflect.full.*
|
||||
|
||||
class A {
|
||||
@@ -17,10 +19,10 @@ class A {
|
||||
|
||||
fun box(): String {
|
||||
val p = A::class.memberExtensionProperties.single()
|
||||
return if ("$p" == "var A.(kotlin.String.)id: kotlin.String") "OK" else "Fail $p"
|
||||
return if ("$p" == "var test.A.(kotlin.String.)id: kotlin.String") "OK" else "Fail $p"
|
||||
|
||||
val q = A::class.declaredFunctions.single()
|
||||
if ("$q" != "fun A.(kotlin.Int.)foo(): kotlin.Double") return "Fail q $q"
|
||||
if ("$q" != "fun test.A.(kotlin.Int.)foo(): kotlin.Double") return "Fail q $q"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun String?.foo(x: Int, y: Array<Int>, z: IntArray, w: List<Map<Any, A<*>>>) {}
|
||||
@@ -22,7 +24,7 @@ fun box(): String {
|
||||
"kotlin.Int",
|
||||
"kotlin.Array<kotlin.Int>",
|
||||
"kotlin.IntArray",
|
||||
"kotlin.collections.List<kotlin.collections.Map<kotlin.Any, A<*>>>"
|
||||
"kotlin.collections.List<kotlin.collections.Map<kotlin.Any, test.A<*>>>"
|
||||
),
|
||||
String?::foo.parameters.map { it.type.toString() }
|
||||
)
|
||||
@@ -30,11 +32,11 @@ fun box(): String {
|
||||
assertEquals("kotlin.Unit", String?::foo.returnType.toString())
|
||||
|
||||
val bar = A::class.members.single { it.name == "bar" }
|
||||
assertEquals(listOf("A<T>", "T", "U"), bar.parameters.map { it.type.toString() })
|
||||
assertEquals(listOf("test.A<T>", "T", "U"), bar.parameters.map { it.type.toString() })
|
||||
assertEquals("T?", bar.returnType.toString())
|
||||
|
||||
assertEquals(
|
||||
listOf("A<in kotlin.Number>", "A<out kotlin.Number>"),
|
||||
listOf("test.A<in kotlin.Number>", "test.A<out kotlin.Number>"),
|
||||
::baz.parameters.map { it.type.toString() }
|
||||
)
|
||||
|
||||
|
||||
+3
-1
@@ -5,6 +5,8 @@
|
||||
|
||||
// WITH_REFLECT
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class A<T1> {
|
||||
@@ -16,6 +18,6 @@ class A<T1> {
|
||||
fun foo(): A<Int>.B<Double, Float>.C<Long> = null!!
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("A<kotlin.Int>.B<kotlin.Double, kotlin.Float>.C<kotlin.Long>", ::foo.returnType.toString())
|
||||
assertEquals("test.A<kotlin.Int>.B<kotlin.Double, kotlin.Float>.C<kotlin.Long>", ::foo.returnType.toString())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user