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"
|
|
||||||
}
|
|
||||||
Generated
+8
-13
@@ -749,16 +749,6 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/reflection"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/reflection"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("realParameterNames.kt")
|
|
||||||
public void testRealParameterNames() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/java8/box/reflection/realParameterNames.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("synthesizedParameterNames.kt")
|
|
||||||
public void testSynthesizedParameterNames() throws Exception {
|
|
||||||
runTest("compiler/testData/codegen/java8/box/reflection/synthesizedParameterNames.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/java8/box/reflection/parameters")
|
@TestMetadata("compiler/testData/codegen/java8/box/reflection/parameters")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
@@ -771,9 +761,14 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/reflection/parameters"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/reflection/parameters"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("javaParametersHaveDefaultNames.kt")
|
@TestMetadata("realParameterNames.kt")
|
||||||
public void testJavaParametersHaveDefaultNames() throws Exception {
|
public void testRealParameterNames() throws Exception {
|
||||||
runTest("compiler/testData/codegen/java8/box/reflection/parameters/javaParametersHaveDefaultNames.kt");
|
runTest("compiler/testData/codegen/java8/box/reflection/parameters/realParameterNames.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("synthesizedParameterNames.kt")
|
||||||
|
public void testSynthesizedParameterNames() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/java8/box/reflection/parameters/synthesizedParameterNames.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user