Merge and improve tests on Java parameter metadata in reflection
This commit is contained in:
Vendored
-22
@@ -1,22 +0,0 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS, NATIVE
|
||||
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
void foo(String s, int i) {}
|
||||
|
||||
static void bar(J j) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf(null, "arg0", "arg1"), J::foo.parameters.map { it.name })
|
||||
assertEquals(listOf("arg0"), J::bar.parameters.map { it.name })
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
// JAVAC_OPTIONS: -parameters
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public J(String constructorParam) {}
|
||||
|
||||
public void foo(int methodParam) {}
|
||||
|
||||
public static void bar(J staticMethodParam) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf("constructorParam"), ::J.parameters.map { it.name })
|
||||
assertEquals(listOf(null, "methodParam"), J::foo.parameters.map { it.name })
|
||||
assertEquals(listOf("staticMethodParam"), J::bar.parameters.map { it.name })
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public J(String constructorParam) {}
|
||||
|
||||
public void foo(int methodParam) {}
|
||||
|
||||
public static void bar(J staticMethodParam) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf("arg0"), ::J.parameters.map { it.name })
|
||||
assertEquals(listOf(null, "arg0"), J::foo.parameters.map { it.name })
|
||||
assertEquals(listOf("arg0"), J::bar.parameters.map { it.name })
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
// WITH_REFLECT
|
||||
// JAVAC_OPTIONS: -parameters
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public J(String constructorParam) {}
|
||||
|
||||
public static void foo(int methodParam) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
val methodParam = J::foo.parameters.single()
|
||||
if (methodParam.name == null) return "Fail: method parameter has no name"
|
||||
assertEquals("methodParam", methodParam.name)
|
||||
|
||||
val constructorParam = J::class.constructors.single().parameters.single()
|
||||
if (constructorParam.name == null) return "Fail: constructor parameter has no name"
|
||||
assertEquals("constructorParam", constructorParam.name)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public J(String constructorParam) {}
|
||||
|
||||
public static void foo(int methodParam) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
val methodParam = J::foo.parameters.single()
|
||||
if (methodParam.name == null) return "Fail: method parameter has no name"
|
||||
assertEquals("arg0", methodParam.name)
|
||||
|
||||
val constructorParam = J::class.constructors.single().parameters.single()
|
||||
if (constructorParam.name == null) return "Fail: constructor parameter has no name"
|
||||
assertEquals("arg0", constructorParam.name)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user