[IR] hack AbstractIrTextTestCase to test dumpKotlinLike
This commit is contained in:
committed by
teamcityserver
parent
6241f9be2d
commit
d2022ab115
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.ir
|
package org.jetbrains.kotlin.ir
|
||||||
@@ -39,6 +28,7 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.scripting.compiler.plugin.loadScriptConfiguration
|
import org.jetbrains.kotlin.scripting.compiler.plugin.loadScriptConfiguration
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
|
||||||
|
import org.jetbrains.kotlin.utils.fileUtils.withReplacedExtensionOrNull
|
||||||
import org.jetbrains.kotlin.utils.rethrow
|
import org.jetbrains.kotlin.utils.rethrow
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
@@ -123,6 +113,20 @@ abstract class AbstractIrTextTestCase : AbstractIrGeneratorTestCase() {
|
|||||||
KotlinTestUtils.assertEqualsToFile(irTreeFileLabel.expectedTextFile, actualTrees)
|
KotlinTestUtils.assertEqualsToFile(irTreeFileLabel.expectedTextFile, actualTrees)
|
||||||
verify(irFile)
|
verify(irFile)
|
||||||
|
|
||||||
|
val kotlinLikeDump = irFile.dumpKotlinLike(
|
||||||
|
KotlinLikeDumpOptions(
|
||||||
|
printFileName = false,
|
||||||
|
printFilePath = false,
|
||||||
|
printFakeOverridesStrategy = FakeOverridesStrategy.NONE
|
||||||
|
)
|
||||||
|
)
|
||||||
|
val kotlinLikeDumpExpectedFile = irTreeFileLabel.expectedTextFile.withReplacedExtensionOrNull(".txt", ".kt.txt")!!
|
||||||
|
// KotlinTestUtils.assertEqualsToFile(kotlinLikeDumpExpectedFile, kotlinLikeDump)
|
||||||
|
|
||||||
|
val kotlinLikeDumpExpectedText = if (kotlinLikeDumpExpectedFile.exists()) kotlinLikeDumpExpectedFile.readText() else ""
|
||||||
|
kotlinLikeDumpExpectedFile.writeText(kotlinLikeDump)
|
||||||
|
assertEquals(kotlinLikeDumpExpectedText, kotlinLikeDump)
|
||||||
|
|
||||||
// Check that deep copy produces an equivalent result
|
// Check that deep copy produces an equivalent result
|
||||||
val irFileCopy = irFile.deepCopyWithSymbols()
|
val irFileCopy = irFile.deepCopyWithSymbols()
|
||||||
val copiedTrees = irFileCopy.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber, normalizeNames = true)
|
val copiedTrees = irFileCopy.dumpTreesFromLineNumber(irTreeFileLabel.lineNumber, normalizeNames = true)
|
||||||
|
|||||||
Reference in New Issue
Block a user