Merge boxWithJava testData into box, delete BoxWithJava test
This commit is contained in:
committed by
Alexander Udalov
parent
16a0ddd2fb
commit
f8dfaf4599
+77
@@ -0,0 +1,77 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public void publicMemberJ() {}
|
||||
private void privateMemberJ() {}
|
||||
public static void publicStaticJ() {}
|
||||
private static void privateStaticJ() {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
open class K : J() {
|
||||
public fun publicMemberK() {}
|
||||
private fun privateMemberK() {}
|
||||
public fun Any.publicMemberExtensionK() {}
|
||||
private fun Any.privateMemberExtensionK() {}
|
||||
}
|
||||
|
||||
class L : K()
|
||||
|
||||
fun Collection<KFunction<*>>.names(): Set<String> =
|
||||
this.map { it.name }.toSet()
|
||||
|
||||
fun check(c: Collection<KFunction<*>>, names: Set<String>) {
|
||||
assertEquals(names, c.names())
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val any = setOf("equals", "hashCode", "toString")
|
||||
|
||||
val j = J::class
|
||||
|
||||
check(j.staticFunctions,
|
||||
setOf("publicStaticJ", "privateStaticJ"))
|
||||
check(j.declaredFunctions,
|
||||
setOf("publicMemberJ", "privateMemberJ", "publicStaticJ", "privateStaticJ"))
|
||||
check(j.declaredMemberFunctions,
|
||||
setOf("publicMemberJ", "privateMemberJ"))
|
||||
check(j.declaredMemberExtensionFunctions,
|
||||
emptySet())
|
||||
|
||||
check(j.functions, any + j.declaredFunctions.names())
|
||||
check(j.memberFunctions, any + j.declaredMemberFunctions.names())
|
||||
check(j.memberExtensionFunctions, emptySet())
|
||||
|
||||
val k = K::class
|
||||
|
||||
check(k.staticFunctions,
|
||||
emptySet())
|
||||
check(k.declaredFunctions,
|
||||
setOf("publicMemberK", "privateMemberK", "publicMemberExtensionK", "privateMemberExtensionK"))
|
||||
check(k.declaredMemberFunctions,
|
||||
setOf("publicMemberK", "privateMemberK"))
|
||||
check(k.declaredMemberExtensionFunctions,
|
||||
setOf("publicMemberExtensionK", "privateMemberExtensionK"))
|
||||
|
||||
check(k.memberFunctions, any + setOf("publicMemberJ") + k.declaredMemberFunctions.names())
|
||||
check(k.memberExtensionFunctions, k.declaredMemberExtensionFunctions.names())
|
||||
check(k.functions, any + (k.memberFunctions + k.memberExtensionFunctions).names())
|
||||
|
||||
|
||||
val l = L::class
|
||||
|
||||
check(l.staticFunctions, emptySet())
|
||||
check(l.declaredFunctions, emptySet())
|
||||
check(l.declaredMemberFunctions, emptySet())
|
||||
check(l.declaredMemberExtensionFunctions, emptySet())
|
||||
check(l.memberFunctions, any + setOf("publicMemberJ", "publicMemberK"))
|
||||
check(l.memberExtensionFunctions, setOf("publicMemberExtensionK"))
|
||||
check(l.functions, any + (l.memberFunctions + l.memberExtensionFunctions).names())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
import kotlin.jvm.functions.Function2;
|
||||
import kotlin.reflect.KFunction;
|
||||
|
||||
public class J {
|
||||
public static String go() {
|
||||
KFunction<String> fun = K.Companion.getRef();
|
||||
Object result = ((Function2) fun).invoke(new K(), "KO");
|
||||
return (String) result;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
class K {
|
||||
fun reverse(s: String): String {
|
||||
return s.reversed()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getRef() = K::reverse
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return J.go()
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
public class J {
|
||||
public J() {
|
||||
}
|
||||
|
||||
public void member(String s) {
|
||||
}
|
||||
|
||||
public static void staticMethod(int x) {
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(listOf("equals", "hashCode", "member", "staticMethod", "toString"), J::class.members.map { it.name }.sorted())
|
||||
assertEquals(listOf("equals", "hashCode", "member", "staticMethod", "toString"), J::class.functions.map { it.name }.sorted())
|
||||
assertEquals(listOf("member", "staticMethod"), J::class.declaredFunctions.map { it.name }.sorted())
|
||||
|
||||
assertEquals(1, J::class.constructors.size)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// WITH_REFLECT
|
||||
// FILE: J.java
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class J {
|
||||
void simple() {}
|
||||
|
||||
void objectTypes(
|
||||
Object o, String s, Object[] oo, String[] ss
|
||||
) {}
|
||||
|
||||
void primitives(
|
||||
boolean z, char c, byte b, short s, int i, float f, long j, double d
|
||||
) {}
|
||||
|
||||
void primitiveArrays(
|
||||
boolean[] z, char[] c, byte[] b, short[] s, int[] i, float[] f, long[] j, double[] d
|
||||
) {}
|
||||
|
||||
void multiDimensionalArrays(
|
||||
int[][][] i, Cloneable[][][][] c
|
||||
) {}
|
||||
|
||||
void wildcards(
|
||||
List<? extends Number> l, List<? super Cloneable> m
|
||||
) {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
import kotlin.reflect.KFunction
|
||||
|
||||
// Initiate descriptor computation in reflection to ensure that nothing fails
|
||||
fun test(f: KFunction<*>) {
|
||||
f.parameters
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test(J::simple)
|
||||
test(J::objectTypes)
|
||||
test(J::primitives)
|
||||
test(J::primitiveArrays)
|
||||
test(J::multiDimensionalArrays)
|
||||
test(J::wildcards)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user