Update tests on decompiled text for JS
Because .kjsm files now contain all declarations from the package (contrary to the JVM decompiler which produces one file for one class/package facade), some common decompiled text tests started to behave differently on JVM and JS. Update two of them (Modifiers, ClassWithClassObject) to make results the same, copy another (TypeAliases) to JVM-/JS-specific tests with different outputs
This commit is contained in:
@@ -5,9 +5,9 @@ package test
|
||||
|
||||
public final class ClassWithClassObject public constructor() {
|
||||
public companion object {
|
||||
public final val a: test.A /* compiled code */
|
||||
public final val a: test.ClassWithClassObject.A /* compiled code */
|
||||
|
||||
public final var b: test.B /* compiled code */
|
||||
public final var b: test.ClassWithClassObject.B /* compiled code */
|
||||
|
||||
public final val kotlin.Int.g: kotlin.Int /* compiled code */
|
||||
|
||||
@@ -21,4 +21,10 @@ public final class ClassWithClassObject public constructor() {
|
||||
}
|
||||
|
||||
public final fun f(): kotlin.Unit { /* compiled code */ }
|
||||
|
||||
public final class A public constructor() {
|
||||
}
|
||||
|
||||
public final class B public constructor() {
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -25,10 +25,10 @@ class ClassWithClassObject {
|
||||
throw RuntimeException()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
}
|
||||
class B {
|
||||
}
|
||||
|
||||
class A {
|
||||
class A {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,7 @@ public final data class Modifiers public constructor(x: kotlin.Int) {
|
||||
public final inline fun inlined(crossinline arg1: () -> kotlin.Unit, noinline arg2: () -> kotlin.Unit): kotlin.Unit { /* compiled code */ }
|
||||
|
||||
public final tailrec fun sum(x: kotlin.Long, sum: kotlin.Long): kotlin.Long { /* compiled code */ }
|
||||
|
||||
public final annotation class Ann public constructor() : kotlin.Annotation {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ data class Modifiers(val x: Int) {
|
||||
}
|
||||
|
||||
inline fun inlined(crossinline arg1: ()->Unit, noinline arg2: ()->Unit): Unit {}
|
||||
}
|
||||
|
||||
annotation class Ann
|
||||
annotation class Ann
|
||||
}
|
||||
|
||||
@@ -9,4 +9,13 @@ public val p: kotlin.Int /* compiled code */
|
||||
|
||||
public fun f(): kotlin.Unit { /* compiled code */ }
|
||||
|
||||
public fun kotlin.Int.plus(i: kotlin.Int /* = compiled code */): kotlin.Int { /* compiled code */ }
|
||||
public fun kotlin.Int.plus(i: kotlin.Int /* = compiled code */): kotlin.Int { /* compiled code */ }
|
||||
|
||||
public final class Class public constructor() {
|
||||
public final class Nested public constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
public interface Interface {
|
||||
}
|
||||
|
||||
|
||||
@@ -6,5 +6,8 @@ private var i = 2
|
||||
|
||||
fun Int.plus(i: Int = 1) = this + i
|
||||
|
||||
class ShouldNotBeVisible1
|
||||
interface ShouldNotBeVisible2
|
||||
class Class {
|
||||
class Nested
|
||||
}
|
||||
|
||||
interface Interface
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// IntelliJ API Decompiler stub source generated from a class file
|
||||
// Implementation of methods is not available
|
||||
|
||||
package test
|
||||
|
||||
@kotlin.annotation.Target public final annotation class Ann public constructor(value: kotlin.String) : kotlin.Annotation {
|
||||
public final val value: kotlin.String /* compiled code */
|
||||
}
|
||||
|
||||
public final class Outer<E, F> public constructor() {
|
||||
public final inner class Inner<G> public constructor() {
|
||||
@kotlin.Suppress public typealias TA<H> = kotlin.collections.Map<kotlin.collections.Map<E, F>, kotlin.collections.Map<G, H>>
|
||||
}
|
||||
}
|
||||
|
||||
public final class TypeAliases public constructor() {
|
||||
public final fun foo(a: dependency.A /* = () -> kotlin.Unit */, b: test.TypeAliases.B /* = (dependency.A /* = () -> kotlin.Unit */) -> kotlin.Unit */, ta: test.Outer<kotlin.String, kotlin.Double>.Inner<kotlin.Int>.TA<kotlin.Boolean> /* = kotlin.collections.Map<kotlin.collections.Map<kotlin.String, kotlin.Double>, kotlin.collections.Map<kotlin.Int, kotlin.Boolean>> */): kotlin.Unit { /* compiled code */ }
|
||||
|
||||
@kotlin.Suppress public typealias B = (dependency.A) -> kotlin.Unit
|
||||
|
||||
@test.Ann @kotlin.Suppress private typealias Parametrized<E, F> = kotlin.collections.Map<E, F>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package dependency
|
||||
|
||||
typealias A = () -> Unit
|
||||
|
||||
fun foo(a: A) {
|
||||
a.invoke()
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package test
|
||||
|
||||
import dependency.*
|
||||
import kotlin.annotation.AnnotationTarget
|
||||
|
||||
class Outer<E, F> {
|
||||
inner class Inner<G> {
|
||||
@Suppress("TOPLEVEL_TYPEALIASES_ONLY")
|
||||
typealias TA<H> = Map<Map<E, F>, Map<G, H>>
|
||||
}
|
||||
}
|
||||
|
||||
@Target(AnnotationTarget.TYPEALIAS)
|
||||
annotation class Ann(val value: String)
|
||||
|
||||
class TypeAliases {
|
||||
|
||||
@Suppress("TOPLEVEL_TYPEALIASES_ONLY")
|
||||
typealias B = (A) -> Unit
|
||||
|
||||
fun foo(a: A, b: B, ta: Outer<String, Double>.Inner<Int>.TA<Boolean>) {
|
||||
b.invoke(a)
|
||||
}
|
||||
|
||||
@Ann("OK")
|
||||
@Suppress("TOPLEVEL_TYPEALIASES_ONLY")
|
||||
private typealias Parametrized<E, F> = Map<E, F>
|
||||
}
|
||||
+6
-8
@@ -23,10 +23,12 @@ import org.jetbrains.kotlin.idea.decompiler.KtDecompiledFile
|
||||
import org.jetbrains.kotlin.idea.test.JdkAndMockLibraryProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.ModuleKind
|
||||
import org.jetbrains.kotlin.idea.test.configureAs
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.serialization.js.JsSerializerProtocol
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
abstract class AbstractDecompiledTextFromJsMetadataTest(baseDirectory: String) : AbstractDecompiledTextBaseTest(baseDirectory, true) {
|
||||
override fun getFileToDecompile(): VirtualFile = getKjsmFile(TEST_PACKAGE, getTestName(false), myModule!!)
|
||||
override fun getFileToDecompile(): VirtualFile = getKjsmFile(TEST_PACKAGE, myModule!!)
|
||||
|
||||
override fun checkPsiFile(psiFile: PsiFile) =
|
||||
assertTrue(psiFile is KtDecompiledFile, "Expecting decompiled kotlin javascript file, was: " + psiFile.javaClass)
|
||||
@@ -41,13 +43,9 @@ abstract class AbstractCommonDecompiledTextFromJsMetadataTest : AbstractDecompil
|
||||
|
||||
abstract class AbstractJsDecompiledTextFromJsMetadataTest : AbstractDecompiledTextFromJsMetadataTest("/decompiler/decompiledTextJs")
|
||||
|
||||
fun getKjsmFile(
|
||||
packageName: String,
|
||||
className: String,
|
||||
module: Module
|
||||
): VirtualFile {
|
||||
fun getKjsmFile(packageName: String, module: Module): VirtualFile {
|
||||
val root = findTestLibraryRoot(module)!!
|
||||
root.refresh(false, true)
|
||||
val packageDir = root.findFileByRelativePath(JdkAndMockLibraryProjectDescriptor.LIBRARY_NAME + "/" + packageName.replace(".", "/"))!!
|
||||
return packageDir.findChild(className + ".kjsm")!!
|
||||
}
|
||||
return packageDir.findChild(JsSerializerProtocol.getKjsmFilePath(FqName(packageName)).substringAfterLast('/'))!!
|
||||
}
|
||||
|
||||
-6
@@ -144,12 +144,6 @@ public class CommonDecompiledTextFromJsMetadataTestGenerated extends AbstractCom
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeAliases")
|
||||
public void testTypeAliases() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/TypeAliases/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeModifiers")
|
||||
public void testTypeModifiers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/TypeModifiers/");
|
||||
|
||||
-6
@@ -150,12 +150,6 @@ public class CommonDecompiledTextTestGenerated extends AbstractCommonDecompiledT
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeAliases")
|
||||
public void testTypeAliases() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/TypeAliases/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeModifiers")
|
||||
public void testTypeModifiers() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledText/TypeModifiers/");
|
||||
|
||||
+6
@@ -42,4 +42,10 @@ public class JsDecompiledTextFromJsMetadataTestGenerated extends AbstractJsDecom
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeAliases")
|
||||
public void testTypeAliases() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledTextJs/TypeAliases/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+6
@@ -54,4 +54,10 @@ public class JvmDecompiledTextTestGenerated extends AbstractJvmDecompiledTextTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("TypeAliases")
|
||||
public void testTypeAliases() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/decompiler/decompiledTextJvm/TypeAliases/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user