Move tests on KClass.java* to box/classLiteral/java

Also replace WITH_REFLECT to WITH_RUNTIME to test that these cases correctly
work without reflection in the classpath
This commit is contained in:
Alexander Udalov
2016-07-15 00:30:06 +03:00
parent 70e01fac18
commit 0ea885ce58
11 changed files with 115 additions and 121 deletions
@@ -1,4 +1,4 @@
// WITH_REFLECT
// WITH_RUNTIME
import kotlin.reflect.KClass
@@ -1,4 +1,4 @@
// WITH_REFLECT
// WITH_RUNTIME
import kotlin.reflect.KClass
@@ -43,8 +43,8 @@ fun box(): String {
check(Nothing::class.javaObjectType, "java.lang.Void")
check(Nothing::class, "java.lang.Void")
check(java.lang.Void::class.javaObjectType, "java.lang.Void")
check(java.lang.Void::class, "java.lang.Void")
check(Void::class.javaObjectType, "java.lang.Void")
check(Void::class, "java.lang.Void")
return "OK"
}
@@ -0,0 +1,24 @@
// WITH_RUNTIME
inline fun <reified T : Any> check(expected: String) {
val clazz = T::class.javaObjectType!!
assert (clazz.canonicalName == "java.lang.$expected") {
"clazz name: ${clazz.canonicalName}"
}
}
fun box(): String {
check<Boolean>("Boolean")
check<Char>("Character")
check<Byte>("Byte")
check<Short>("Short")
check<Int>("Integer")
check<Float>("Float")
check<Long>("Long")
check<Double>("Double")
check<String>("String")
check<Void>("Void")
return "OK"
}
@@ -1,4 +1,4 @@
// WITH_REFLECT
// WITH_RUNTIME
import kotlin.reflect.KClass
@@ -53,8 +53,8 @@ fun box(): String {
checkNull(Nothing::class.javaPrimitiveType)
checkNull(Nothing::class)
checkNull(java.lang.Void::class.javaPrimitiveType)
checkNull(java.lang.Void::class)
checkNull(Void::class.javaPrimitiveType)
checkNull(Void::class)
return "OK"
}
@@ -1,6 +1,4 @@
// WITH_REFLECT
import kotlin.reflect.KClass
// WITH_RUNTIME
inline fun <reified T : Any> check(expected: String) {
val clazz = T::class.javaPrimitiveType!!
@@ -27,7 +25,7 @@ fun box(): String {
check<Double>("double")
checkNull<String>()
checkNull<java.lang.Void>()
checkNull<Void>()
return "OK"
}
@@ -0,0 +1,24 @@
// WITH_RUNTIME
inline fun <reified T : Any> check(expected: String) {
val clazz = T::class.java!!
assert (clazz.canonicalName == "java.lang.$expected") {
"clazz name: ${clazz.canonicalName}"
}
}
fun box(): String {
check<Boolean>("Boolean")
check<Char>("Character")
check<Byte>("Byte")
check<Short>("Short")
check<Int>("Integer")
check<Float>("Float")
check<Long>("Long")
check<Double>("Double")
check<String>("String")
check<Void>("Void")
return "OK"
}
@@ -1,4 +1,4 @@
// WITH_REFLECT
// WITH_RUNTIME
import kotlin.reflect.KClass
@@ -1,26 +0,0 @@
// WITH_REFLECT
import kotlin.reflect.KClass
inline fun <reified T : Any> check(expected: String) {
val clazz = T::class.javaObjectType!!
assert (clazz.canonicalName == "java.lang.${expected.capitalize()}") {
"clazz name: ${clazz.canonicalName}"
}
}
fun box(): String {
check<Boolean>("boolean")
check<Char>("character")
check<Byte>("byte")
check<Short>("short")
check<Int>("integer")
check<Float>("float")
check<Long>("long")
check<Double>("double")
check<String>("String")
check<java.lang.Void>("Void")
return "OK"
}
@@ -1,26 +0,0 @@
// WITH_REFLECT
import kotlin.reflect.KClass
inline fun <reified T : Any> check(expected: String) {
val clazz = T::class.java!!
assert (clazz.canonicalName == "java.lang.${expected.capitalize()}") {
"clazz name: ${clazz.canonicalName}"
}
}
fun box(): String {
check<Boolean>("boolean")
check<Char>("character")
check<Byte>("byte")
check<Short>("short")
check<Int>("integer")
check<Float>("float")
check<Long>("long")
check<Double>("double")
check<String>("String")
check<java.lang.Void>("Void")
return "OK"
}
@@ -2364,12 +2364,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("objectSuperConstructorCall.kt")
public void testObjectSuperConstructorCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/bound/objectSuperConstructorCall.kt");
doTest(fileName);
}
@TestMetadata("primitives.kt")
public void testPrimitives() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/bound/primitives.kt");
@@ -2388,6 +2382,63 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/classLiteral/java")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Java extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInJava() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/classLiteral/java"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("java.kt")
public void testJava() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/java.kt");
doTest(fileName);
}
@TestMetadata("javaObjectType.kt")
public void testJavaObjectType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/javaObjectType.kt");
doTest(fileName);
}
@TestMetadata("javaObjectTypeReified.kt")
public void testJavaObjectTypeReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/javaObjectTypeReified.kt");
doTest(fileName);
}
@TestMetadata("javaPrimitiveType.kt")
public void testJavaPrimitiveType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/javaPrimitiveType.kt");
doTest(fileName);
}
@TestMetadata("javaPrimitiveTypeReified.kt")
public void testJavaPrimitiveTypeReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/javaPrimitiveTypeReified.kt");
doTest(fileName);
}
@TestMetadata("javaReified.kt")
public void testJavaReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/javaReified.kt");
doTest(fileName);
}
@TestMetadata("kt11943.kt")
public void testKt11943() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/kt11943.kt");
doTest(fileName);
}
@TestMetadata("objectSuperConstructorCall.kt")
public void testObjectSuperConstructorCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/classLiteral/java/objectSuperConstructorCall.kt");
doTest(fileName);
}
}
}
@TestMetadata("compiler/testData/codegen/box/classes")
@@ -12154,57 +12205,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
}
}
@TestMetadata("compiler/testData/codegen/box/reflection/javaProperties")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JavaProperties extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInJavaProperties() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/reflection/javaProperties"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("java.kt")
public void testJava() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/javaProperties/java.kt");
doTest(fileName);
}
@TestMetadata("javaObjectType.kt")
public void testJavaObjectType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/javaProperties/javaObjectType.kt");
doTest(fileName);
}
@TestMetadata("javaObjectTypeReified.kt")
public void testJavaObjectTypeReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/javaProperties/javaObjectTypeReified.kt");
doTest(fileName);
}
@TestMetadata("javaPrimitiveType.kt")
public void testJavaPrimitiveType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/javaProperties/javaPrimitiveType.kt");
doTest(fileName);
}
@TestMetadata("javaPrimitiveTypeReified.kt")
public void testJavaPrimitiveTypeReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/javaProperties/javaPrimitiveTypeReified.kt");
doTest(fileName);
}
@TestMetadata("javaReified.kt")
public void testJavaReified() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/javaProperties/javaReified.kt");
doTest(fileName);
}
@TestMetadata("kt11943.kt")
public void testKt11943() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/javaProperties/kt11943.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/box/reflection/kClassInAnnotation")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)