Move FIR tests to fir modules
This commit is contained in:
committed by
Mikhail Glukhikh
parent
95af0268b8
commit
cfb446df9e
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.fir
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveTransformer
|
||||
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.impl.*
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFirResolveTestCase : AbstractFirResolveWithSessionTestCase() {
|
||||
override fun createEnvironment(): KotlinCoreEnvironment {
|
||||
return createEnvironmentWithMockJdk(ConfigurationKind.JDK_NO_RUNTIME)
|
||||
}
|
||||
|
||||
fun doCreateAndProcessFir(ktFiles: List<KtFile>): List<FirFile> {
|
||||
val session = createSession()
|
||||
|
||||
val builder = RawFirBuilder(session)
|
||||
|
||||
val transformer = FirTotalResolveTransformer()
|
||||
val firFiles = ktFiles.map {
|
||||
val firFile = builder.buildFirFile(it)
|
||||
(session.service<FirProvider>() as FirProviderImpl).recordFile(firFile)
|
||||
firFile
|
||||
}.also {
|
||||
try {
|
||||
transformer.processFiles(it)
|
||||
} catch (e: Exception) {
|
||||
it.forEach { println(it.render()) }
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
return firFiles
|
||||
}
|
||||
|
||||
|
||||
fun doTest(path: String) {
|
||||
val file = File(path)
|
||||
|
||||
val allFiles = listOf(file) + file.parentFile.listFiles { sibling ->
|
||||
sibling.name.removePrefix(file.nameWithoutExtension).removeSuffix(file.extension).matches("\\.[0-9]+\\.".toRegex())
|
||||
}
|
||||
|
||||
val ktFiles =
|
||||
allFiles.map {
|
||||
val text = KotlinTestUtils.doLoadFile(it)
|
||||
it.name to text
|
||||
}
|
||||
.sortedBy { (_, text) ->
|
||||
KotlinTestUtils.parseDirectives(text)["analyzePriority"]?.toInt()
|
||||
}
|
||||
.map { (name, text) ->
|
||||
KotlinTestUtils.createFile(name, text, project)
|
||||
}
|
||||
|
||||
val firFiles = doCreateAndProcessFir(ktFiles)
|
||||
|
||||
val firFileDump = StringBuilder().also { firFiles.first().accept(FirRenderer(it), null) }.toString()
|
||||
val expectedPath = path.replace(".kt", ".txt")
|
||||
KotlinTestUtils.assertEqualsToFile(File(expectedPath), firFileDump)
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.fir
|
||||
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
|
||||
abstract class AbstractFirResolveTestCaseWithStdlib : AbstractFirResolveTestCase() {
|
||||
override fun createEnvironment(): KotlinCoreEnvironment {
|
||||
return createEnvironmentWithJdk(ConfigurationKind.ALL, TestJdkKind.FULL_JDK)
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.java.JavaSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.FirQualifierResolver
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.FirTypeResolver
|
||||
import org.jetbrains.kotlin.fir.resolve.impl.*
|
||||
import org.jetbrains.kotlin.test.KotlinTestWithEnvironment
|
||||
|
||||
abstract class AbstractFirResolveWithSessionTestCase : KotlinTestWithEnvironment() {
|
||||
|
||||
open fun createSession(): FirSession {
|
||||
return object : FirSessionBase() {
|
||||
init {
|
||||
val firProvider = FirProviderImpl(this)
|
||||
registerComponent(FirProvider::class, firProvider)
|
||||
registerComponent(
|
||||
FirSymbolProvider::class,
|
||||
FirCompositeSymbolProvider(listOf(firProvider, JavaSymbolProvider(project), FirLibrarySymbolProviderImpl(this)))
|
||||
)
|
||||
registerComponent(FirQualifierResolver::class, FirQualifierResolverImpl(this))
|
||||
registerComponent(FirTypeResolver::class, FirTypeResolverImpl())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,230 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.fir;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/fir/resolve")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInResolve() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/fir/resolve"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true, "stdlib");
|
||||
}
|
||||
|
||||
@TestMetadata("companion.kt")
|
||||
public void testCompanion() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/companion.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("derivedClass.kt")
|
||||
public void testDerivedClass() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/derivedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/enum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("F.kt")
|
||||
public void testF() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/F.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ft.kt")
|
||||
public void testFt() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/ft.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionTypes.kt")
|
||||
public void testFunctionTypes() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/functionTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericFunctions.kt")
|
||||
public void testGenericFunctions() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/genericFunctions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/nestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedOfAliasedType.kt")
|
||||
public void testNestedOfAliasedType() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/NestedOfAliasedType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedSuperType.kt")
|
||||
public void testNestedSuperType() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/NestedSuperType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleClass.kt")
|
||||
public void testSimpleClass() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/simpleClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleTypeAlias.kt")
|
||||
public void testSimpleTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/simpleTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("treeSet.kt")
|
||||
public void testTreeSet() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/treeSet.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TwoDeclarationsInSameFile.kt")
|
||||
public void testTwoDeclarationsInSameFile() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/TwoDeclarationsInSameFile.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasWithGeneric.kt")
|
||||
public void testTypeAliasWithGeneric() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/typeAliasWithGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterInPropertyReceiver.kt")
|
||||
public void testTypeParameterInPropertyReceiver() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/typeParameterInPropertyReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterVsNested.kt")
|
||||
public void testTypeParameterVsNested() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/typeParameterVsNested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/fir/resolve/builtins")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Builtins extends AbstractFirResolveTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInBuiltins() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/fir/resolve/builtins"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("lists.kt")
|
||||
public void testLists() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/builtins/lists.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/fir/resolve/fromBuilder")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class FromBuilder extends AbstractFirResolveTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInFromBuilder() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/fir/resolve/fromBuilder"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("complexTypes.kt")
|
||||
public void testComplexTypes() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/fromBuilder/complexTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/fromBuilder/enums.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noPrimaryConstructor.kt")
|
||||
public void testNoPrimaryConstructor() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/fromBuilder/noPrimaryConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleClass.kt")
|
||||
public void testSimpleClass() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/fromBuilder/simpleClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameters.kt")
|
||||
public void testTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/fromBuilder/typeParameters.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/fir/resolve/multifile")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Multifile extends AbstractFirResolveTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInMultifile() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/fir/resolve/multifile"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("Annotations.kt")
|
||||
public void testAnnotations() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/Annotations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedSuperType.kt")
|
||||
public void testNestedSuperType() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/NestedSuperType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sealedStarImport.kt")
|
||||
public void testSealedStarImport() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/sealedStarImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleAliasedImport.kt")
|
||||
public void testSimpleAliasedImport() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/simpleAliasedImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleImport.kt")
|
||||
public void testSimpleImport() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/simpleImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleImportNested.kt")
|
||||
public void testSimpleImportNested() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/simpleImportNested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleImportOuter.kt")
|
||||
public void testSimpleImportOuter() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/simpleImportOuter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleStarImport.kt")
|
||||
public void testSimpleStarImport() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/simpleStarImport.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("TypeAliasExpansion.kt")
|
||||
public void testTypeAliasExpansion() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/multifile/TypeAliasExpansion.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.fir;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/fir/resolve/stdlib")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class FirResolveTestCaseWithStdlibGenerated extends AbstractFirResolveTestCaseWithStdlib {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInStdlib() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/fir/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("concurrent.kt")
|
||||
public void testConcurrent() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/stdlib/concurrent.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionX.kt")
|
||||
public void testFunctionX() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/stdlib/functionX.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reflectionClass.kt")
|
||||
public void testReflectionClass() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/stdlib/reflectionClass.kt");
|
||||
}
|
||||
}
|
||||
-134
@@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.fir.builder;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("compiler/testData/fir/rawBuilder")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class RawFirBuilderTestCaseGenerated extends AbstractRawFirBuilderTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doRawFirTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInRawBuilder() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/fir/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/fir/rawBuilder/declarations")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Declarations extends AbstractRawFirBuilderTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doRawFirTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDeclarations() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/fir/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("complexTypes.kt")
|
||||
public void testComplexTypes() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/complexTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("derivedClass.kt")
|
||||
public void testDerivedClass() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/derivedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enums.kt")
|
||||
public void testEnums() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/enums.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("enums2.kt")
|
||||
public void testEnums2() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/enums2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("expectActual.kt")
|
||||
public void testExpectActual() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/expectActual.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("F.kt")
|
||||
public void testF() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/F.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionTypes.kt")
|
||||
public void testFunctionTypes() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/functionTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericFunctions.kt")
|
||||
public void testGenericFunctions() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/genericFunctions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/nestedClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedOfAliasedType.kt")
|
||||
public void testNestedOfAliasedType() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/NestedOfAliasedType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedSuperType.kt")
|
||||
public void testNestedSuperType() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/NestedSuperType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noPrimaryConstructor.kt")
|
||||
public void testNoPrimaryConstructor() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/noPrimaryConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleClass.kt")
|
||||
public void testSimpleClass() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/simpleClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleFun.kt")
|
||||
public void testSimpleFun() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/simpleFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleTypeAlias.kt")
|
||||
public void testSimpleTypeAlias() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/simpleTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasWithGeneric.kt")
|
||||
public void testTypeAliasWithGeneric() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/typeAliasWithGeneric.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameterVsNested.kt")
|
||||
public void testTypeParameterVsNested() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/typeParameterVsNested.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("typeParameters.kt")
|
||||
public void testTypeParameters() throws Exception {
|
||||
runTest("compiler/testData/fir/rawBuilder/declarations/typeParameters.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. 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.fir.builder
|
||||
|
||||
import com.intellij.testFramework.TestDataPath
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners
|
||||
import org.junit.runner.RunWith
|
||||
import java.io.File
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
@TestDataPath("\$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners::class)
|
||||
class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
|
||||
|
||||
fun testTotalKotlin() {
|
||||
val root = File(testDataPath)
|
||||
var counter = 0
|
||||
var time = 0L
|
||||
var totalLength = 0
|
||||
println("BASE PATH: $testDataPath")
|
||||
for (file in root.walkTopDown()) {
|
||||
if (file.isDirectory) continue
|
||||
if (file.path.contains("testData") || file.path.contains("resources")) continue
|
||||
if (file.extension != "kt") continue
|
||||
try {
|
||||
val ktFile = createKtFile(file.toRelativeString(root))
|
||||
var firFile: FirFile? = null
|
||||
time += measureNanoTime {
|
||||
firFile = ktFile.toFirFile()
|
||||
}
|
||||
totalLength += StringBuilder().also { FirRenderer(it).visitFile(firFile!!) }.length
|
||||
counter++
|
||||
} catch (e: Exception) {
|
||||
println("TIME PER FILE: ${(time / counter) * 1e-6} ms, COUNTER: $counter")
|
||||
println("EXCEPTION in: " + file.toRelativeString(root))
|
||||
throw e
|
||||
}
|
||||
}
|
||||
println("SUCCESS!")
|
||||
println("TOTAL LENGTH: $totalLength")
|
||||
println("TIME PER FILE: ${(time / counter) * 1e-6} ms, COUNTER: $counter")
|
||||
}
|
||||
|
||||
fun testVisitConsistency() {
|
||||
val root = File(testDataPath)
|
||||
for (file in root.walkTopDown()) {
|
||||
if (file.isDirectory) continue
|
||||
if (file.path.contains("testData") || file.path.contains("resources")) continue
|
||||
if (file.extension != "kt") continue
|
||||
val ktFile = createKtFile(file.toRelativeString(root))
|
||||
val firFile = ktFile.toFirFile()
|
||||
try {
|
||||
firFile.checkChildren()
|
||||
} catch (e: Throwable) {
|
||||
println("EXCEPTION in: " + file.toRelativeString(root))
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun testTransformConsistency() {
|
||||
val root = File(testDataPath)
|
||||
for (file in root.walkTopDown()) {
|
||||
if (file.isDirectory) continue
|
||||
if (file.path.contains("testData") || file.path.contains("resources")) continue
|
||||
if (file.extension != "kt") continue
|
||||
val ktFile = createKtFile(file.toRelativeString(root))
|
||||
val firFile = ktFile.toFirFile()
|
||||
try {
|
||||
firFile.checkTransformedChildren()
|
||||
} catch (e: Throwable) {
|
||||
println("EXCEPTION in: " + file.toRelativeString(root))
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -202,17 +202,7 @@ fun main(args: Array<String>) {
|
||||
model("ir/sourceRanges")
|
||||
}
|
||||
|
||||
testClass<AbstractRawFirBuilderTestCase> {
|
||||
model("fir/rawBuilder", testMethod = "doRawFirTest")
|
||||
}
|
||||
|
||||
testClass<AbstractFirResolveTestCase> {
|
||||
model("fir/resolve", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("stdlib"))
|
||||
}
|
||||
|
||||
testClass<AbstractFirResolveTestCaseWithStdlib> {
|
||||
model("fir/resolve/stdlib", pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
testClass<AbstractBytecodeListingTest> {
|
||||
model("codegen/bytecodeListing")
|
||||
@@ -387,4 +377,20 @@ fun main(args: Array<String>) {
|
||||
model("codegen/bytecodeText", targetBackend = TargetBackend.JVM_IR)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("compiler/fir/psi2fir/tests", "compiler/fir/psi2fir/testData") {
|
||||
testClass<AbstractRawFirBuilderTestCase> {
|
||||
model("rawBuilder", testMethod = "doRawFirTest")
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("compiler/fir/resolve/tests", "compiler/fir/resolve/testData") {
|
||||
testClass<AbstractFirResolveTestCase> {
|
||||
model("resolve", pattern = KT_WITHOUT_DOTS_IN_NAME, excludeDirs = listOf("stdlib"))
|
||||
}
|
||||
|
||||
testClass<AbstractFirResolveTestCaseWithStdlib> {
|
||||
model("resolve/stdlib", pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user