Migrate AbstractIrCheckLocalVariablesTableTest to CodegenTestCase stuff
This commit is contained in:
+1
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
data class Data(val x: String, val y: Int)
|
||||
|
||||
suspend fun test() {
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
class A<T>(val x: String, val y: String, val z: T)
|
||||
|
||||
suspend fun <T> foo(a: A<T>, block: suspend (A<T>) -> String): String = block(a)
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
|
||||
data class A<T, F>(val x: T, val y: F)
|
||||
|
||||
suspend fun <X, Y> foo(a: A<X, Y>, block: suspend (A<X, Y>) -> String) = block(a)
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
data class A(val x: String, val y: String)
|
||||
|
||||
suspend inline fun foo(a: A, block: suspend (A) -> String): String = block(a)
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
class A {
|
||||
operator fun component1() = "O"
|
||||
operator fun component2(): String = throw RuntimeException("fail 0")
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// WITH_RUNTIME
|
||||
class C {
|
||||
@kotlin.jvm.JvmOverloads fun foo(firstParam: Int, secondParam: String = "") {
|
||||
}
|
||||
|
||||
+8
-27
@@ -21,12 +21,10 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFile;
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection;
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
|
||||
import java.io.File;
|
||||
@@ -41,32 +39,14 @@ import java.util.regex.Pattern;
|
||||
* Test correctness of written local variables in class file for specified method
|
||||
*/
|
||||
|
||||
public abstract class AbstractCheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
||||
public abstract class AbstractCheckLocalVariablesTableTest extends CodegenTestCase {
|
||||
protected File ktFile;
|
||||
protected KotlinCoreEnvironment environment;
|
||||
|
||||
public AbstractCheckLocalVariablesTableTest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
environment = KotlinTestUtils.createEnvironmentWithMockJdkAndIdeaAnnotations(myTestRootDisposable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
environment = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected void doTest(@NotNull String ktFileName) throws Exception {
|
||||
ktFile = new File(ktFileName);
|
||||
protected void doMultiFileTest(@NotNull File wholeFile, @NotNull List<TestFile> files, @Nullable File javaFilesDir) throws Exception {
|
||||
ktFile = wholeFile;
|
||||
String text = FileUtil.loadFile(ktFile, true);
|
||||
|
||||
KtFile psiFile = KotlinTestUtils.createFile(ktFile.getName(), text, environment.getProject());
|
||||
|
||||
OutputFileCollection outputFiles = GenerationUtils.compileFile(psiFile, environment);
|
||||
compile(files, javaFilesDir);
|
||||
|
||||
String classAndMethod = parseClassAndMethodSignature();
|
||||
String[] split = classAndMethod.split("\\.");
|
||||
@@ -74,9 +54,10 @@ public abstract class AbstractCheckLocalVariablesTableTest extends TestCaseWithT
|
||||
String classFileRegex = StringUtil.escapeToRegexp(split[0] + ".class").replace("\\*", ".+");
|
||||
String methodName = split[1];
|
||||
|
||||
OutputFile outputFile = ContainerUtil.find(outputFiles.asList(), file -> file.getRelativePath().matches(classFileRegex));
|
||||
List<OutputFile> outputFiles = ((OutputFileCollection) classFileFactory).asList();
|
||||
OutputFile outputFile = ContainerUtil.find(outputFiles, file -> file.getRelativePath().matches(classFileRegex));
|
||||
|
||||
String pathsString = StringUtil.join(outputFiles.asList(), OutputFile::getRelativePath, ", ");
|
||||
String pathsString = StringUtil.join(outputFiles, OutputFile::getRelativePath, ", ");
|
||||
assertNotNull("Couldn't find class file for pattern " + classFileRegex + " in: " + pathsString, outputFile);
|
||||
|
||||
ClassReader cr = new ClassReader(outputFile.asByteArray());
|
||||
|
||||
+9
-5
@@ -7,16 +7,20 @@ package org.jetbrains.kotlin.codegen.ir
|
||||
|
||||
import com.intellij.openapi.util.Comparing
|
||||
import org.jetbrains.kotlin.codegen.AbstractCheckLocalVariablesTableTest
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.junit.ComparisonFailure
|
||||
import java.nio.charset.Charset
|
||||
|
||||
abstract class AbstractIrCheckLocalVariablesTableTest : AbstractCheckLocalVariablesTableTest() {
|
||||
@Throws(Exception::class)
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
assert(environment != null)
|
||||
environment.configuration.put(JVMConfigurationKeys.IR, true)
|
||||
|
||||
override fun updateConfiguration(configuration: CompilerConfiguration) {
|
||||
configuration.put(JVMConfigurationKeys.IR, true)
|
||||
}
|
||||
|
||||
override fun extractConfigurationKind(files: MutableList<TestFile>): ConfigurationKind {
|
||||
return ConfigurationKind.ALL;
|
||||
}
|
||||
|
||||
override fun doCompare(text: String?, actualLocalVariables: MutableList<LocalVariable>) {
|
||||
|
||||
Reference in New Issue
Block a user