Support test directives in inline tests

This commit is contained in:
Michael Bogdanov
2016-04-03 15:25:36 +03:00
parent d319811101
commit f5166b7aef
61 changed files with 77 additions and 72 deletions
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
fun <T> T.noInline(p: (T) -> Unit) {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
class Z {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
var res = 1
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
var res = 1
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
var res = 1
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package builders
import java.util.ArrayList
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package builders
import java.util.ArrayList
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
public class Input(val s1: String, val s2: String) {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
public class Input(val s1: String, val s2: String) {
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
object ContentTypeByExtension {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline public fun String.run(p1: String? = null): String {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
inline fun <R> call(s: () -> R) = s()
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
inline fun <R> call(s: () -> R) = s()
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
inline fun <R> call(crossinline s: () -> R) = { s() }()
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface Z {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface Z {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface Z<T> {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface Z {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
inline fun Inline.calcExt(s: (Int) -> Int, p: Int) : Int {
return s(p)
}
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline fun foo1() = run {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline fun test(s: () -> Unit) {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline fun <R> mfun(f: () -> R) {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
public class Data(val value: Int)
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
@file:[JvmName("MultifileClass") JvmMultifileClass]
package a
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
public class Holder(var value: String = "") {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
public class Holder(var value: String = "") {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
public interface MCloseable {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
@file:kotlin.jvm.JvmMultifileClass
@file:kotlin.jvm.JvmName("TestKt")
package test
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline fun <reified R> foo() = bar<R>() {"OK"}
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
inline fun <reified R, T> bar(crossinline tasksFactory: () -> T) = {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
class A
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline fun <reified T, reified R>T.castTo(): R = this as R
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
class A
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
class A
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
class A
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
open class TypeRef<T> {
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface Call<T> {
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
public inline fun <reified T : Any> inlineMeIfYouCan(): String? =
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
import java.util.*
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
public abstract class A<T>
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface F<T> {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface F<T> {
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
class B<T>
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
class B<T>
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface F<T> {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
open class Test {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
import java.util.*
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
interface MComparator<T> {
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
inline fun Inline.calcExt(s: (Int) -> Int, p: Int) : Int {
return s(p)
}
+1 -1
View File
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline fun doSmth(vararg a: String) : String {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
package test
inline fun stub() {
@@ -1,5 +1,5 @@
// FILE: 1.kt
// WITH_REFLECT
package test
inline fun <reified T : Any> className() = T::class.java.simpleName
@@ -1,4 +1,5 @@
// FILE: 1.kt
// WITH_RUNTIME
class My(val value: Int)
@@ -55,12 +55,10 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
@Override
protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List<TestFile> files, @Nullable File javaFilesDir) throws Exception {
TestJdkKind jdkKind = TestJdkKind.MOCK_JDK;
TestJdkKind jdkKind = getJdkKind(files);
List<String> javacOptions = new ArrayList<String>(0);
for (TestFile file : files) {
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "FULL_JDK")) {
jdkKind = TestJdkKind.FULL_JDK;
}
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "WITH_RUNTIME")) {
addRuntime = true;
}
@@ -16,15 +16,11 @@
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.test.ConfigurationKind
import java.io.File
abstract class AbstractBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest() {
override fun doMultiFileTest(file: File, files: List<TestFile>, javaFilesDir: File?) {
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, files)
loadMultiFiles(files)
blackBox()
override fun doMultiFileTest(wholeFile: File, files: List<TestFile>, javaFilesDir: File?) {
super.doMultiFileTest(wholeFile, files, javaFilesDir)
try {
InlineTestUtil.checkNoCallsToInline(initializedClassLoader.allGeneratedFiles.filterClassFiles(), myFiles.psiFiles)
SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles())
@@ -69,10 +69,10 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
assert files.size() == 2 : "There should be exactly two files in this test";
TestFile fileA = files.get(0);
TestFile fileB = files.get(1);
ClassFileFactory factoryA = compileA(fileA.name, fileA.content);
ClassFileFactory factoryA = compileA(fileA.name, fileA.content, files);
ClassFileFactory factoryB = null;
try {
factoryB = compileB(fileB.name, fileB.content);
factoryB = compileB(fileB.name, fileB.content, files);
invokeBox(PackagePartClassUtils.getFilePartShortName(new File(fileB.name).getName()));
}
catch (Throwable e) {
@@ -101,16 +101,16 @@ public abstract class AbstractCompileKotlinAgainstKotlinTest extends CodegenTest
}
@NotNull
protected ClassFileFactory compileA(@NotNull String fileName, @NotNull String content) throws IOException {
protected ClassFileFactory compileA(@NotNull String fileName, @NotNull String content, List<TestFile> files) throws IOException {
KotlinCoreEnvironment environment =
KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(getTestRootDisposable(), ConfigurationKind.ALL);
KotlinTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(getTestRootDisposable(), ConfigurationKind.ALL, getJdkKind(files));
return compileKotlin(fileName, content, aDir, environment, getTestRootDisposable());
}
@NotNull
protected ClassFileFactory compileB(@NotNull String fileName, @NotNull String content) throws IOException {
protected ClassFileFactory compileB(@NotNull String fileName, @NotNull String content, List<TestFile> files) throws IOException {
CompilerConfiguration configurationWithADirInClasspath = KotlinTestUtils
.compilerConfigurationForTests(ConfigurationKind.ALL, TestJdkKind.MOCK_JDK, KotlinTestUtils.getAnnotationsJar(), aDir);
.compilerConfigurationForTests(ConfigurationKind.ALL, getJdkKind(files), KotlinTestUtils.getAnnotationsJar(), aDir);
KotlinCoreEnvironment environment =
KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configurationWithADirInClasspath, EnvironmentConfigFiles.JVM_CONFIG_FILES);
@@ -91,6 +91,16 @@ public abstract class CodegenTestCase extends UsefulTestCase {
createEnvironmentWithMockJdkAndIdeaAnnotations(configurationKind, Collections.<TestFile>emptyList(), javaSourceRoots);
}
@NotNull
protected static TestJdkKind getJdkKind(@NotNull List<TestFile> files) {
for (TestFile file : files) {
if (InTextDirectivesUtils.isDirectiveDefined(file.content, "FULL_JDK")) {
return TestJdkKind.FULL_JDK;
}
}
return TestJdkKind.MOCK_JDK;
}
protected final void createEnvironmentWithMockJdkAndIdeaAnnotations(
@NotNull ConfigurationKind configurationKind,
@NotNull List<TestFile> testFilesWithConfigurationDirectives,