Support KPackage.members, functions and properties
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
import kotlin.reflect.*
|
||||
import kotlin.reflect.jvm.*
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
fun foo() {}
|
||||
fun Int.bar() {}
|
||||
val baz = 42
|
||||
val Int.quux: Int get() = this
|
||||
|
||||
fun box(): String {
|
||||
fun check(actual: Collection<KCallable<*>>, expected: Set<String>) {
|
||||
assertEquals(expected, actual.map { it.name }.toSet())
|
||||
}
|
||||
|
||||
val kp = Class.forName("_DefaultPackage").kotlinPackage ?: return "Fail: package class not found"
|
||||
|
||||
check(kp.members, setOf("bar", "baz", "foo", "box", "quux"))
|
||||
check(kp.functions, setOf("bar", "foo", "box"))
|
||||
check(kp.properties, setOf("baz"))
|
||||
check(kp.extensionProperties, setOf("quux"))
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+15
@@ -3214,6 +3214,21 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/packages")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Packages extends AbstractBlackBoxCodegenTest {
|
||||
public void testAllFilesPresentInPackages() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/packages"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleGetMembers.kt")
|
||||
public void testSimpleGetMembers() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/packages/simpleGetMembers.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/parameters")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user