Binding: all current tests are green.
This commit is contained in:
@@ -20,10 +20,7 @@ import com.intellij.openapi.util.text.StringUtil
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParametersContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.util.deepCopy
|
||||
import org.jetbrains.kotlin.ir.util.dump
|
||||
import org.jetbrains.kotlin.ir.util.dumpTreesFromLineNumber
|
||||
@@ -38,9 +35,24 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
override fun doTest(wholeFile: File, testFiles: List<TestFile>) {
|
||||
val dir = wholeFile.parentFile
|
||||
val ignoreErrors = shouldIgnoreErrors(wholeFile)
|
||||
for ((testFile, irFile) in generateIrFilesAsSingleModule(testFiles, ignoreErrors)) {
|
||||
val irModule = generateIrModule(ignoreErrors)
|
||||
|
||||
val ktFiles = testFiles.filter { it.name.endsWith(".kt") }
|
||||
for ((testFile, irFile) in ktFiles.zip(irModule.files)) {
|
||||
doTestIrFileAgainstExpectations(dir, testFile, irFile)
|
||||
}
|
||||
|
||||
if (shouldDumpDependencies(wholeFile)) {
|
||||
doTestIrModuleDependencies(wholeFile, irModule)
|
||||
}
|
||||
}
|
||||
|
||||
private fun doTestIrModuleDependencies(wholeFile: File, irModule: IrModuleFragment) {
|
||||
irModule.dependencyModules.forEach { irDependencyModule ->
|
||||
val actual = irDependencyModule.dump()
|
||||
val expectedFileName = wholeFile.absolutePath.replace(".kt", "__${irDependencyModule.descriptor.name.asString()}.txt")
|
||||
KotlinTestUtils.assertEqualsToFile(File(expectedFileName), actual)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun doTestIrFileAgainstExpectations(dir: File, testFile: TestFile, irFile: IrFile) {
|
||||
@@ -166,6 +178,11 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
||||
private val EXPECTED_OCCURRENCES_PATTERN = Regex("""^\s*//\s*(\d+)\s*(.*)$""")
|
||||
private val IR_FILE_TXT_PATTERN = Regex("""// IR_FILE: (.*)$""")
|
||||
|
||||
private val DUMP_DEPENDENCIES_PATTERN = Regex("""// !DUMP_DEPENDENCIES""")
|
||||
|
||||
internal fun shouldDumpDependencies(wholeFile: File): Boolean =
|
||||
DUMP_DEPENDENCIES_PATTERN.containsMatchIn(wholeFile.readText())
|
||||
|
||||
internal fun parseExpectations(dir: File, testFile: TestFile): Expectations {
|
||||
val regexps = ArrayList<RegexpInText>()
|
||||
val treeFiles = ArrayList<IrTreeFileLabel>()
|
||||
|
||||
@@ -40,6 +40,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Classes extends AbstractIrTextTestCase {
|
||||
@TestMetadata("abstractMembers.kt")
|
||||
public void testAbstractMembers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/classes/abstractMembers.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInClasses() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/classes"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
@@ -1010,4 +1016,19 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase {
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/ir/irText/stubs")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Stubs extends AbstractIrTextTestCase {
|
||||
public void testAllFilesPresentInStubs() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText/stubs"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/stubs/simple.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user