AA: test evaluation mode with same test inputs

This commit is contained in:
Jinseong Jeon
2022-03-10 14:26:13 -08:00
committed by Ilya Kirillov
parent a7fcbfb717
commit 46707b0426
71 changed files with 231 additions and 291 deletions
@@ -1,11 +0,0 @@
/*
* Copyright 2010-2021 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.
*/
package org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider
import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
abstract class AbstractCompileTimeConstantEvaluatorConstantLikeTest
: AbstractCompileTimeConstantEvaluatorTest(KtConstantEvaluationMode.CONSTANT_LIKE_EXPRESSION_EVALUATION)
@@ -1,11 +0,0 @@
/*
* Copyright 2010-2022 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.
*/
package org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider
import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
abstract class AbstractCompileTimeConstantEvaluatorConstantTest
: AbstractCompileTimeConstantEvaluatorTest(KtConstantEvaluationMode.CONSTANT_EXPRESSION_EVALUATION)
@@ -15,9 +15,7 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.services.TestServices
import org.jetbrains.kotlin.test.services.assertions
abstract class AbstractCompileTimeConstantEvaluatorTest(
private val mode: KtConstantEvaluationMode
) : AbstractHLApiSingleFileTest() {
abstract class AbstractCompileTimeConstantEvaluatorTest : AbstractHLApiSingleFileTest() {
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
val element = testServices.expressionMarkerProvider.getSelectedElement(ktFile)
val expression = when (element) {
@@ -27,13 +25,24 @@ abstract class AbstractCompileTimeConstantEvaluatorTest(
} ?: testServices.assertions.fail { "Unsupported expression: $element" }
val constantValue = executeOnPooledThreadInReadAction {
analyseForTest(expression) {
expression.evaluate(mode)
expression.evaluate(KtConstantEvaluationMode.CONSTANT_EXPRESSION_EVALUATION)
}
}
val constantLikeValue = executeOnPooledThreadInReadAction {
analyseForTest(expression) {
expression.evaluate(KtConstantEvaluationMode.CONSTANT_LIKE_EXPRESSION_EVALUATION)
}
}
val actual = buildString {
appendLine("expression: ${expression.text}")
appendLine()
appendLine("CONSTANT_EXPRESSION_EVALUATION")
appendLine("constant: ${constantValue?.renderAsKotlinConstant() ?: "NOT_EVALUATED"}")
appendLine("constantValueKind: ${constantValue?.constantValueKind ?: "NOT_EVALUATED"}")
appendLine()
appendLine("CONSTANT_LIKE_EXPRESSION_EVALUATION")
appendLine("constantLike: ${constantLikeValue?.renderAsKotlinConstant() ?: "NOT_EVALUATED"}")
appendLine("constantLikeValueKind: ${constantLikeValue?.constantValueKind ?: "NOT_EVALUATED"}")
}
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
}