AA: introduce KtConstantEvaluationMode
This commit is contained in:
committed by
Ilya Kirillov
parent
ee23a52e54
commit
606033e1e6
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* 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)
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* 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)
|
||||
+9
-6
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.impl.barebone.test.FrontendApiTestConfiguratorService
|
||||
import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
|
||||
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.test.framework.AbstractHLApiSingleFileTest
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
@@ -15,7 +15,9 @@ import org.jetbrains.kotlin.test.model.TestModule
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.assertions
|
||||
|
||||
abstract class AbstractCompileTimeConstantEvaluatorTest : AbstractHLApiSingleFileTest() {
|
||||
abstract class AbstractCompileTimeConstantEvaluatorTest(
|
||||
private val mode: KtConstantEvaluationMode
|
||||
) : AbstractHLApiSingleFileTest() {
|
||||
override fun doTestByFileStructure(ktFile: KtFile, module: TestModule, testServices: TestServices) {
|
||||
val element = testServices.expressionMarkerProvider.getSelectedElement(ktFile)
|
||||
val expression = when (element) {
|
||||
@@ -24,7 +26,9 @@ abstract class AbstractCompileTimeConstantEvaluatorTest : AbstractHLApiSingleFil
|
||||
else -> null
|
||||
} ?: testServices.assertions.fail { "Unsupported expression: $element" }
|
||||
val constantValue = executeOnPooledThreadInReadAction {
|
||||
analyseForTest(expression) { expression.evaluate() }
|
||||
analyseForTest(expression) {
|
||||
expression.evaluate(mode)
|
||||
}
|
||||
}
|
||||
val actual = buildString {
|
||||
appendLine("expression: ${expression.text}")
|
||||
@@ -33,5 +37,4 @@ abstract class AbstractCompileTimeConstantEvaluatorTest : AbstractHLApiSingleFil
|
||||
}
|
||||
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user