Add WITH_RUNTIME and WITH_REFLECT directives to box tests

Currently all tests in boxWithStdlib/ run with both runtime and reflection
included; eventually they'll be merged into box/ using these directives
This commit is contained in:
Alexander Udalov
2016-03-03 15:40:33 +03:00
parent f47cc5ce2f
commit daab3db062
69 changed files with 162 additions and 95 deletions
@@ -41,4 +41,4 @@ fun box(): String {
val test2: X<String, B<String>> = J.test2() as X<String, B<String>>
return test2.p1 + test2.p2.value
}
}
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.test.*
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.reflect.KCallable
import kotlin.test.*
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.reflect.KClass
import kotlin.test.*
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.test.assertEquals
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.reflect.*
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.reflect.*
import kotlin.test.assertTrue
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.test.assertEquals
@@ -1,4 +1,4 @@
// NO_KOTLIN_REFLECT
// WITH_RUNTIME
import kotlin.test.assertNotNull
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1.kt
import test.A
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: box.kt
package test
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1.kt
import a.*
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1.kt
import a.OK
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: box.kt
package test
+1
View File
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1.kt
package thispackage
+1
View File
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1.kt
package test2
+1
View File
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1.kt
package test2
+1
View File
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1.kt
package test
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: box.kt
import a.*
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1/wrapped.kt
fun getWrapped1(): Runnable {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: 1/part.kt
@file:JvmName("Foo")
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: JavaClass.java
public class JavaClass {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class O {}
@@ -16,7 +17,7 @@ annotation class Ann(val args: Array<KClass<*>>)
fun box(): String {
val args = Test::class.java.getAnnotation(Ann::class.java).args
val argName1 = args[0].simpleName ?: "fail 1"
val argName2 = args[1].simpleName ?: "fail 2"
val argName1 = args[0].java.simpleName ?: "fail 1"
val argName2 = args[1].java.simpleName ?: "fail 2"
return argName1 + argName2
}
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class OK {}
@@ -14,6 +15,6 @@ import kotlin.reflect.KClass
annotation class Ann(val arg: KClass<*>)
fun box(): String {
val argName = Test::class.java.getAnnotation(Ann::class.java).arg.simpleName ?: "fail 1"
val argName = Test::class.java.getAnnotation(Ann::class.java).arg.java.simpleName ?: "fail 1"
return argName
}
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class O {}
@@ -16,7 +17,7 @@ annotation class Ann(vararg val args: KClass<*>)
fun box(): String {
val args = Test::class.java.getAnnotation(Ann::class.java).args
val argName1 = args[0].simpleName ?: "fail 1"
val argName2 = args[1].simpleName ?: "fail 2"
val argName1 = args[0].java.simpleName ?: "fail 1"
val argName2 = args[1].java.simpleName ?: "fail 2"
return argName1 + argName2
}
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: A.java
public class A extends AImpl implements java.util.List<String> {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: JavaClass.java
public class JavaClass {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Baz.java
public class Baz {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: StringHolder.java
import java.lang.annotation.ElementType;
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Baz.java
public class Baz {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Baz.java
public class Baz {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Baz.java
public class Baz {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Bar.java
public class Bar {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: CompanionInitialization.java
public class CompanionInitialization {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
public class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
public class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
public class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
public class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
import java.lang.annotation.Annotation;
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: JavaClass.java
import java.lang.annotation.Retention;
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: Test.java
class Test {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: JavaBaseClass.java
public class JavaBaseClass {
@@ -1,3 +1,4 @@
// WITH_RUNTIME
// FILE: JavaBaseClass.java
public class JavaBaseClass {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
@Anno("J")
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
import kotlin.jvm.functions.Function2;
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J extends K {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
public class J {
@@ -1,3 +1,4 @@
// WITH_REFLECT
// FILE: J.java
import java.util.List;
@@ -51,6 +51,9 @@ import static org.jetbrains.kotlin.test.KotlinTestUtils.compilerConfigurationFor
import static org.jetbrains.kotlin.test.KotlinTestUtils.getAnnotationsJar;
public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
private boolean addRuntime = false;
private boolean addReflect = false;
@Override
protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List<TestFile> files, @Nullable File javaFilesDir) throws Exception {
TestJdkKind jdkKind = TestJdkKind.MOCK_JDK;
@@ -59,18 +62,26 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "FULL_JDK")) {
jdkKind = TestJdkKind.FULL_JDK;
}
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "NO_KOTLIN_REFLECT")) {
configurationKind = ConfigurationKind.NO_KOTLIN_REFLECT;
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_RUNTIME")) {
addRuntime = true;
}
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_REFLECT")) {
addReflect = true;
}
javacOptions.addAll(InTextDirectivesUtils.findListWithPrefixes(file.content, "// JAVAC_OPTIONS:"));
}
configurationKind =
addReflect ? ConfigurationKind.ALL :
addRuntime ? ConfigurationKind.NO_KOTLIN_REFLECT :
ConfigurationKind.JDK_ONLY;
compileAndRun(files, javaFilesDir, jdkKind, javacOptions);
}
protected void doTestWithStdlib(@NotNull String filename) throws Exception {
configurationKind = ConfigurationKind.ALL;
addReflect = true;
doTest(filename);
}
@@ -7030,11 +7030,83 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/reflection"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("defaultImplsGenericSignature.kt")
public void testDefaultImplsGenericSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/defaultImplsGenericSignature.kt");
doTest(fileName);
}
@TestMetadata("functionLiteralGenericSignature.kt")
public void testFunctionLiteralGenericSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/functionLiteralGenericSignature.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NoKotlinReflect extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInNoKotlinReflect() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/reflection/noKotlinReflect"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("javaClass.kt")
public void testJavaClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/javaClass.kt");
doTest(fileName);
}
@TestMetadata("primitiveJavaClass.kt")
public void testPrimitiveJavaClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/primitiveJavaClass.kt");
doTest(fileName);
}
@TestMetadata("propertyGetSetName.kt")
public void testPropertyGetSetName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/propertyGetSetName.kt");
doTest(fileName);
}
@TestMetadata("propertyInstanceof.kt")
public void testPropertyInstanceof() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/propertyInstanceof.kt");
doTest(fileName);
}
@TestMetadata("reifiedTypeJavaClass.kt")
public void testReifiedTypeJavaClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/reifiedTypeJavaClass.kt");
doTest(fileName);
}
@TestMetadata("simpleClassLiterals.kt")
public void testSimpleClassLiterals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/simpleClassLiterals.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/methodsFromAny")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class MethodsFromAny extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInMethodsFromAny() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/reflection/noKotlinReflect/methodsFromAny"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("callableReferences.kt")
public void testCallableReferences() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/methodsFromAny/callableReferences.kt");
doTest(fileName);
}
@TestMetadata("classReference.kt")
public void testClassReference() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/noKotlinReflect/methodsFromAny/classReference.kt");
doTest(fileName);
}
}
}
}
@TestMetadata("compiler/testData/codegen/box/regressions")
@@ -601,12 +601,6 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
doTest(fileName);
}
@TestMetadata("defaultImplsGenericSignature.kt")
public void testDefaultImplsGenericSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/defaultImplsGenericSignature.kt");
doTest(fileName);
}
@TestMetadata("functionReferenceErasedToKFunction.kt")
public void testFunctionReferenceErasedToKFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithJava/reflection/functionReferenceErasedToKFunction.kt");
@@ -3786,12 +3786,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName);
}
@TestMetadata("kt11121.kt")
public void testKt11121() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/kt11121.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("genericBackingFieldSignature.kt")
public void testGenericBackingFieldSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/genericBackingFieldSignature.kt");
@@ -3804,6 +3798,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName);
}
@TestMetadata("kt11121.kt")
public void testKt11121() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/kt11121.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("kt5112.kt")
public void testKt5112() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/kt5112.kt");
@@ -4153,72 +4153,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
}
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class NoKotlinReflect extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInNoKotlinReflect() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("javaClass.kt")
public void testJavaClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/javaClass.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("primitiveJavaClass.kt")
public void testPrimitiveJavaClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/primitiveJavaClass.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("propertyGetSetName.kt")
public void testPropertyGetSetName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/propertyGetSetName.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("propertyInstanceof.kt")
public void testPropertyInstanceof() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/propertyInstanceof.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("reifiedTypeJavaClass.kt")
public void testReifiedTypeJavaClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/reifiedTypeJavaClass.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("simpleClassLiterals.kt")
public void testSimpleClassLiterals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/simpleClassLiterals.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/methodsFromAny")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class MethodsFromAny extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInMethodsFromAny() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/methodsFromAny"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("callableReferences.kt")
public void testCallableReferences() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/methodsFromAny/callableReferences.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("classReference.kt")
public void testClassReference() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/noKotlinReflect/methodsFromAny/classReference.kt");
doTestWithStdlib(fileName);
}
}
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/parameters")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)