[Tests] Drop obsolete KotlinJavascriptSerializerTest.kt
This commit is contained in:
committed by
Space Team
parent
9b4f503fbe
commit
64d4b61628
@@ -183,7 +183,6 @@
|
|||||||
/compiler/testData/resolveConstructorDelegationCalls/ "Kotlin Compiler Core"
|
/compiler/testData/resolveConstructorDelegationCalls/ "Kotlin Compiler Core"
|
||||||
/compiler/testData/resolvedCalls/ "Kotlin Compiler Core"
|
/compiler/testData/resolvedCalls/ "Kotlin Compiler Core"
|
||||||
/compiler/testData/serialization/builtinsSerializer/ "Kotlin Compiler Core"
|
/compiler/testData/serialization/builtinsSerializer/ "Kotlin Compiler Core"
|
||||||
/compiler/testData/serialization/js/ "Kotlin JS"
|
|
||||||
/compiler/testData/serialization/nonStableParameterNames/ "Kotlin Compiler Core" "Kotlin JVM" "Kotlin JS" "Kotlin Native" "Kotlin Wasm" "Kotlin Common Backend"
|
/compiler/testData/serialization/nonStableParameterNames/ "Kotlin Compiler Core" "Kotlin JVM" "Kotlin JS" "Kotlin Native" "Kotlin Wasm" "Kotlin Common Backend"
|
||||||
/compiler/testData/serialization/klib/ "Kotlin Common Backend"
|
/compiler/testData/serialization/klib/ "Kotlin Common Backend"
|
||||||
/compiler/testData/type/ "Kotlin Compiler Core"
|
/compiler/testData/type/ "Kotlin Compiler Core"
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package test
|
|
||||||
|
|
||||||
|
|
||||||
enum class Weapon {
|
|
||||||
ROCK,
|
|
||||||
PAPER,
|
|
||||||
SCISSORS
|
|
||||||
}
|
|
||||||
|
|
||||||
val byteConst: dynamic = 10.toByte()
|
|
||||||
val shortConst: dynamic = 20.toShort()
|
|
||||||
val intConst: dynamic = 30
|
|
||||||
val longConst: dynamic = 40.toLong()
|
|
||||||
val charConst: dynamic = 'A'
|
|
||||||
val stringConst: dynamic = "abcd"
|
|
||||||
val booleanConst: dynamic = true
|
|
||||||
val floatConst: dynamic = 2.0f
|
|
||||||
val doubleConst: dynamic = 3.0
|
|
||||||
val enumConst: dynamic = Weapon.ROCK
|
|
||||||
val arrayConst: dynamic = byteArrayOf(1,2)
|
|
||||||
val dynamicConst: dynamic = 100
|
|
||||||
|
|
||||||
class Class {
|
|
||||||
val byteConst: dynamic = 10.toByte()
|
|
||||||
val shortConst: dynamic = 20.toShort()
|
|
||||||
val intConst: dynamic = 30
|
|
||||||
val longConst: dynamic = 40.toLong()
|
|
||||||
val charConst: dynamic = 'A'
|
|
||||||
val stringConst: dynamic = "abcd"
|
|
||||||
val booleanConst: dynamic = true
|
|
||||||
val floatConst: dynamic = 2.0f
|
|
||||||
val doubleConst: dynamic = 3.0
|
|
||||||
val enumConst: dynamic = Weapon.ROCK
|
|
||||||
val arrayConst: dynamic = byteArrayOf(1,2)
|
|
||||||
val dynamicConst: dynamic = 100
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
package test
|
|
||||||
|
|
||||||
public val arrayConst: dynamic = {1.toByte(), 2.toByte()}
|
|
||||||
public val booleanConst: dynamic = true
|
|
||||||
public val byteConst: dynamic = 10.toByte()
|
|
||||||
public val charConst: dynamic = \u0041 ('A')
|
|
||||||
public val doubleConst: dynamic = 3.0.toDouble()
|
|
||||||
public val dynamicConst: dynamic = 100
|
|
||||||
public val enumConst: dynamic = Weapon.ROCK
|
|
||||||
public val floatConst: dynamic = 2.0.toFloat()
|
|
||||||
public val intConst: dynamic = 30
|
|
||||||
public val longConst: dynamic = 40.toLong()
|
|
||||||
public val shortConst: dynamic = 20.toShort()
|
|
||||||
public val stringConst: dynamic = "abcd"
|
|
||||||
|
|
||||||
public final class Class {
|
|
||||||
public constructor Class()
|
|
||||||
public final val arrayConst: dynamic = {1.toByte(), 2.toByte()}
|
|
||||||
public final val booleanConst: dynamic = true
|
|
||||||
public final val byteConst: dynamic = 10.toByte()
|
|
||||||
public final val charConst: dynamic = \u0041 ('A')
|
|
||||||
public final val doubleConst: dynamic = 3.0.toDouble()
|
|
||||||
public final val dynamicConst: dynamic = 100
|
|
||||||
public final val enumConst: dynamic = Weapon.ROCK
|
|
||||||
public final val floatConst: dynamic = 2.0.toFloat()
|
|
||||||
public final val intConst: dynamic = 30
|
|
||||||
public final val longConst: dynamic = 40.toLong()
|
|
||||||
public final val shortConst: dynamic = 20.toShort()
|
|
||||||
public final val stringConst: dynamic = "abcd"
|
|
||||||
}
|
|
||||||
|
|
||||||
public final enum class Weapon : kotlin.Enum<test.Weapon> {
|
|
||||||
enum entry ROCK
|
|
||||||
|
|
||||||
enum entry PAPER
|
|
||||||
|
|
||||||
enum entry SCISSORS
|
|
||||||
|
|
||||||
private constructor Weapon()
|
|
||||||
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
|
||||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
|
||||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
|
||||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.Weapon): kotlin.Int
|
|
||||||
|
|
||||||
// Static members
|
|
||||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.Weapon
|
|
||||||
public final /*synthesized*/ fun values(): kotlin.Array<test.Weapon>
|
|
||||||
}
|
|
||||||
-162
@@ -1,162 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.serialization.js
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.Disposer
|
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
|
||||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots
|
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
|
||||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
|
||||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
|
||||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
|
|
||||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
|
||||||
import org.jetbrains.kotlin.js.config.JsConfig
|
|
||||||
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
|
|
||||||
import org.jetbrains.kotlin.jvm.compiler.LoadDescriptorUtil.TEST_PACKAGE_FQNAME
|
|
||||||
import org.jetbrains.kotlin.resolve.CompilerEnvironment
|
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
|
||||||
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil.readModuleAsProto
|
|
||||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
|
||||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
|
|
||||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator
|
|
||||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparatorAdaptor
|
|
||||||
import org.jetbrains.kotlin.utils.JsMetadataVersion
|
|
||||||
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
|
|
||||||
import org.jetbrains.kotlin.utils.sure
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
|
||||||
private val BASE_DIR = "compiler/testData/serialization"
|
|
||||||
|
|
||||||
private fun doTest(fileName: String, metaFileDir: File = tmpdir) {
|
|
||||||
val source = "$BASE_DIR/$fileName"
|
|
||||||
val metaFile = File(metaFileDir, "${FileUtil.getNameWithoutExtension(fileName)}.meta.js")
|
|
||||||
|
|
||||||
val srcDirs = listOf(File(source))
|
|
||||||
|
|
||||||
val configuration = KotlinTestUtils.newConfiguration()
|
|
||||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
|
|
||||||
configuration.put(JSConfigurationKeys.LIBRARIES, JsConfig.JS_STDLIB)
|
|
||||||
|
|
||||||
configuration.addKotlinSourceRoots(srcDirs.map { it.path })
|
|
||||||
|
|
||||||
serialize(configuration, metaFile)
|
|
||||||
val module = deserialize(metaFile)
|
|
||||||
|
|
||||||
RecursiveDescriptorComparatorAdaptor.validateAndCompareDescriptorWithFile(
|
|
||||||
module.getPackage(TEST_PACKAGE_FQNAME),
|
|
||||||
RecursiveDescriptorComparator.DONT_INCLUDE_METHODS_OF_OBJECT,
|
|
||||||
File(source.replace(".kt", ".txt"))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun serialize(configuration: CompilerConfiguration, metaFile: File) {
|
|
||||||
val rootDisposable = Disposer.newDisposable("Disposable for ${KotlinJavascriptSerializerTest::class.simpleName}.serialize")
|
|
||||||
try {
|
|
||||||
val environment = KotlinCoreEnvironment.createForTests(rootDisposable, configuration, EnvironmentConfigFiles.JS_CONFIG_FILES)
|
|
||||||
val files = environment.getSourceFiles()
|
|
||||||
val config = JsConfig(environment.project, environment.configuration, CompilerEnvironment)
|
|
||||||
val analysisResult = TopDownAnalyzerFacadeForJS.analyzeFiles(files, config)
|
|
||||||
val description = JsModuleDescriptor(
|
|
||||||
name = KotlinTestUtils.TEST_MODULE_NAME,
|
|
||||||
kind = ModuleKind.PLAIN,
|
|
||||||
imported = listOf(),
|
|
||||||
data = analysisResult.moduleDescriptor
|
|
||||||
)
|
|
||||||
val serializedMetadata = KotlinJavascriptSerializationUtil.serializeMetadata(
|
|
||||||
analysisResult.bindingContext, description, configuration.languageVersionSettings,
|
|
||||||
configuration.get(CommonConfigurationKeys.METADATA_VERSION) as? JsMetadataVersion ?: JsMetadataVersion.INSTANCE,
|
|
||||||
config.project
|
|
||||||
)
|
|
||||||
FileUtil.writeToFile(metaFile, serializedMetadata.asString())
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
Disposer.dispose(rootDisposable)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun deserialize(metaFile: File): ModuleDescriptorImpl {
|
|
||||||
val module = KotlinTestUtils.createEmptyModule("<${KotlinTestUtils.TEST_MODULE_NAME}>", JsPlatformAnalyzerServices.builtIns)
|
|
||||||
val metadata = KotlinJavascriptMetadataUtils.loadMetadata(metaFile).single()
|
|
||||||
|
|
||||||
val (header, packageFragmentProtos) = readModuleAsProto(metadata.body, metadata.version)
|
|
||||||
val provider = createKotlinJavascriptPackageFragmentProvider(
|
|
||||||
LockBasedStorageManager("KotlinJavascriptrSerializerTest"), module, header, packageFragmentProtos, metadata.version,
|
|
||||||
DeserializationConfiguration.Default, LookupTracker.DO_NOTHING
|
|
||||||
).sure { "No package fragment provider was created" }
|
|
||||||
|
|
||||||
module.initialize(provider)
|
|
||||||
module.setDependencies(module, module.builtIns.builtInsModule)
|
|
||||||
|
|
||||||
return module
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testDynamicConstants() {
|
|
||||||
doTest("js/dynamicConstants.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testSimple() {
|
|
||||||
doTest("builtinsSerializer/simple.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testNestedClassesAndObjects() {
|
|
||||||
doTest("builtinsSerializer/nestedClassesAndObjects.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testCompileTimeConstants() {
|
|
||||||
doTest("builtinsSerializer/compileTimeConstants.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testAnnotationTargets() {
|
|
||||||
doTest("builtinsSerializer/annotationTargets.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testAnnotatedEnumEntry() {
|
|
||||||
doTest("builtinsSerializer/annotatedEnumEntry.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testPrimitives() {
|
|
||||||
doTest("builtinsSerializer/annotationArguments/primitives.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testPrimitiveArrays() {
|
|
||||||
doTest("builtinsSerializer/annotationArguments/primitiveArrays.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testString() {
|
|
||||||
doTest("builtinsSerializer/annotationArguments/string.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testAnnotation() {
|
|
||||||
doTest("builtinsSerializer/annotationArguments/annotation.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testEnum() {
|
|
||||||
doTest("builtinsSerializer/annotationArguments/enum.kt")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testPropertyAccessorAnnotations() {
|
|
||||||
doTest("builtinsSerializer/propertyAccessorAnnotations.kt")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user