Normalize names of temporary variables in IrTextTests

This commit is contained in:
Steven Schäfer
2019-11-01 12:35:22 +01:00
committed by Mikhail Glukhikh
parent 740f851a10
commit 733c7579aa
73 changed files with 666 additions and 701 deletions
@@ -105,17 +105,6 @@ abstract class AbstractIrGeneratorTestCase : CodegenTestCase() {
internal fun shouldIgnoreErrors(wholeFile: File): Boolean =
IGNORE_ERRORS_PATTERN.containsMatchIn(wholeFile.readText())
fun createExpectedTextFile(testFile: TestFile, dir: File, fileName: String): File {
val textFile = File(dir, fileName)
if (!textFile.exists()) {
TestCase.assertTrue("Can't create an expected text containingFile: ${textFile.absolutePath}", textFile.createNewFile())
PrintWriter(FileWriter(textFile)).use {
it.println("$fileName: new expected text containingFile for ${testFile.name}")
}
}
return textFile
}
fun generateIrModuleWithJsResolve(
ktFilesToAnalyze: List<KtFile>, environment: KotlinCoreEnvironment, psi2ir: Psi2IrTranslator
): IrModuleFragment =
@@ -103,7 +103,7 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
if (testFile.isExternalFile()) return
val expectations = parseExpectations(dir, testFile)
val irFileDump = irFile.dump()
val irFileDump = irFile.dump(normalizeNames = true)
val expected = StringBuilder()
val actual = StringBuilder()
@@ -114,13 +114,13 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
}
for (irTreeFileLabel in expectations.irTreeFileLabels) {
val actualTrees = irFile.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber)
val actualTrees = irFile.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber, normalizeNames = true)
KotlinTestUtils.assertEqualsToFile(irTreeFileLabel.expectedTextFile, actualTrees)
verify(irFile)
// Check that deep copy produces an equivalent result
val irFileCopy = irFile.deepCopyWithSymbols()
val copiedTrees = irFileCopy.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber)
val copiedTrees = irFileCopy.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber, normalizeNames = true)
TestCase.assertEquals("IR dump mismatch after deep copy with symbols", actualTrees, copiedTrees)
verify(irFileCopy)
}
@@ -347,12 +347,12 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
var treeFiles =
testFile.content.matchLinesWith(IR_FILE_TXT_PATTERN) {
val fileName = it.groupValues[1].trim()
val file = createExpectedTextFile(testFile, dir, getExpectedTextFileName(testFile, fileName))
val file = File(dir, getExpectedTextFileName(testFile, fileName))
IrTreeFileLabel(file, 0)
}
if (treeFiles.isEmpty()) {
val file = createExpectedTextFile(testFile, dir, getExpectedTextFileName(testFile))
val file = File(dir, getExpectedTextFileName(testFile))
treeFiles = listOf(IrTreeFileLabel(file, 0))
}