[Tests] Add .knm stub consistency test

The test compares stub trees built from .knm files directly and from
the decompiled text. Test data for .class decompiler is reused,
JVM-specific cases are ignored

KT-61354
This commit is contained in:
Pavel Kirpichenkov
2023-08-25 18:20:56 +03:00
committed by Space Team
parent 2537ff94b7
commit cf98fb5612
16 changed files with 841 additions and 5 deletions
@@ -1,3 +1,6 @@
// KNM_K2_IGNORE
// KNM_FE10_IGNORE
package test
public class AnnotatedFlexibleTypes(val javaClass: d.JavaClass) {
@@ -1,3 +1,7 @@
// Issue: KTIJ-26788 (need stdlib for lazy)
// KNM_K2_IGNORE
// KNM_FE10_IGNORE
@a public class Annotations private @a constructor(private @property:a @param:a val c1: Int, @property:a @param:a val c2: Int) {
@a() val hasValueArguments = 42
@@ -1,3 +1,5 @@
// Issue: KTIJ-26761
// KNM_K2_IGNORE
public class AnnotationsOnNullableTypes {
fun B<@A C?>.receiverArgument() {}
@@ -1,7 +1,7 @@
// FIR_IDENTICAL
// JVM_FILE_NAME: ContextReceiversOnFunctionTypeKt
// !LANGUAGE: +ContextReceivers
// KNM_K2_IGNORE
fun f(g: context(A, B) Int.(Int) -> Int) {}
class A {
@@ -1,4 +1,7 @@
// FIR_IDENTICAL
// KNM_K2_IGNORE
// KNM_FE10_IGNORE
package test
class LocalClass {
@@ -1,3 +1,7 @@
// Issue: KTIJ-26788 (need stdlib for Continuation)
// KNM_K2_IGNORE
// KNM_FE10_IGNORE
package test
import kotlin.coroutines.*
@@ -1,3 +1,6 @@
// Issue: KTIJ-26761
// KNM_K2_IGNORE
package foo.TopLevelMembers
fun funWithBlockBody() {
@@ -144,9 +144,7 @@ internal data class TestData(
companion object {
fun createFromDirectory(directory: Path): TestData {
val allFiles = Files.list(directory).collect(Collectors.toList())
val mainKotlinFile = allFiles.single { path: Path ->
path.name.replaceFirstChar { Character.toUpperCase(it) } == "${directory.name.removeSuffix("Kt")}.kt"
}
val mainKotlinFile = findMainTestKotlinFile(directory)
val fileText = mainKotlinFile.readText()
val jvmFileName = InTextDirectivesUtils.findStringWithPrefixes(fileText, "JVM_FILE_NAME:") ?: directory.name
val additionalCompilerOptions = InTextDirectivesUtils.findListWithPrefixes(fileText, "// !LANGUAGE: ").map { "-XXLanguage:$it" }
@@ -179,3 +177,9 @@ internal data class TestData(
}
}
fun findMainTestKotlinFile(directory: Path): Path {
val allFiles = Files.list(directory).collect(Collectors.toList())
return allFiles.singleOrNull { path: Path ->
path.name.replaceFirstChar { Character.toUpperCase(it) } == "${directory.name.removeSuffix("Kt")}.kt"
} ?: error("Test directory should contain a single primary kt source file")
}
@@ -10,6 +10,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.impl.DebugUtil
import com.intellij.psi.stubs.PsiFileStub
import com.intellij.psi.stubs.StubElement
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.psi.stubs.impl.STUB_TO_STRING_PREFIX
import org.jetbrains.kotlin.test.KotlinTestUtils
@@ -40,7 +41,8 @@ abstract class AbstractStubBuilderTest : AbstractDecompiledClassTest() {
protected abstract fun getStubToTest(classFile: VirtualFile): PsiFileStub<*>
}
private fun StubElement<out PsiElement>.serializeToString(): String {
@TestOnly
fun StubElement<out PsiElement>.serializeToString(): String {
return serializeStubToString(this)
}
@@ -22,6 +22,10 @@ dependencies {
api(project(":js:js.serializer"))
api(project(":kotlin-util-klib-metadata"))
compileOnly(intellijCore())
testImplementation(projectTests(":compiler:tests-common"))
testImplementation(projectTests(":compiler:tests-common-new"))
testImplementation(projectTests(":analysis:decompiled:decompiler-to-file-stubs"))
}
testsJar()
@@ -9,6 +9,7 @@ import com.intellij.openapi.fileTypes.FileTypeRegistry
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiManager
import com.intellij.psi.compiled.ClassFileDecompilers
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.analysis.decompiler.psi.KotlinDecompiledFileViewProvider
import org.jetbrains.kotlin.analysis.decompiler.psi.text.DecompiledText
import org.jetbrains.kotlin.analysis.decompiler.psi.text.createIncompatibleAbiVersionDecompiledText
@@ -69,4 +70,7 @@ abstract class KlibMetadataDecompiler<out V : BinaryVersion>(
null -> createIncompatibleAbiVersionDecompiledText(expectedBinaryVersion(), invalidBinaryVersion())
}
}
@TestOnly
internal fun buildDecompiledTextForTests(virtualFile: VirtualFile): DecompiledText = buildDecompiledText(virtualFile)
}
@@ -0,0 +1,172 @@
/*
* Copyright 2010-2023 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.decompiler.konan
import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem
import com.intellij.psi.PsiManager
import com.intellij.util.indexing.FileContentImpl
import org.jetbrains.kotlin.analysis.decompiler.stub.files.findMainTestKotlinFile
import org.jetbrains.kotlin.analysis.decompiler.stub.files.serializeToString
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.library.KLIB_METADATA_FILE_EXTENSION_WITH_DOT
import org.jetbrains.kotlin.psi.stubs.elements.KtFileStubBuilder
import org.jetbrains.kotlin.test.*
import org.jetbrains.kotlin.test.directives.model.Directive
import org.jetbrains.kotlin.test.directives.model.DirectiveApplicability
import org.jetbrains.kotlin.test.directives.model.SimpleDirective
import org.jetbrains.kotlin.test.directives.model.SimpleDirectivesContainer
import org.jetbrains.kotlin.test.util.KtTestUtil
import org.jetbrains.kotlin.utils.addIfNotNull
import org.junit.Assert
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.stream.Collectors
import kotlin.io.path.absolutePathString
import kotlin.io.path.extension
abstract class AbstractDecompiledKnmStubConsistencyFe10Test : AbstractDecompiledKnmStubConsistencyTest() {
private object Directives : SimpleDirectivesContainer() {
val KNM_FE10_IGNORE by directive(
description = "Ignore test for KNM files with FE10 K/N Decompiler",
applicability = DirectiveApplicability.Global,
)
}
override val ignoreDirective: SimpleDirective
get() = Directives.KNM_FE10_IGNORE
override fun createDecompiler(): KlibMetadataDecompiler<*> {
return KotlinNativeMetadataDecompiler()
}
}
abstract class AbstractDecompiledKnmStubConsistencyK2Test : AbstractDecompiledKnmStubConsistencyTest() {
private object Directives : SimpleDirectivesContainer() {
val KNM_K2_IGNORE by directive(
description = "Ignore test for KNM files with K2 K/N Decompiler",
applicability = DirectiveApplicability.Global,
)
}
override val ignoreDirective: SimpleDirective
get() = Directives.KNM_K2_IGNORE
override fun createDecompiler(): KlibMetadataDecompiler<*> {
return K2KotlinNativeMetadataDecompiler()
}
}
abstract class AbstractDecompiledKnmStubConsistencyTest : KotlinTestWithEnvironment() {
abstract val ignoreDirective: Directive
abstract fun createDecompiler(): KlibMetadataDecompiler<*>
override fun createEnvironment(): KotlinCoreEnvironment {
return KotlinCoreEnvironment.createForTests(
ApplicationEnvironmentDisposer.ROOT_DISPOSABLE,
KotlinTestUtils.newConfiguration(
ConfigurationKind.JDK_NO_RUNTIME,
TestJdkKind.MOCK_JDK,
),
EnvironmentConfigFiles.METADATA_CONFIG_FILES,
)
}
override fun setUp() {
super.setUp()
environment.projectEnvironment.environment.registerFileType(
KlibMetaFileType, KlibMetaFileType.defaultExtension
)
}
fun runTest(testDirectory: String) {
val testDirectoryPath = Paths.get(testDirectory)
withKnmIgnoreDirective(testDirectoryPath) { doTest(testDirectoryPath) }
}
private fun isTestIgnored(testDirectory: Path): Boolean {
val mainKotlinFile = findMainTestKotlinFile(testDirectory).toFile()
return InTextDirectivesUtils.isDirectiveDefined(mainKotlinFile.readText(), "// ${ignoreDirective.name}")
}
private fun withKnmIgnoreDirective(testDirectory: Path, block: () -> Unit) {
val isIgnored = isTestIgnored(testDirectory)
try {
block()
} catch (e: Throwable) {
if (isIgnored) return
else throw e
}
if (isIgnored) error("The test is passing. Please, remove the `// ${ignoreDirective.name}` directive")
}
private fun doTest(testDirectoryPath: Path) {
val commonKlib = compileCommonKlib(testDirectoryPath)
val files = getKnmFilesFromKlib(commonKlib)
for (knmFile in files) {
checkKnmStubConsistency(knmFile)
}
}
private fun compileCommonKlib(testDirectory: Path): File {
val ktFiles = Files.list(testDirectory).filter { it.extension == "kt" }.collect(Collectors.toList())
val testKlib = KtTestUtil.tmpDir("testLibrary").resolve("library.klib")
KlibTestUtil.compileCommonSourcesToKlib(
ktFiles.map(Path::toFile),
libraryName = "library",
testKlib,
)
return testKlib
}
private fun getKnmFilesFromKlib(klib: File): List<VirtualFile> {
val path = klib.toPath()
val jarFileSystem = environment.projectEnvironment.environment.jarFileSystem as CoreJarFileSystem
val root = jarFileSystem.refreshAndFindFileByPath(path.absolutePathString() + "!/")!!
val files = mutableListOf<VirtualFile>()
VfsUtilCore.iterateChildrenRecursively(
root,
{ virtualFile -> virtualFile.isDirectory || virtualFile.name.endsWith(KLIB_METADATA_FILE_EXTENSION_WITH_DOT) },
{ virtualFile ->
if (!virtualFile.isDirectory) {
files.addIfNotNull(virtualFile)
}
true
})
return files
}
private fun checkKnmStubConsistency(knmFile: VirtualFile) {
val stubTreeBinaryFile = createDecompiler().stubBuilder.buildFileStub(FileContentImpl.createByFile(knmFile, environment.project))!!
val fileViewProviderForDecompiledFile = K2KotlinNativeMetadataDecompiler().createFileViewProvider(
knmFile, PsiManager.getInstance(project), physical = false,
)
val stubTreeForDecompiledFile = KtFileStubBuilder().buildStubTree(
KlibDecompiledFile(fileViewProviderForDecompiledFile) { virtualFile ->
createDecompiler().buildDecompiledTextForTests(virtualFile)
}
)
Assert.assertEquals(
"PSI and deserialized stubs don't match",
stubTreeForDecompiledFile.serializeToString(),
stubTreeBinaryFile.serializeToString()
)
}
}
@@ -0,0 +1,308 @@
/*
* Copyright 2010-2023 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.decompiler.konan;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
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 org.jetbrains.kotlin.generators.tests.analysis.api.GenerateAnalysisApiTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder")
@TestDataPath("$PROJECT_ROOT")
public class DecompiledKnmStubConsistencyFe10TestGenerated extends AbstractDecompiledKnmStubConsistencyFe10Test {
@Test
public void testAllFilesPresentInClsFileStubBuilder() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder"), Pattern.compile("^([^\\.]+)$"), null, false);
}
@Test
@TestMetadata("AnnotatedFlexibleTypes")
public void testAnnotatedFlexibleTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotatedFlexibleTypes/");
}
@Test
@TestMetadata("AnnotatedParameterInEnumConstructor")
public void testAnnotatedParameterInEnumConstructor() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotatedParameterInEnumConstructor/");
}
@Test
@TestMetadata("AnnotatedParameterInInnerClassConstructor")
public void testAnnotatedParameterInInnerClassConstructor() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotatedParameterInInnerClassConstructor/");
}
@Test
@TestMetadata("AnnotationClass")
public void testAnnotationClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationClass/");
}
@Test
@TestMetadata("AnnotationValues")
public void testAnnotationValues() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationValues/");
}
@Test
@TestMetadata("Annotations")
public void testAnnotations() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Annotations/");
}
@Test
@TestMetadata("AnnotationsOnNullableTypes")
public void testAnnotationsOnNullableTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationsOnNullableTypes/");
}
@Test
@TestMetadata("AnnotationsOnParenthesizedTypes")
public void testAnnotationsOnParenthesizedTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationsOnParenthesizedTypes/");
}
@Test
@TestMetadata("AnonymousReturnWithGenericType")
public void testAnonymousReturnWithGenericType() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnonymousReturnWithGenericType/");
}
@Test
@TestMetadata("ClassMembers")
public void testClassMembers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ClassMembers/");
}
@Test
@TestMetadata("ClassObject")
public void testClassObject() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ClassObject/");
}
@Test
@TestMetadata("Const")
public void testConst() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Const/");
}
@Test
@TestMetadata("ContextReceiversCallableMembers")
public void testContextReceiversCallableMembers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversCallableMembers/");
}
@Test
@TestMetadata("ContextReceiversOnClass")
public void testContextReceiversOnClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversOnClass/");
}
@Test
@TestMetadata("ContextReceiversOnFunctionType")
public void testContextReceiversOnFunctionType() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversOnFunctionType/");
}
@Test
@TestMetadata("ContextReceiversOnTopLevelCallables")
public void testContextReceiversOnTopLevelCallables() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversOnTopLevelCallables/");
}
@Test
@TestMetadata("Contracts")
public void testContracts() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Contracts/");
}
@Test
@TestMetadata("DataClass")
public void testDataClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/DataClass/");
}
@Test
@TestMetadata("DefinitelyNotNullTypes")
public void testDefinitelyNotNullTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/DefinitelyNotNullTypes/");
}
@Test
@TestMetadata("Delegation")
public void testDelegation() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Delegation/");
}
@Test
@TestMetadata("DependencyOnNestedClasses")
public void testDependencyOnNestedClasses() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/DependencyOnNestedClasses/");
}
@Test
@TestMetadata("Enum")
public void testEnum() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Enum/");
}
@Test
@TestMetadata("FlexibleTypes")
public void testFlexibleTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/FlexibleTypes/");
}
@Test
@TestMetadata("FunInterfaceDeclaration")
public void testFunInterfaceDeclaration() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/FunInterfaceDeclaration/");
}
@Test
@TestMetadata("InheritingClasses")
public void testInheritingClasses() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/InheritingClasses/");
}
@Test
@TestMetadata("InnerClassEnumEntry")
public void testInnerClassEnumEntry() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/InnerClassEnumEntry/");
}
@Test
@TestMetadata("InnerTypes")
public void testInnerTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/InnerTypes/");
}
@Test
@TestMetadata("LocalClass")
public void testLocalClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/LocalClass/");
}
@Test
@TestMetadata("Modifiers")
public void testModifiers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Modifiers/");
}
@Test
@TestMetadata("MultifileClass")
public void testMultifileClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/MultifileClass/");
}
@Test
@TestMetadata("NamedCompanionObject")
public void testNamedCompanionObject() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/NamedCompanionObject/");
}
@Test
@TestMetadata("NestedClasses")
public void testNestedClasses() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/NestedClasses/");
}
@Test
@TestMetadata("Objects")
public void testObjects() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Objects/");
}
@Test
@TestMetadata("PrivateConstField")
public void testPrivateConstField() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/PrivateConstField/");
}
@Test
@TestMetadata("PrivateToThis")
public void testPrivateToThis() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/PrivateToThis/");
}
@Test
@TestMetadata("Sealed")
public void testSealed() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Sealed/");
}
@Test
@TestMetadata("SecondaryConstructors")
public void testSecondaryConstructors() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SecondaryConstructors/");
}
@Test
@TestMetadata("SpecialNames")
public void testSpecialNames() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SpecialNames/");
}
@Test
@TestMetadata("SuspendLambda")
public void testSuspendLambda() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SuspendLambda/");
}
@Test
@TestMetadata("TopJvmPackageName")
public void testTopJvmPackageName() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TopJvmPackageName/");
}
@Test
@TestMetadata("TopLevelMembersAnnotatedKt")
public void testTopLevelMembersAnnotatedKt() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TopLevelMembersAnnotatedKt/");
}
@Test
@TestMetadata("TopLevelMembersKt")
public void testTopLevelMembersKt() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TopLevelMembersKt/");
}
@Test
@TestMetadata("TypeAliases")
public void testTypeAliases() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeAliases/");
}
@Test
@TestMetadata("TypeBoundsAndDelegationSpecifiers")
public void testTypeBoundsAndDelegationSpecifiers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeBoundsAndDelegationSpecifiers/");
}
@Test
@TestMetadata("TypeModifiers")
public void testTypeModifiers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeModifiers/");
}
@Test
@TestMetadata("TypeParams")
public void testTypeParams() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeParams/");
}
@Test
@TestMetadata("Types")
public void testTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Types/");
}
}
@@ -0,0 +1,308 @@
/*
* Copyright 2010-2023 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.decompiler.konan;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.util.KtTestUtil;
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 org.jetbrains.kotlin.generators.tests.analysis.api.GenerateAnalysisApiTestsKt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder")
@TestDataPath("$PROJECT_ROOT")
public class DecompiledKnmStubConsistencyK2TestGenerated extends AbstractDecompiledKnmStubConsistencyK2Test {
@Test
public void testAllFilesPresentInClsFileStubBuilder() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder"), Pattern.compile("^([^\\.]+)$"), null, false);
}
@Test
@TestMetadata("AnnotatedFlexibleTypes")
public void testAnnotatedFlexibleTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotatedFlexibleTypes/");
}
@Test
@TestMetadata("AnnotatedParameterInEnumConstructor")
public void testAnnotatedParameterInEnumConstructor() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotatedParameterInEnumConstructor/");
}
@Test
@TestMetadata("AnnotatedParameterInInnerClassConstructor")
public void testAnnotatedParameterInInnerClassConstructor() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotatedParameterInInnerClassConstructor/");
}
@Test
@TestMetadata("AnnotationClass")
public void testAnnotationClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationClass/");
}
@Test
@TestMetadata("AnnotationValues")
public void testAnnotationValues() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationValues/");
}
@Test
@TestMetadata("Annotations")
public void testAnnotations() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Annotations/");
}
@Test
@TestMetadata("AnnotationsOnNullableTypes")
public void testAnnotationsOnNullableTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationsOnNullableTypes/");
}
@Test
@TestMetadata("AnnotationsOnParenthesizedTypes")
public void testAnnotationsOnParenthesizedTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnnotationsOnParenthesizedTypes/");
}
@Test
@TestMetadata("AnonymousReturnWithGenericType")
public void testAnonymousReturnWithGenericType() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/AnonymousReturnWithGenericType/");
}
@Test
@TestMetadata("ClassMembers")
public void testClassMembers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ClassMembers/");
}
@Test
@TestMetadata("ClassObject")
public void testClassObject() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ClassObject/");
}
@Test
@TestMetadata("Const")
public void testConst() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Const/");
}
@Test
@TestMetadata("ContextReceiversCallableMembers")
public void testContextReceiversCallableMembers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversCallableMembers/");
}
@Test
@TestMetadata("ContextReceiversOnClass")
public void testContextReceiversOnClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversOnClass/");
}
@Test
@TestMetadata("ContextReceiversOnFunctionType")
public void testContextReceiversOnFunctionType() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversOnFunctionType/");
}
@Test
@TestMetadata("ContextReceiversOnTopLevelCallables")
public void testContextReceiversOnTopLevelCallables() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/ContextReceiversOnTopLevelCallables/");
}
@Test
@TestMetadata("Contracts")
public void testContracts() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Contracts/");
}
@Test
@TestMetadata("DataClass")
public void testDataClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/DataClass/");
}
@Test
@TestMetadata("DefinitelyNotNullTypes")
public void testDefinitelyNotNullTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/DefinitelyNotNullTypes/");
}
@Test
@TestMetadata("Delegation")
public void testDelegation() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Delegation/");
}
@Test
@TestMetadata("DependencyOnNestedClasses")
public void testDependencyOnNestedClasses() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/DependencyOnNestedClasses/");
}
@Test
@TestMetadata("Enum")
public void testEnum() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Enum/");
}
@Test
@TestMetadata("FlexibleTypes")
public void testFlexibleTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/FlexibleTypes/");
}
@Test
@TestMetadata("FunInterfaceDeclaration")
public void testFunInterfaceDeclaration() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/FunInterfaceDeclaration/");
}
@Test
@TestMetadata("InheritingClasses")
public void testInheritingClasses() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/InheritingClasses/");
}
@Test
@TestMetadata("InnerClassEnumEntry")
public void testInnerClassEnumEntry() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/InnerClassEnumEntry/");
}
@Test
@TestMetadata("InnerTypes")
public void testInnerTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/InnerTypes/");
}
@Test
@TestMetadata("LocalClass")
public void testLocalClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/LocalClass/");
}
@Test
@TestMetadata("Modifiers")
public void testModifiers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Modifiers/");
}
@Test
@TestMetadata("MultifileClass")
public void testMultifileClass() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/MultifileClass/");
}
@Test
@TestMetadata("NamedCompanionObject")
public void testNamedCompanionObject() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/NamedCompanionObject/");
}
@Test
@TestMetadata("NestedClasses")
public void testNestedClasses() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/NestedClasses/");
}
@Test
@TestMetadata("Objects")
public void testObjects() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Objects/");
}
@Test
@TestMetadata("PrivateConstField")
public void testPrivateConstField() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/PrivateConstField/");
}
@Test
@TestMetadata("PrivateToThis")
public void testPrivateToThis() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/PrivateToThis/");
}
@Test
@TestMetadata("Sealed")
public void testSealed() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Sealed/");
}
@Test
@TestMetadata("SecondaryConstructors")
public void testSecondaryConstructors() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SecondaryConstructors/");
}
@Test
@TestMetadata("SpecialNames")
public void testSpecialNames() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SpecialNames/");
}
@Test
@TestMetadata("SuspendLambda")
public void testSuspendLambda() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/SuspendLambda/");
}
@Test
@TestMetadata("TopJvmPackageName")
public void testTopJvmPackageName() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TopJvmPackageName/");
}
@Test
@TestMetadata("TopLevelMembersAnnotatedKt")
public void testTopLevelMembersAnnotatedKt() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TopLevelMembersAnnotatedKt/");
}
@Test
@TestMetadata("TopLevelMembersKt")
public void testTopLevelMembersKt() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TopLevelMembersKt/");
}
@Test
@TestMetadata("TypeAliases")
public void testTypeAliases() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeAliases/");
}
@Test
@TestMetadata("TypeBoundsAndDelegationSpecifiers")
public void testTypeBoundsAndDelegationSpecifiers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeBoundsAndDelegationSpecifiers/");
}
@Test
@TestMetadata("TypeModifiers")
public void testTypeModifiers() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeModifiers/");
}
@Test
@TestMetadata("TypeParams")
public void testTypeParams() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/TypeParams/");
}
@Test
@TestMetadata("Types")
public void testTypes() throws Exception {
runTest("analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Types/");
}
}
@@ -23,6 +23,7 @@ dependencies {
testImplementation(projectTests(":analysis:decompiled:decompiler-to-file-stubs"))
testImplementation(projectTests(":analysis:decompiled:decompiler-to-psi"))
testImplementation(projectTests(":analysis:symbol-light-classes"))
testImplementation(projectTests(":analysis:decompiled:native"))
testImplementation(intellijCore())
testApiJUnit5()
}
@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.generators.tests.analysis.api
import org.jetbrains.kotlin.analysis.decompiler.konan.AbstractDecompiledKnmStubConsistencyFe10Test
import org.jetbrains.kotlin.analysis.decompiler.konan.AbstractDecompiledKnmStubConsistencyK2Test
import org.jetbrains.kotlin.analysis.decompiler.psi.AbstractByDecompiledPsiStubBuilderK2CompilerTest
import org.jetbrains.kotlin.analysis.decompiler.psi.AbstractByDecompiledPsiStubBuilderTest
import org.jetbrains.kotlin.analysis.decompiler.stub.files.AbstractAdditionalStubInfoK2CompilerTest
@@ -52,4 +54,16 @@ internal fun TestGroupSuite.generateDecompiledTests() {
model("clsFileStubBuilder", extension = null, recursive = false)
}
}
testGroup(
"analysis/decompiled/native/tests",
"analysis/decompiled/decompiler-to-file-stubs/testData",
) {
testClass<AbstractDecompiledKnmStubConsistencyK2Test> {
model("clsFileStubBuilder", extension = null, recursive = false)
}
testClass<AbstractDecompiledKnmStubConsistencyFe10Test> {
model("clsFileStubBuilder", extension = null, recursive = false)
}
}
}