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,60 +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.fe10.components.compileTimeConstantProvider;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.FrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.descriptors.test.KtFe10FrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorConstantTest;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant")
@TestDataPath("$PROJECT_ROOT")
public class Fe10CompileTimeConstantEvaluatorConstantTestGenerated extends AbstractCompileTimeConstantEvaluatorConstantTest {
@NotNull
@Override
public FrontendApiTestConfiguratorService getConfigurator() {
return KtFe10FrontendApiTestConfiguratorService.INSTANCE;
}
@Test
public void testAllFilesPresentInEvaluate_constant() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("namedReference_const.kt")
public void testNamedReference_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/namedReference_const.kt");
}
@Test
@TestMetadata("namedReference_val.kt")
public void testNamedReference_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/namedReference_val.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_const.kt")
public void testPropertyInit_DivByOtherProperty_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/propertyInit_DivByOtherProperty_const.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_val.kt")
public void testPropertyInit_DivByOtherProperty_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/propertyInit_DivByOtherProperty_val.kt");
}
}
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.FrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.descriptors.test.KtFe10FrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorConstantLikeTest;
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorTest;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -20,9 +20,9 @@ import java.util.regex.Pattern;
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike")
@TestMetadata("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate")
@TestDataPath("$PROJECT_ROOT")
public class Fe10CompileTimeConstantEvaluatorConstantLikeTestGenerated extends AbstractCompileTimeConstantEvaluatorConstantLikeTest {
public class Fe10CompileTimeConstantEvaluatorTestGenerated extends AbstractCompileTimeConstantEvaluatorTest {
@NotNull
@Override
public FrontendApiTestConfiguratorService getConfigurator() {
@@ -30,109 +30,109 @@ public class Fe10CompileTimeConstantEvaluatorConstantLikeTestGenerated extends A
}
@Test
public void testAllFilesPresentInEvaluate_constantLike() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike"), Pattern.compile("^(.+)\\.kt$"), null, true);
public void testAllFilesPresentInEvaluate() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("binaryExpressionWithString.kt")
public void testBinaryExpressionWithString() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/binaryExpressionWithString.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/binaryExpressionWithString.kt");
}
@Test
@TestMetadata("namedReference_const.kt")
public void testNamedReference_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/namedReference_const.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/namedReference_const.kt");
}
@Test
@TestMetadata("namedReference_val.kt")
public void testNamedReference_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/namedReference_val.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/namedReference_val.kt");
}
@Test
@TestMetadata("namedReference_var.kt")
public void testNamedReference_var() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/namedReference_var.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/namedReference_var.kt");
}
@Test
@TestMetadata("propertyInCompanionObject.kt")
public void testPropertyInCompanionObject() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInCompanionObject.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInCompanionObject.kt");
}
@Test
@TestMetadata("propertyInCompanionObject_indirect.kt")
public void testPropertyInCompanionObject_indirect() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInCompanionObject_indirect.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInCompanionObject_indirect.kt");
}
@Test
@TestMetadata("propertyInCompanionObject_indirect_twice.kt")
public void testPropertyInCompanionObject_indirect_twice() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInCompanionObject_indirect_twice.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInCompanionObject_indirect_twice.kt");
}
@Test
@TestMetadata("propertyInit_Byte.kt")
public void testPropertyInit_Byte() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Byte.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Byte.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_const.kt")
public void testPropertyInit_DivByOtherProperty_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_DivByOtherProperty_const.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_DivByOtherProperty_const.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_val.kt")
public void testPropertyInit_DivByOtherProperty_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_DivByOtherProperty_val.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_DivByOtherProperty_val.kt");
}
@Test
@TestMetadata("propertyInit_DivByZero.kt")
public void testPropertyInit_DivByZero() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_DivByZero.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_DivByZero.kt");
}
@Test
@TestMetadata("propertyInit_Double.kt")
public void testPropertyInit_Double() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Double.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Double.kt");
}
@Test
@TestMetadata("propertyInit_Float.kt")
public void testPropertyInit_Float() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Float.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Float.kt");
}
@Test
@TestMetadata("propertyInit_Int.kt")
public void testPropertyInit_Int() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Int.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Int.kt");
}
@Test
@TestMetadata("propertyInit_Long.kt")
public void testPropertyInit_Long() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Long.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Long.kt");
}
@Test
@TestMetadata("propertyInit_UInt.kt")
public void testPropertyInit_UInt() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_UInt.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_UInt.kt");
}
@Test
@TestMetadata("stringLiteral.kt")
public void testStringLiteral() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/stringLiteral.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/stringLiteral.kt");
}
}
@@ -1,60 +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.fir.components.compileTimeConstantProvider;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.FrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.fir.FirFrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorConstantTest;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant")
@TestDataPath("$PROJECT_ROOT")
public class FirCompileTimeConstantEvaluatorConstantTestGenerated extends AbstractCompileTimeConstantEvaluatorConstantTest {
@NotNull
@Override
public FrontendApiTestConfiguratorService getConfigurator() {
return FirFrontendApiTestConfiguratorService.INSTANCE;
}
@Test
public void testAllFilesPresentInEvaluate_constant() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("namedReference_const.kt")
public void testNamedReference_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/namedReference_const.kt");
}
@Test
@TestMetadata("namedReference_val.kt")
public void testNamedReference_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/namedReference_val.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_const.kt")
public void testPropertyInit_DivByOtherProperty_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/propertyInit_DivByOtherProperty_const.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_val.kt")
public void testPropertyInit_DivByOtherProperty_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constant/propertyInit_DivByOtherProperty_val.kt");
}
}
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.FrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.fir.FirFrontendApiTestConfiguratorService;
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorConstantLikeTest;
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorTest;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
@@ -20,9 +20,9 @@ import java.util.regex.Pattern;
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike")
@TestMetadata("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate")
@TestDataPath("$PROJECT_ROOT")
public class FirCompileTimeConstantEvaluatorConstantLikeTestGenerated extends AbstractCompileTimeConstantEvaluatorConstantLikeTest {
public class FirCompileTimeConstantEvaluatorTestGenerated extends AbstractCompileTimeConstantEvaluatorTest {
@NotNull
@Override
public FrontendApiTestConfiguratorService getConfigurator() {
@@ -30,109 +30,109 @@ public class FirCompileTimeConstantEvaluatorConstantLikeTestGenerated extends Ab
}
@Test
public void testAllFilesPresentInEvaluate_constantLike() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike"), Pattern.compile("^(.+)\\.kt$"), null, true);
public void testAllFilesPresentInEvaluate() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("binaryExpressionWithString.kt")
public void testBinaryExpressionWithString() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/binaryExpressionWithString.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/binaryExpressionWithString.kt");
}
@Test
@TestMetadata("namedReference_const.kt")
public void testNamedReference_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/namedReference_const.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/namedReference_const.kt");
}
@Test
@TestMetadata("namedReference_val.kt")
public void testNamedReference_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/namedReference_val.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/namedReference_val.kt");
}
@Test
@TestMetadata("namedReference_var.kt")
public void testNamedReference_var() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/namedReference_var.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/namedReference_var.kt");
}
@Test
@TestMetadata("propertyInCompanionObject.kt")
public void testPropertyInCompanionObject() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInCompanionObject.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInCompanionObject.kt");
}
@Test
@TestMetadata("propertyInCompanionObject_indirect.kt")
public void testPropertyInCompanionObject_indirect() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInCompanionObject_indirect.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInCompanionObject_indirect.kt");
}
@Test
@TestMetadata("propertyInCompanionObject_indirect_twice.kt")
public void testPropertyInCompanionObject_indirect_twice() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInCompanionObject_indirect_twice.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInCompanionObject_indirect_twice.kt");
}
@Test
@TestMetadata("propertyInit_Byte.kt")
public void testPropertyInit_Byte() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Byte.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Byte.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_const.kt")
public void testPropertyInit_DivByOtherProperty_const() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_DivByOtherProperty_const.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_DivByOtherProperty_const.kt");
}
@Test
@TestMetadata("propertyInit_DivByOtherProperty_val.kt")
public void testPropertyInit_DivByOtherProperty_val() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_DivByOtherProperty_val.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_DivByOtherProperty_val.kt");
}
@Test
@TestMetadata("propertyInit_DivByZero.kt")
public void testPropertyInit_DivByZero() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_DivByZero.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_DivByZero.kt");
}
@Test
@TestMetadata("propertyInit_Double.kt")
public void testPropertyInit_Double() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Double.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Double.kt");
}
@Test
@TestMetadata("propertyInit_Float.kt")
public void testPropertyInit_Float() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Float.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Float.kt");
}
@Test
@TestMetadata("propertyInit_Int.kt")
public void testPropertyInit_Int() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Int.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Int.kt");
}
@Test
@TestMetadata("propertyInit_Long.kt")
public void testPropertyInit_Long() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_Long.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_Long.kt");
}
@Test
@TestMetadata("propertyInit_UInt.kt")
public void testPropertyInit_UInt() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/propertyInit_UInt.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/propertyInit_UInt.kt");
}
@Test
@TestMetadata("stringLiteral.kt")
public void testStringLiteral() throws Exception {
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate_constantLike/stringLiteral.kt");
runTest("analysis/analysis-api/testData/components/compileTimeConstantProvider/evaluate/stringLiteral.kt");
}
}
@@ -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)
}
@@ -0,0 +1,9 @@
expression: "message" + msg
CONSTANT_EXPRESSION_EVALUATION
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: NOT_EVALUATED
constantLikeValueKind: NOT_EVALUATED
@@ -0,0 +1,9 @@
expression: bar
CONSTANT_EXPRESSION_EVALUATION
constant: 42
constantValueKind: Int
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Int
@@ -0,0 +1,9 @@
expression: bar
CONSTANT_EXPRESSION_EVALUATION
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Int
@@ -0,0 +1,9 @@
expression: bar
CONSTANT_EXPRESSION_EVALUATION
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: NOT_EVALUATED
constantLikeValueKind: NOT_EVALUATED
@@ -0,0 +1,9 @@
expression: someField
CONSTANT_EXPRESSION_EVALUATION
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: "something"
constantLikeValueKind: String
@@ -0,0 +1,9 @@
expression: indirectPointer
CONSTANT_EXPRESSION_EVALUATION
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: "something"
constantLikeValueKind: String
@@ -0,0 +1,9 @@
expression: oneMore
CONSTANT_EXPRESSION_EVALUATION
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: "something"
constantLikeValueKind: String
@@ -0,0 +1,9 @@
expression: 42
CONSTANT_EXPRESSION_EVALUATION
constant: 42
constantValueKind: Byte
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Byte
@@ -0,0 +1,9 @@
expression: 42 / d
CONSTANT_EXPRESSION_EVALUATION
constant: 42
constantValueKind: Int
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Int
@@ -0,0 +1,9 @@
expression: 42 / d
CONSTANT_EXPRESSION_EVALUATION
constant: 42
constantValueKind: Int
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Int
@@ -0,0 +1,9 @@
expression: 42 / d
CONSTANT_EXPRESSION_EVALUATION
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Int
@@ -0,0 +1,9 @@
expression: 42 / 0
CONSTANT_EXPRESSION_EVALUATION
constant: error("Division by zero")
constantValueKind: Error
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: error("Division by zero")
constantLikeValueKind: Error
@@ -0,0 +1,9 @@
expression: 42 / 0
CONSTANT_EXPRESSION_EVALUATION
constant: error("/ by zero")
constantValueKind: Error
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: error("/ by zero")
constantLikeValueKind: Error
@@ -0,0 +1,9 @@
expression: 3.14
CONSTANT_EXPRESSION_EVALUATION
constant: 3.14
constantValueKind: Double
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 3.14
constantLikeValueKind: Double
@@ -0,0 +1,9 @@
expression: 3.14f
CONSTANT_EXPRESSION_EVALUATION
constant: 3.14f
constantValueKind: Float
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 3.14f
constantLikeValueKind: Float
@@ -0,0 +1,9 @@
expression: 42
CONSTANT_EXPRESSION_EVALUATION
constant: 42
constantValueKind: Int
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Int
@@ -0,0 +1,9 @@
expression: 42
CONSTANT_EXPRESSION_EVALUATION
constant: 42
constantValueKind: Long
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42
constantLikeValueKind: Long
@@ -0,0 +1,9 @@
expression: 42u
CONSTANT_EXPRESSION_EVALUATION
constant: 42u
constantValueKind: UInt
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: 42u
constantLikeValueKind: UInt
@@ -0,0 +1,9 @@
expression: "42"
CONSTANT_EXPRESSION_EVALUATION
constant: "42"
constantValueKind: String
CONSTANT_LIKE_EXPRESSION_EVALUATION
constantLike: "42"
constantLikeValueKind: String
@@ -1,3 +0,0 @@
expression: bar
constant: 42
constantValueKind: Int
@@ -1,3 +0,0 @@
expression: bar
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -1,4 +0,0 @@
class Test {
val p = <expr>42 / d</expr> // uninitialized d
const val d = 1
}
@@ -1,3 +0,0 @@
expression: 42 / d
constant: 42
constantValueKind: Int
@@ -1,3 +0,0 @@
expression: 42 / d
constant: error("Division by zero")
constantValueKind: Error
@@ -1,5 +0,0 @@
class Test {
val p = <expr>42 / d</expr> // uninitialized d
val d = 0 // should not raise div-by-zero error
}
@@ -1,3 +0,0 @@
expression: 42 / d
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -1,3 +0,0 @@
expression: "message" + msg
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -1,8 +0,0 @@
class Test {
const val bar : Int = 42
}
fun box() {
val t = Test()
t.<expr>bar</expr>
}
@@ -1,3 +0,0 @@
expression: bar
constant: 42
constantValueKind: Int
@@ -1,8 +0,0 @@
class Test {
val bar : Int = 42
}
fun box() {
val t = Test()
t.<expr>bar</expr>
}
@@ -1,3 +0,0 @@
expression: bar
constant: 42
constantValueKind: Int
@@ -1,3 +0,0 @@
expression: bar
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -1,3 +0,0 @@
expression: someField
constant: "something"
constantValueKind: String
@@ -1,3 +0,0 @@
expression: indirectPointer
constant: "something"
constantValueKind: String
@@ -1,3 +0,0 @@
expression: oneMore
constant: "something"
constantValueKind: String
@@ -1,3 +0,0 @@
expression: 42
constant: 42
constantValueKind: Byte
@@ -1,3 +0,0 @@
expression: 42 / d
constant: 42
constantValueKind: Int
@@ -1,3 +0,0 @@
expression: 42 / d
constant: 42
constantValueKind: Int
@@ -1,3 +0,0 @@
expression: 42 / 0
constant: error("Division by zero")
constantValueKind: Error
@@ -1,3 +0,0 @@
expression: 42 / 0
constant: error("/ by zero")
constantValueKind: Error
@@ -1,3 +0,0 @@
expression: 3.14
constant: 3.14
constantValueKind: Double
@@ -1,3 +0,0 @@
expression: 3.14f
constant: 3.14f
constantValueKind: Float
@@ -1,3 +0,0 @@
expression: 42
constant: 42
constantValueKind: Int
@@ -1,3 +0,0 @@
expression: 42
constant: 42
constantValueKind: Long
@@ -1,3 +0,0 @@
expression: 42u
constant: 42u
constantValueKind: UInt
@@ -1,3 +0,0 @@
expression: "42"
constant: "42"
constantValueKind: String
@@ -15,8 +15,7 @@ import org.jetbrains.kotlin.analysis.api.impl.base.test.annotations.AbstractAnal
import org.jetbrains.kotlin.analysis.api.impl.base.test.annotations.AbstractAnalysisApiAnnotationsOnTypesTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.AbstractResolveCallTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.AbstractResolveCandidatesTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorConstantLikeTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorConstantTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.compileTimeConstantProvider.AbstractCompileTimeConstantEvaluatorTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.diagnosticProvider.AbstractCollectDiagnosticsTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.expressionInfoProvider.AbstractReturnTargetSymbolTest
import org.jetbrains.kotlin.analysis.api.impl.base.test.components.expressionInfoProvider.AbstractWhenMissingCasesTest
@@ -144,11 +143,8 @@ private fun TestGroupSuite.generateAnalysisApiComponentsTests() {
}
component("compileTimeConstantProvider") {
test(AbstractCompileTimeConstantEvaluatorConstantTest::class) {
model("evaluate_constant")
}
test(AbstractCompileTimeConstantEvaluatorConstantLikeTest::class) {
model("evaluate_constantLike")
test(AbstractCompileTimeConstantEvaluatorTest::class) {
model("evaluate")
}
}