[JS IR] Support per-file mode and ES modules
This commit is contained in:
@@ -1173,6 +1173,69 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExport(@NotNull JsExport export) {
|
||||
p.print("export");
|
||||
space();
|
||||
JsExport.Subject subject = export.getSubject();
|
||||
|
||||
if (subject instanceof JsExport.Subject.All) {
|
||||
p.print("*");
|
||||
} else if (subject instanceof JsExport.Subject.Elements) {
|
||||
blockOpen();
|
||||
List<JsExport.Element> elements = ((JsExport.Subject.Elements) subject).getElements();
|
||||
for (JsExport.Element element : elements) {
|
||||
nameDef(element.getName());
|
||||
JsName alias = element.getAlias();
|
||||
if (alias != null) {
|
||||
p.print(" as ");
|
||||
nameDef(alias);
|
||||
}
|
||||
p.print(',');
|
||||
p.newline();
|
||||
}
|
||||
p.indentOut();
|
||||
p.print('}');
|
||||
}
|
||||
|
||||
if (export.getFromModule() != null) {
|
||||
p.print(" from ");
|
||||
p.print(javaScriptString(export.getFromModule()));
|
||||
}
|
||||
needSemi = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitImport(@NotNull JsImport jsImport) {
|
||||
p.print("import {");
|
||||
boolean isMultiline = jsImport.getElements().size() > 1;
|
||||
p.indentIn();
|
||||
if (isMultiline)
|
||||
newlineOpt();
|
||||
else
|
||||
space();
|
||||
|
||||
for (JsImport.Element element : jsImport.getElements()) {
|
||||
nameDef(element.getName());
|
||||
JsName alias = element.getAlias();
|
||||
if (alias != null) {
|
||||
p.print(" as ");
|
||||
nameDef(alias);
|
||||
}
|
||||
|
||||
if (isMultiline) {
|
||||
p.print(',');
|
||||
newlineOpt();
|
||||
} else {
|
||||
space();
|
||||
}
|
||||
}
|
||||
p.indentOut();
|
||||
p.print("} from ");
|
||||
p.print(javaScriptString(jsImport.getModule()));
|
||||
}
|
||||
|
||||
|
||||
private void newline() {
|
||||
p.newline();
|
||||
sourceLocationConsumer.newLine();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.js.backend.ast
|
||||
|
||||
class JsExport(
|
||||
val subject: Subject,
|
||||
val fromModule: String? = null,
|
||||
) : SourceInfoAwareJsNode(), JsStatement {
|
||||
|
||||
constructor(element: Element) : this(Subject.Elements(listOf(element)))
|
||||
constructor(name: JsName, alias: JsName? = null) : this(Element(name, alias))
|
||||
|
||||
sealed class Subject {
|
||||
class Elements(val elements: List<Element>) : Subject()
|
||||
object All : Subject()
|
||||
}
|
||||
|
||||
class Element(
|
||||
val name: JsName,
|
||||
val alias: JsName?
|
||||
)
|
||||
|
||||
override fun accept(visitor: JsVisitor) {
|
||||
visitor.visitExport(this)
|
||||
}
|
||||
|
||||
override fun acceptChildren(visitor: JsVisitor) {
|
||||
}
|
||||
|
||||
override fun deepCopy(): JsStatement =
|
||||
JsExport(subject, fromModule)
|
||||
|
||||
override fun traverse(v: JsVisitorWithContext, ctx: JsContext<*>) {
|
||||
v.visit(this, ctx)
|
||||
v.endVisit(this, ctx)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.js.backend.ast
|
||||
|
||||
class JsImport(
|
||||
val module: String,
|
||||
val elements: MutableList<Element> = mutableListOf(),
|
||||
) : SourceInfoAwareJsNode(), JsStatement {
|
||||
|
||||
class Element(
|
||||
val name: JsName,
|
||||
val alias: JsName?
|
||||
) {
|
||||
constructor(name: String, alias: String?) : this(JsName(name), alias?.let { JsName(it) })
|
||||
}
|
||||
|
||||
override fun accept(visitor: JsVisitor) {
|
||||
visitor.visitImport(this)
|
||||
}
|
||||
|
||||
override fun acceptChildren(visitor: JsVisitor) {
|
||||
}
|
||||
|
||||
override fun deepCopy(): JsStatement =
|
||||
JsImport(module, elements.map { it }.toMutableList())
|
||||
|
||||
override fun traverse(v: JsVisitorWithContext, ctx: JsContext<*>) {
|
||||
v.visit(this, ctx)
|
||||
v.endVisit(this, ctx)
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,12 @@ abstract class JsVisitor {
|
||||
open fun visitSingleLineComment(comment: JsSingleLineComment): Unit =
|
||||
visitElement(comment)
|
||||
|
||||
open fun visitExport(export: JsExport): Unit =
|
||||
visitElement(export)
|
||||
|
||||
open fun visitImport(import: JsImport): Unit =
|
||||
visitElement(import)
|
||||
|
||||
protected open fun visitElement(node: JsNode) {
|
||||
}
|
||||
}
|
||||
@@ -214,6 +214,12 @@ public abstract class JsVisitorWithContext {
|
||||
public void endVisit(@NotNull JsSingleLineComment x, @NotNull JsContext ctx) {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsExport x, @NotNull JsContext ctx) {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsImport x, @NotNull JsContext ctx) {
|
||||
}
|
||||
|
||||
public void endVisit(@NotNull JsWhile x, @NotNull JsContext ctx) {
|
||||
endVisit((JsLoop) x, ctx);
|
||||
}
|
||||
@@ -398,6 +404,14 @@ public abstract class JsVisitorWithContext {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsExport x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean visit(@NotNull JsImport x, @NotNull JsContext ctx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected abstract <T extends JsNode> T doAccept(T node);
|
||||
|
||||
protected abstract JsExpression doAcceptLvalue(JsExpression expr);
|
||||
|
||||
+1
@@ -124,6 +124,7 @@ object KotlinJavascriptSerializationUtil {
|
||||
ModuleKind.AMD -> JsProtoBuf.Library.Kind.AMD
|
||||
ModuleKind.COMMON_JS -> JsProtoBuf.Library.Kind.COMMON_JS
|
||||
ModuleKind.UMD -> JsProtoBuf.Library.Kind.UMD
|
||||
ModuleKind.ES -> error("Es modules serialization")
|
||||
}
|
||||
if (builder.kind != moduleProtoKind) {
|
||||
builder.kind = moduleProtoKind
|
||||
|
||||
@@ -22,5 +22,6 @@ public enum ModuleKind {
|
||||
PLAIN,
|
||||
AMD,
|
||||
COMMON_JS,
|
||||
UMD
|
||||
UMD,
|
||||
ES
|
||||
}
|
||||
|
||||
@@ -257,6 +257,8 @@ projectTest(parallel = true) {
|
||||
}
|
||||
|
||||
projectTest("jsTest", true) {
|
||||
// PIR temporary disabled
|
||||
systemProperty("kotlin.js.ir.pir", "false")
|
||||
setUpJsBoxTests(jsEnabled = true, jsIrEnabled = false)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,11 +47,6 @@ fun main(args: Array<String>) {
|
||||
model("typescript-export/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS_IR_ES6)
|
||||
}
|
||||
|
||||
testClass<AbstractLegacyJsTypeScriptExportTest> {
|
||||
model("typescript-export/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
||||
}
|
||||
|
||||
|
||||
testClass<AbstractSourceMapGenerationSmokeTest> {
|
||||
model("sourcemap/", pattern = "^([^_](.+))\\.kt$", targetBackend = TargetBackend.JS)
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalDataProviderImpl
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumerImpl
|
||||
import org.jetbrains.kotlin.incremental.js.TranslationResultValue
|
||||
import org.jetbrains.kotlin.ir.backend.js.codegen.JsGenerationGranularity
|
||||
import org.jetbrains.kotlin.ir.backend.js.ic.ICCache
|
||||
import org.jetbrains.kotlin.js.JavaScript
|
||||
import org.jetbrains.kotlin.js.backend.JsToStringGenerationVisitor
|
||||
@@ -46,6 +47,7 @@ import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapParser
|
||||
import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapSuccess
|
||||
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver
|
||||
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
||||
import org.jetbrains.kotlin.js.test.engines.ExternalTool
|
||||
import org.jetbrains.kotlin.js.sourceMap.SourceMapBuilderConsumer
|
||||
import org.jetbrains.kotlin.js.test.utils.*
|
||||
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
||||
@@ -153,7 +155,17 @@ abstract class BasicBoxTest(
|
||||
if (errorPolicyMatcher.find()) ErrorTolerancePolicy.resolvePolicy(errorPolicyMatcher.group(1)) else ErrorTolerancePolicy.DEFAULT
|
||||
|
||||
val skipDceDriven = SKIP_DCE_DRIVEN.matcher(fileContent).find()
|
||||
val esModules = ES_MODULES.matcher(fileContent).find()
|
||||
|
||||
val splitPerModule = SPLIT_PER_MODULE.matcher(fileContent).find()
|
||||
val splitPerFile = SPLIT_PER_FILE.matcher(fileContent).find()
|
||||
|
||||
val granularity = when {
|
||||
splitPerModule -> JsGenerationGranularity.PER_MODULE
|
||||
splitPerFile -> JsGenerationGranularity.PER_FILE
|
||||
else -> JsGenerationGranularity.WHOLE_PROGRAM
|
||||
}
|
||||
|
||||
val skipMangleVerification = SKIP_MANGLE_VERIFICATION.matcher(fileContent).find()
|
||||
|
||||
val safeExternalBoolean = SAFE_EXTERNAL_BOOLEAN.matcher(fileContent).find()
|
||||
@@ -196,6 +208,12 @@ abstract class BasicBoxTest(
|
||||
val mainModule = modules[mainModuleName] ?: error("No module with name \"$mainModuleName\"")
|
||||
val icCache = mutableMapOf<String, TestModuleCache>()
|
||||
|
||||
if (esModules) {
|
||||
modules.forEach { _, m -> m.moduleKind = ModuleKind.ES }
|
||||
}
|
||||
|
||||
val customTestModule: String? = inputFiles.find { it.testEntryEsModule }?.let { File(it.fileName).readText() }
|
||||
|
||||
val generatedJsFiles = orderedModules.asReversed().mapNotNull { module ->
|
||||
val dependencies = module.dependenciesSymbols.map { modules[it]?.outputFileName(outputDir) + ".meta.js" }
|
||||
val allDependencies = module.allTransitiveDependencies().map { modules[it]?.outputFileName(outputDir) + ".meta.js" }
|
||||
@@ -229,7 +247,8 @@ abstract class BasicBoxTest(
|
||||
isMainModule,
|
||||
expectActualLinker,
|
||||
skipDceDriven,
|
||||
splitPerModule,
|
||||
esModules,
|
||||
granularity,
|
||||
errorPolicy,
|
||||
propertyLazyInitialization = true,
|
||||
safeExternalBoolean,
|
||||
@@ -237,7 +256,8 @@ abstract class BasicBoxTest(
|
||||
skipMangleVerification,
|
||||
abiVersion,
|
||||
checkIC,
|
||||
icCache
|
||||
icCache,
|
||||
customTestModule,
|
||||
)
|
||||
|
||||
when {
|
||||
@@ -279,6 +299,7 @@ abstract class BasicBoxTest(
|
||||
}
|
||||
|
||||
val additionalFiles = mutableListOf<String>()
|
||||
val moduleEmulationFiles = mutableListOf<String>()
|
||||
|
||||
val moduleKindMatcher = MODULE_KIND_PATTERN.matcher(fileContent)
|
||||
val moduleKind = if (moduleKindMatcher.find()) ModuleKind.valueOf(moduleKindMatcher.group(1)) else ModuleKind.PLAIN
|
||||
@@ -286,7 +307,7 @@ abstract class BasicBoxTest(
|
||||
val withModuleSystem = moduleKind != ModuleKind.PLAIN && !NO_MODULE_SYSTEM_PATTERN.matcher(fileContent).find()
|
||||
|
||||
if (withModuleSystem) {
|
||||
additionalFiles += MODULE_EMULATION_FILE
|
||||
moduleEmulationFiles += MODULE_EMULATION_FILE
|
||||
}
|
||||
|
||||
val additionalJsFile = filePath.removeSuffix("." + KotlinFileType.EXTENSION) + JavaScript.DOT_EXTENSION
|
||||
@@ -294,6 +315,63 @@ abstract class BasicBoxTest(
|
||||
additionalFiles += additionalJsFile
|
||||
}
|
||||
|
||||
if (esModules) {
|
||||
val additionalMainJsFile =
|
||||
(filePath.removeSuffix("." + KotlinFileType.EXTENSION) + "__main.js").takeIf { File(it).exists() }
|
||||
|
||||
val maybeAdditionalMjsFile: String? =
|
||||
(filePath.removeSuffix("." + KotlinFileType.EXTENSION) + ".mjs")
|
||||
.takeIf { File(it).exists() }
|
||||
|
||||
val allMjsFiles: List<String> =
|
||||
inputFiles.filter { it.fileName.endsWith(".mjs") }.map { it.fileName } + listOfNotNull(maybeAdditionalMjsFile)
|
||||
|
||||
val allNonEsModuleFiles: List<String> =
|
||||
additionalFiles + inputJsFilesBefore + globalCommonFiles + localCommonFiles + additionalCommonFiles
|
||||
|
||||
fun runIrEsmTests(testOutputDir: File) {
|
||||
val esmOutputDir = testOutputDir.esModulesSubDir
|
||||
|
||||
// Copy __main file if present
|
||||
if (additionalMainJsFile != null) {
|
||||
val newFileName = File(esmOutputDir, "test.mjs")
|
||||
newFileName.delete()
|
||||
File(additionalMainJsFile).copyTo(newFileName)
|
||||
}
|
||||
|
||||
// Copy all .mjs files into generated directory
|
||||
allMjsFiles.forEach { mjsFile ->
|
||||
val outFile = File(esmOutputDir, File(mjsFile).name)
|
||||
File(mjsFile).copyTo(outFile)
|
||||
}
|
||||
|
||||
val perFileEsModuleFile = "$esmOutputDir/test.mjs"
|
||||
v8tool.run(*allNonEsModuleFiles.toTypedArray(), perFileEsModuleFile, *inputJsFilesAfter.toTypedArray())
|
||||
}
|
||||
|
||||
fun File.getTestDir(): File =
|
||||
File(generatedJsFiles.single().first.replace(outputDir.absolutePath, this.absolutePath))
|
||||
|
||||
if (!skipRegularMode) {
|
||||
runIrEsmTests(outputDir.getTestDir())
|
||||
|
||||
if (runIrDce) {
|
||||
runIrEsmTests(dceOutputDir.getTestDir())
|
||||
}
|
||||
}
|
||||
|
||||
if (runIrPir && !skipDceDriven) {
|
||||
runIrEsmTests(pirOutputDir.getTestDir())
|
||||
}
|
||||
}
|
||||
|
||||
if (esModules)
|
||||
return
|
||||
|
||||
// Old systems tests
|
||||
|
||||
additionalFiles.addAll(0, moduleEmulationFiles)
|
||||
|
||||
val additionalMainFiles = mutableListOf<String>()
|
||||
val additionalMainJsFile = filePath.removeSuffix("." + KotlinFileType.EXTENSION) + "__main.js"
|
||||
if (File(additionalMainJsFile).exists()) {
|
||||
@@ -318,7 +396,6 @@ abstract class BasicBoxTest(
|
||||
} +
|
||||
globalCommonFiles + localCommonFiles + additionalCommonFiles + additionalMainFiles + inputJsFilesAfter
|
||||
|
||||
|
||||
val dontRunGeneratedCode =
|
||||
InTextDirectivesUtils.dontRunGeneratedCode(targetBackend, file)
|
||||
|
||||
@@ -501,7 +578,8 @@ abstract class BasicBoxTest(
|
||||
isMainModule: Boolean,
|
||||
expectActualLinker: Boolean,
|
||||
skipDceDriven: Boolean,
|
||||
splitPerModule: Boolean,
|
||||
esModules: Boolean,
|
||||
granularity: JsGenerationGranularity,
|
||||
errorIgnorancePolicy: ErrorTolerancePolicy,
|
||||
propertyLazyInitialization: Boolean,
|
||||
safeExternalBoolean: Boolean,
|
||||
@@ -509,7 +587,8 @@ abstract class BasicBoxTest(
|
||||
skipMangleVerification: Boolean,
|
||||
abiVersion: KotlinAbiVersion,
|
||||
checkIC: Boolean,
|
||||
icCache: MutableMap<String, TestModuleCache>
|
||||
icCache: MutableMap<String, TestModuleCache>,
|
||||
customTestModule: String?,
|
||||
) {
|
||||
val kotlinFiles = module.files.filter { it.fileName.endsWith(".kt") }
|
||||
val testFiles = kotlinFiles.map { it.fileName }
|
||||
@@ -558,7 +637,8 @@ abstract class BasicBoxTest(
|
||||
needsFullIrRuntime,
|
||||
isMainModule,
|
||||
skipDceDriven,
|
||||
splitPerModule,
|
||||
esModules,
|
||||
granularity,
|
||||
propertyLazyInitialization,
|
||||
safeExternalBoolean,
|
||||
safeExternalBooleanDiagnostic,
|
||||
@@ -566,7 +646,8 @@ abstract class BasicBoxTest(
|
||||
abiVersion,
|
||||
checkIC,
|
||||
recompile = false,
|
||||
icCache
|
||||
icCache,
|
||||
customTestModule,
|
||||
)
|
||||
|
||||
if (incrementalCompilationChecksEnabled && module.hasFilesToRecompile) {
|
||||
@@ -661,7 +742,8 @@ abstract class BasicBoxTest(
|
||||
needsFullIrRuntime,
|
||||
isMainModule = false,
|
||||
skipDceDriven = true,
|
||||
splitPerModule = false,
|
||||
esModules = false,
|
||||
granularity = JsGenerationGranularity.WHOLE_PROGRAM,
|
||||
propertyLazyInitialization = true,
|
||||
safeExternalBoolean = false,
|
||||
safeExternalBooleanDiagnostic = null,
|
||||
@@ -669,7 +751,8 @@ abstract class BasicBoxTest(
|
||||
abiVersion = KotlinAbiVersion.CURRENT,
|
||||
incrementalCompilation = true,
|
||||
recompile = true,
|
||||
mutableMapOf()
|
||||
mutableMapOf(),
|
||||
customTestModule = null,
|
||||
)
|
||||
|
||||
val originalOutput = FileUtil.loadFile(outputFile)
|
||||
@@ -747,7 +830,8 @@ abstract class BasicBoxTest(
|
||||
needsFullIrRuntime: Boolean,
|
||||
isMainModule: Boolean,
|
||||
skipDceDriven: Boolean,
|
||||
splitPerModule: Boolean,
|
||||
esModules: Boolean,
|
||||
granularity: JsGenerationGranularity,
|
||||
propertyLazyInitialization: Boolean,
|
||||
safeExternalBoolean: Boolean,
|
||||
safeExternalBooleanDiagnostic: RuntimeDiagnostic?,
|
||||
@@ -755,7 +839,8 @@ abstract class BasicBoxTest(
|
||||
abiVersion: KotlinAbiVersion,
|
||||
incrementalCompilation: Boolean,
|
||||
recompile: Boolean,
|
||||
icCache: MutableMap<String, TestModuleCache>
|
||||
icCache: MutableMap<String, TestModuleCache>,
|
||||
customTestModule: String?,
|
||||
) {
|
||||
val translator = K2JSTranslator(config, false)
|
||||
val translationResult = translator.translateUnits(ExceptionThrowingReporter, units, mainCallParameters)
|
||||
@@ -813,6 +898,8 @@ abstract class BasicBoxTest(
|
||||
"$content\n"
|
||||
|
||||
ModuleKind.PLAIN -> content
|
||||
|
||||
ModuleKind.ES -> error("Module emulation markers are not supported for ES modules")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,7 +1169,8 @@ abstract class BasicBoxTest(
|
||||
temporaryFile.absolutePath,
|
||||
currentModule,
|
||||
recompile = RECOMPILE_PATTERN.matcher(text).find(),
|
||||
packageName = ktFile.packageFqName.asString()
|
||||
packageName = ktFile.packageFqName.asString(),
|
||||
testEntryEsModule = ENTRY_ES_MODULE.matcher(text).find(),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1099,7 +1187,7 @@ abstract class BasicBoxTest(
|
||||
}
|
||||
}
|
||||
|
||||
protected class TestFile(val fileName: String, val module: TestModule, val recompile: Boolean, val packageName: String) {
|
||||
protected class TestFile(val fileName: String, val module: TestModule, val recompile: Boolean, val packageName: String, val testEntryEsModule: Boolean) {
|
||||
init {
|
||||
module.files += this
|
||||
}
|
||||
@@ -1149,6 +1237,8 @@ abstract class BasicBoxTest(
|
||||
// Run top level box function
|
||||
private val RUN_PLAIN_BOX_FUNCTION = Pattern.compile("^// *RUN_PLAIN_BOX_FUNCTION", Pattern.MULTILINE)
|
||||
|
||||
private val ENTRY_ES_MODULE = Pattern.compile("^// *ENTRY_ES_MODULE", Pattern.MULTILINE)
|
||||
|
||||
private val NO_INLINE_PATTERN = Pattern.compile("^// *NO_INLINE *$", Pattern.MULTILINE)
|
||||
private val SKIP_NODE_JS = Pattern.compile("^// *SKIP_NODE_JS *$", Pattern.MULTILINE)
|
||||
private val SKIP_MINIFICATION = Pattern.compile("^// *SKIP_MINIFICATION *$", Pattern.MULTILINE)
|
||||
@@ -1163,7 +1253,10 @@ abstract class BasicBoxTest(
|
||||
private val WITH_STDLIB = Pattern.compile("^// *WITH_STDLIB *\$", Pattern.MULTILINE)
|
||||
private val EXPECT_ACTUAL_LINKER = Pattern.compile("^// EXPECT_ACTUAL_LINKER *$", Pattern.MULTILINE)
|
||||
private val SKIP_DCE_DRIVEN = Pattern.compile("^// *SKIP_DCE_DRIVEN *$", Pattern.MULTILINE)
|
||||
private val ES_MODULES = Pattern.compile("^// *ES_MODULES *$", Pattern.MULTILINE)
|
||||
|
||||
private val SPLIT_PER_MODULE = Pattern.compile("^// *SPLIT_PER_MODULE *$", Pattern.MULTILINE)
|
||||
private val SPLIT_PER_FILE = Pattern.compile("^// *SPLIT_PER_FILE *$", Pattern.MULTILINE)
|
||||
private val SKIP_MANGLE_VERIFICATION = Pattern.compile("^// *SKIP_MANGLE_VERIFICATION *$", Pattern.MULTILINE)
|
||||
|
||||
private val ERROR_POLICY_PATTERN = Pattern.compile("^// *ERROR_POLICY: *(.+)$", Pattern.MULTILINE)
|
||||
@@ -1216,4 +1309,6 @@ fun RuntimeDiagnostic.Companion.resolve(
|
||||
else -> {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val v8tool by lazy { ExternalTool(System.getProperty("javascript.engine.path.V8")) }
|
||||
@@ -10,7 +10,14 @@ import org.jetbrains.kotlin.backend.common.phaser.AnyNamedPhase
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||
import org.jetbrains.kotlin.backend.common.phaser.toPhaseMap
|
||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.ir.backend.js.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.codegen.CompilerOutputSink
|
||||
import org.jetbrains.kotlin.ir.backend.js.codegen.JsGenerationGranularity
|
||||
import org.jetbrains.kotlin.ir.backend.js.codegen.JsGenerationGranularity.*
|
||||
import org.jetbrains.kotlin.ir.backend.js.codegen.JsGenerationOptions
|
||||
import org.jetbrains.kotlin.ir.backend.js.codegen.generateEsModules
|
||||
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransformer
|
||||
import org.jetbrains.kotlin.ir.backend.js.ic.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
@@ -205,7 +212,8 @@ abstract class BasicIrBoxTest(
|
||||
needsFullIrRuntime: Boolean,
|
||||
isMainModule: Boolean,
|
||||
skipDceDriven: Boolean,
|
||||
splitPerModule: Boolean,
|
||||
esModules: Boolean,
|
||||
granularity: JsGenerationGranularity,
|
||||
propertyLazyInitialization: Boolean,
|
||||
safeExternalBoolean: Boolean,
|
||||
safeExternalBooleanDiagnostic: RuntimeDiagnostic?,
|
||||
@@ -213,7 +221,8 @@ abstract class BasicIrBoxTest(
|
||||
abiVersion: KotlinAbiVersion,
|
||||
incrementalCompilation: Boolean,
|
||||
recompile: Boolean,
|
||||
icCache: MutableMap<String, TestModuleCache>
|
||||
icCache: MutableMap<String, TestModuleCache>,
|
||||
customTestModule: String?,
|
||||
) {
|
||||
val filesToCompile = units.mapNotNull { (it as? TranslationUnit.SourceFile)?.file }
|
||||
|
||||
@@ -299,38 +308,73 @@ abstract class BasicIrBoxTest(
|
||||
icCache = emptyMap()
|
||||
)
|
||||
|
||||
if (!skipRegularMode) {
|
||||
// val dirtyFilesToRecompile = if (recompile) {
|
||||
// units.map { (it as TranslationUnit.SourceFile).file.virtualFilePath }.toSet()
|
||||
// } else null
|
||||
val dirtyFilesToRecompile: Set<String>? = null
|
||||
|
||||
val compiledModule = compile(
|
||||
val mainArguments = mainCallParameters.run { if (shouldBeGenerated()) arguments() else null }
|
||||
fun compileToLoweredIr(
|
||||
dceDriven: Boolean,
|
||||
granularity: JsGenerationGranularity,
|
||||
dirtyFilesToRecompile: Set<String>? = null
|
||||
): LoweredIr =
|
||||
compile(
|
||||
module,
|
||||
phaseConfig = phaseConfig,
|
||||
irFactory = IrFactoryImpl,
|
||||
mainArguments = mainCallParameters.run { if (shouldBeGenerated()) arguments() else null },
|
||||
exportedDeclarations = setOf(FqName.fromSegments(listOfNotNull(testPackage, testFunction))),
|
||||
generateFullJs = true,
|
||||
generateDceJs = runIrDce,
|
||||
dceDriven = false,
|
||||
dceDriven = dceDriven,
|
||||
es6mode = runEs6Mode,
|
||||
multiModule = splitPerModule || perModule,
|
||||
propertyLazyInitialization = propertyLazyInitialization,
|
||||
verifySignatures = !skipMangleVerification,
|
||||
lowerPerModule = lowerPerModule,
|
||||
safeExternalBoolean = safeExternalBoolean,
|
||||
safeExternalBooleanDiagnostic = safeExternalBooleanDiagnostic,
|
||||
verifySignatures = !skipMangleVerification,
|
||||
granularity = granularity,
|
||||
filesToLower = dirtyFilesToRecompile
|
||||
)
|
||||
|
||||
// if (incrementalCompilation) {
|
||||
// // TODO: enable once incremental js generation is done
|
||||
// generateJsFromAst(klibPath, icCache.map { it.key to it.value.createModuleCache() }.toMap())
|
||||
// }
|
||||
fun generateTestFile(outputDir: File) {
|
||||
val moduleName = config.configuration[CommonConfigurationKeys.MODULE_NAME]
|
||||
val esmTestFile = File(outputDir, "test.mjs")
|
||||
logger.logFile("ES module test file", esmTestFile)
|
||||
val defaultTestModule =
|
||||
"""
|
||||
import { box } from './${moduleName}/index.js';
|
||||
let res = box();
|
||||
if (res !== "OK") {
|
||||
throw "Wrong result: " + String(res);
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
val jsOutputFile = if (recompile) File(outputFile.parentFile, outputFile.nameWithoutExtension + "-recompiled.js")
|
||||
else outputFile
|
||||
esmTestFile.writeText(customTestModule ?: defaultTestModule)
|
||||
}
|
||||
|
||||
val options = JsGenerationOptions(generatePackageJson = true, generateTypeScriptDefinitions = generateDts)
|
||||
|
||||
fun generateEsModules(ir: LoweredIr, outputDir: File, granularity: JsGenerationGranularity) {
|
||||
outputDir.deleteRecursively()
|
||||
generateEsModules(ir, jsOutputSink(outputDir), mainArguments = mainArguments, granularity = granularity, options = options)
|
||||
generateTestFile(outputDir)
|
||||
}
|
||||
|
||||
fun generateOldModuleSystems(
|
||||
ir: LoweredIr,
|
||||
outputFile: File,
|
||||
outputDceFile: File,
|
||||
granularity: JsGenerationGranularity,
|
||||
runDce: Boolean,
|
||||
dirtyFilesToRecompile: Set<String>? = null
|
||||
) {
|
||||
outputFile.deleteRecursively()
|
||||
|
||||
check(granularity != PER_FILE) { "Per file granularity is not supported for old module systems" }
|
||||
val transformer = IrModuleToJsTransformer(
|
||||
ir.context,
|
||||
mainArguments,
|
||||
fullJs = true,
|
||||
dceJs = runDce,
|
||||
multiModule = granularity == PER_MODULE,
|
||||
relativeRequirePath = false
|
||||
)
|
||||
val compiledModule: CompilerResult = transformer.generateModule(ir.allModules)
|
||||
|
||||
val compiledOutput = if (dirtyFilesToRecompile != null) CompilationOutputs(
|
||||
"""
|
||||
@@ -343,9 +387,9 @@ abstract class BasicIrBoxTest(
|
||||
) else compiledModule.outputs!!
|
||||
val compiledDCEOutput = if (dirtyFilesToRecompile != null) null else compiledModule.outputsAfterDce
|
||||
|
||||
compiledOutput.writeTo(jsOutputFile, config)
|
||||
compiledOutput.writeTo(outputFile, config)
|
||||
|
||||
compiledDCEOutput?.writeTo(dceOutputFile, config)
|
||||
compiledDCEOutput?.writeTo(outputDceFile, config)
|
||||
|
||||
if (generateDts) {
|
||||
val dtsFile = outputFile.withReplacedExtensionOrNull("_v5.js", ".d.ts")!!
|
||||
@@ -356,26 +400,31 @@ abstract class BasicIrBoxTest(
|
||||
compiledOutput.jsProgram?.let { processJsProgram(it, units) }
|
||||
}
|
||||
|
||||
if (runIrPir) {
|
||||
val compiledModule = compile(
|
||||
module,
|
||||
phaseConfig = phaseConfig,
|
||||
irFactory = PersistentIrFactory(),
|
||||
mainArguments = mainCallParameters.run { if (shouldBeGenerated()) arguments() else null },
|
||||
exportedDeclarations = setOf(FqName.fromSegments(listOfNotNull(testPackage, testFunction))),
|
||||
generateFullJs = true,
|
||||
generateDceJs = runIrDce,
|
||||
dceDriven = true,
|
||||
es6mode = runEs6Mode,
|
||||
multiModule = splitPerModule || perModule,
|
||||
propertyLazyInitialization = propertyLazyInitialization,
|
||||
lowerPerModule = lowerPerModule,
|
||||
safeExternalBoolean = safeExternalBoolean,
|
||||
safeExternalBooleanDiagnostic = safeExternalBooleanDiagnostic,
|
||||
verifySignatures = !skipMangleVerification,
|
||||
)
|
||||
compiledModule.outputs!!.writeTo(pirOutputFile, config)
|
||||
processJsProgram(compiledModule.outputs!!.jsProgram!!, units)
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val granularity = if (perModule) PER_MODULE else granularity
|
||||
|
||||
if (!skipRegularMode) {
|
||||
val ir = compileToLoweredIr(dceDriven = false, granularity)
|
||||
if (esModules) {
|
||||
generateEsModules(ir, outputFile.esModulesSubDir, granularity)
|
||||
if (runIrDce) {
|
||||
eliminateDeadDeclarations(ir.allModules, ir.context)
|
||||
generateEsModules(ir, dceOutputFile.esModulesSubDir, granularity)
|
||||
}
|
||||
} else {
|
||||
val jsOutputFile = if (recompile) File(outputFile.parentFile, outputFile.nameWithoutExtension + "-recompiled.js")
|
||||
else outputFile
|
||||
generateOldModuleSystems(ir, jsOutputFile, dceOutputFile, granularity, runIrDce)
|
||||
}
|
||||
}
|
||||
|
||||
if (runIrPir && !skipDceDriven) {
|
||||
val ir = compileToLoweredIr(dceDriven = true, granularity)
|
||||
if (esModules) {
|
||||
generateEsModules(ir, pirOutputFile.esModulesSubDir, granularity)
|
||||
} else {
|
||||
generateOldModuleSystems(ir, pirOutputFile, pirOutputFile, granularity, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -453,15 +502,19 @@ abstract class BasicIrBoxTest(
|
||||
needsFullIrRuntime,
|
||||
isMainModule,
|
||||
skipDceDriven = true,
|
||||
splitPerModule = false, // TODO??
|
||||
granularity = WHOLE_PROGRAM, // TODO??
|
||||
propertyLazyInitialization = true,
|
||||
safeExternalBoolean = false,
|
||||
safeExternalBooleanDiagnostic = null,
|
||||
skipMangleVerification = false,
|
||||
KotlinAbiVersion.CURRENT,
|
||||
abiVersion = KotlinAbiVersion.CURRENT,
|
||||
incrementalCompilation = true,
|
||||
recompile = true,
|
||||
icCaches
|
||||
icCache = icCaches,
|
||||
|
||||
// TODO??
|
||||
customTestModule = null,
|
||||
esModules = false,
|
||||
)
|
||||
|
||||
val cacheProvider = icCache.cacheProvider()
|
||||
@@ -481,6 +534,19 @@ abstract class BasicIrBoxTest(
|
||||
}
|
||||
}
|
||||
|
||||
private fun jsOutputSink(perFileOutputDir: File): CompilerOutputSink {
|
||||
perFileOutputDir.deleteRecursively()
|
||||
perFileOutputDir.mkdirs()
|
||||
|
||||
return object : CompilerOutputSink {
|
||||
override fun write(module: String, path: String, content: String) {
|
||||
val file = File(File(perFileOutputDir, module), path)
|
||||
file.parentFile.mkdirs()
|
||||
file.writeText(content)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun createIcCache(
|
||||
path: String,
|
||||
dirtyFiles: Collection<String>?,
|
||||
@@ -561,8 +627,10 @@ abstract class BasicIrBoxTest(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun File.write(text: String) {
|
||||
parentFile.mkdirs()
|
||||
writeText(text)
|
||||
}
|
||||
|
||||
val File.esModulesSubDir: File
|
||||
get() = File(absolutePath + "_esm")
|
||||
|
||||
@@ -7,8 +7,12 @@ package org.jetbrains.kotlin.js.test.engines
|
||||
|
||||
import java.io.BufferedReader
|
||||
import java.io.InputStreamReader
|
||||
import java.lang.Boolean.getBoolean
|
||||
import kotlin.test.fail
|
||||
|
||||
|
||||
val toolLogsEnabled: Boolean = getBoolean("kotlin.js.test.verbose")
|
||||
|
||||
class ExternalTool(val path: String) {
|
||||
fun run(vararg arguments: String) {
|
||||
val command = arrayOf(path, *arguments)
|
||||
@@ -17,7 +21,9 @@ class ExternalTool(val path: String) {
|
||||
.start()
|
||||
|
||||
val commandString = command.joinToString(" ") { escapeShellArgument(it) }
|
||||
println(commandString)
|
||||
if (toolLogsEnabled) {
|
||||
println(commandString)
|
||||
}
|
||||
|
||||
// Print process output
|
||||
val input = BufferedReader(InputStreamReader(process.inputStream))
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.js.test.semantics
|
||||
|
||||
import org.jetbrains.kotlin.js.test.BasicBoxTest
|
||||
|
||||
abstract class AbstractLegacyJsTypeScriptExportTest : BasicBoxTest(
|
||||
pathToTestDir = TEST_DATA_DIR_PATH + "typescript-export/",
|
||||
testGroupOutputDirPrefix = "legacy-typescript-export/"
|
||||
)
|
||||
Generated
+488
-10
@@ -1587,6 +1587,494 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EsModules extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInEsModules() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRef")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRef extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRef() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRef"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableObjectRef.kt")
|
||||
public void testCallableObjectRef() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/callableObjectRef.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineJsModule.kt")
|
||||
public void testInlineJsModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineJsModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineJsModuleNonIdentifier.kt")
|
||||
public void testInlineJsModuleNonIdentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineJsModuleNonIdentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineJsModulePackage.kt")
|
||||
public void testInlineJsModulePackage() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineJsModulePackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModule.kt")
|
||||
public void testInlineModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModuleNonIndentifier.kt")
|
||||
public void testInlineModuleNonIndentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineModuleNonIndentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/lambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("object.kt")
|
||||
public void testObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/object.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectInInlineClosure.kt")
|
||||
public void testObjectInInlineClosure() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/objectInInlineClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectIsObject.kt")
|
||||
public void testObjectIsObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/objectIsObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelExtension.kt")
|
||||
public void testTopLevelExtension() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelMutableProperty.kt")
|
||||
public void testTopLevelMutableProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelMutableProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelProperty.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRefPerFile")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRefPerFile extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRefPerFile() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRefPerFile"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableObjectRef.kt")
|
||||
public void testCallableObjectRef() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/callableObjectRef.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/inheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModule.kt")
|
||||
public void testInlineModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/inlineModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModuleNonIndentifier.kt")
|
||||
public void testInlineModuleNonIndentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/inlineModuleNonIndentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/lambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("object.kt")
|
||||
public void testObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/object.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectInInlineClosure.kt")
|
||||
public void testObjectInInlineClosure() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/objectInInlineClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectIsObject.kt")
|
||||
public void testObjectIsObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/objectIsObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelExtension.kt")
|
||||
public void testTopLevelExtension() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelMutableProperty.kt")
|
||||
public void testTopLevelMutableProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelMutableProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelProperty.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRefPerModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRefPerModule extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRefPerModule() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRefPerModule"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableObjectRef.kt")
|
||||
public void testCallableObjectRef() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/callableObjectRef.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/inheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModule.kt")
|
||||
public void testInlineModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/inlineModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModuleNonIndentifier.kt")
|
||||
public void testInlineModuleNonIndentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/inlineModuleNonIndentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/lambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("object.kt")
|
||||
public void testObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/object.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectInInlineClosure.kt")
|
||||
public void testObjectInInlineClosure() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/objectInInlineClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectIsObject.kt")
|
||||
public void testObjectIsObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/objectIsObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelExtension.kt")
|
||||
public void testTopLevelExtension() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelMutableProperty.kt")
|
||||
public void testTopLevelMutableProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelMutableProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelProperty.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/export")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Export extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("exportAllFile.kt")
|
||||
public void testExportAllFile() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/exportAllFile.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonIndetifierModuleName.kt")
|
||||
public void testNonIndetifierModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/nonIndetifierModuleName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenChainNonExportIntermediate.kt")
|
||||
public void testOverriddenChainNonExportIntermediate() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/overriddenChainNonExportIntermediate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenExternalMethodWithSameNameMethod.kt")
|
||||
public void testOverriddenExternalMethodWithSameNameMethod() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/overriddenExternalMethodWithSameNameMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenExternalMethodWithSameStableNameMethod.kt")
|
||||
public void testOverriddenExternalMethodWithSameStableNameMethod() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/overriddenExternalMethodWithSameStableNameMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reservedModuleName.kt")
|
||||
public void testReservedModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/reservedModuleName.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/incremental")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Incremental extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIncremental() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/incremental"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("jsModule.kt")
|
||||
public void testJsModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/incremental/jsModule.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/inline")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Inline extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInline() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/inline"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlinedObjectLiteralIsCheck.kt")
|
||||
public void testInlinedObjectLiteralIsCheck() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/inline/inlinedObjectLiteralIsCheck.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsExport")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsExport extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsExport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsExport"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClass.kt")
|
||||
public void testDataClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/dataClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("exportedDefaultStub.kt")
|
||||
public void testExportedDefaultStub() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/exportedDefaultStub.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jsExportInClass.kt")
|
||||
public void testJsExportInClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/jsExportInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveExport.kt")
|
||||
public void testRecursiveExport() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/recursiveExport.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsModule extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsModule() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsModule"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("externalClass.kt")
|
||||
public void testExternalClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalClassNameClash.kt")
|
||||
public void testExternalClassNameClash() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalClassNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalClassWithDefaults.kt")
|
||||
public void testExternalClassWithDefaults() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalClassWithDefaults.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalConstructor.kt")
|
||||
public void testExternalConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunction.kt")
|
||||
public void testExternalFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunctionNameClash.kt")
|
||||
public void testExternalFunctionNameClash() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalFunctionNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalObject.kt")
|
||||
public void testExternalObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalPackage.kt")
|
||||
public void testExternalPackage() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalPackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalPackageInDifferentFile.kt")
|
||||
public void testExternalPackageInDifferentFile() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalPackageInDifferentFile.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalProperty.kt")
|
||||
public void testExternalProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaces.kt")
|
||||
public void testInterfaces() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/interfaces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelVarargFun.kt")
|
||||
public void testTopLevelVarargFun() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/topLevelVarargFun.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsName")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsName extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsName() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsName"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultJsName.kt")
|
||||
public void testDefaultJsName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsName/defaultJsName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jsTopLevelClashes.kt")
|
||||
public void testJsTopLevelClashes() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsName/jsTopLevelClashes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/native")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Native extends AbstractIrBoxJsES6Test {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNative() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/native"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritanceInNativeClass.kt")
|
||||
public void testInheritanceInNativeClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/native/inheritanceInNativeClass.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/examples")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -2385,21 +2873,11 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingClashFunctionsAndClasses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manglingClashWithFunctionsWithoutParameters.kt")
|
||||
public void testManglingClashWithFunctionsWithoutParameters() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingClashWithFunctionsWithoutParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manglingImportedFromObjectWithNI.kt")
|
||||
public void testManglingImportedFromObjectWithNI() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingImportedFromObjectWithNI.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manglingStability.kt")
|
||||
public void testManglingStability() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingStability.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namedArguments.kt")
|
||||
public void testNamedArguments() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/namedArguments.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
-5
@@ -20145,11 +20145,6 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/properties/lazyInitializationOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lazyInitializationPure.kt")
|
||||
public void testLazyInitializationPure() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/lazyInitializationPure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lazyInitializationSplitPerModule.kt")
|
||||
public void testLazyInitializationSplitPerModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/lazyInitializationSplitPerModule.kt");
|
||||
|
||||
+488
-10
@@ -1587,6 +1587,494 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EsModules extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInEsModules() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRef")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRef extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRef() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRef"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableObjectRef.kt")
|
||||
public void testCallableObjectRef() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/callableObjectRef.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineJsModule.kt")
|
||||
public void testInlineJsModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineJsModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineJsModuleNonIdentifier.kt")
|
||||
public void testInlineJsModuleNonIdentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineJsModuleNonIdentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineJsModulePackage.kt")
|
||||
public void testInlineJsModulePackage() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineJsModulePackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModule.kt")
|
||||
public void testInlineModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModuleNonIndentifier.kt")
|
||||
public void testInlineModuleNonIndentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/inlineModuleNonIndentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/lambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("object.kt")
|
||||
public void testObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/object.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectInInlineClosure.kt")
|
||||
public void testObjectInInlineClosure() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/objectInInlineClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectIsObject.kt")
|
||||
public void testObjectIsObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/objectIsObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelExtension.kt")
|
||||
public void testTopLevelExtension() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelMutableProperty.kt")
|
||||
public void testTopLevelMutableProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelMutableProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRef/topLevelProperty.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRefPerFile")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRefPerFile extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRefPerFile() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRefPerFile"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableObjectRef.kt")
|
||||
public void testCallableObjectRef() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/callableObjectRef.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/inheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModule.kt")
|
||||
public void testInlineModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/inlineModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModuleNonIndentifier.kt")
|
||||
public void testInlineModuleNonIndentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/inlineModuleNonIndentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/lambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("object.kt")
|
||||
public void testObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/object.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectInInlineClosure.kt")
|
||||
public void testObjectInInlineClosure() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/objectInInlineClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectIsObject.kt")
|
||||
public void testObjectIsObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/objectIsObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelExtension.kt")
|
||||
public void testTopLevelExtension() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelMutableProperty.kt")
|
||||
public void testTopLevelMutableProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelMutableProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerFile/topLevelProperty.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRefPerModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRefPerModule extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRefPerModule() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRefPerModule"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("callableObjectRef.kt")
|
||||
public void testCallableObjectRef() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/callableObjectRef.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constructor.kt")
|
||||
public void testConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/constructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/inheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModule.kt")
|
||||
public void testInlineModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/inlineModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineModuleNonIndentifier.kt")
|
||||
public void testInlineModuleNonIndentifier() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/inlineModuleNonIndentifier.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambda.kt")
|
||||
public void testLambda() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/lambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("object.kt")
|
||||
public void testObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/object.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectInInlineClosure.kt")
|
||||
public void testObjectInInlineClosure() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/objectInInlineClosure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("objectIsObject.kt")
|
||||
public void testObjectIsObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/objectIsObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelExtension.kt")
|
||||
public void testTopLevelExtension() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunction.kt")
|
||||
public void testTopLevelFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelMutableProperty.kt")
|
||||
public void testTopLevelMutableProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelMutableProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelProperty.kt")
|
||||
public void testTopLevelProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/crossModuleRefPerModule/topLevelProperty.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/export")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Export extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("exportAllFile.kt")
|
||||
public void testExportAllFile() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/exportAllFile.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nonIndetifierModuleName.kt")
|
||||
public void testNonIndetifierModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/nonIndetifierModuleName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenChainNonExportIntermediate.kt")
|
||||
public void testOverriddenChainNonExportIntermediate() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/overriddenChainNonExportIntermediate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenExternalMethodWithSameNameMethod.kt")
|
||||
public void testOverriddenExternalMethodWithSameNameMethod() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/overriddenExternalMethodWithSameNameMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenExternalMethodWithSameStableNameMethod.kt")
|
||||
public void testOverriddenExternalMethodWithSameStableNameMethod() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/overriddenExternalMethodWithSameStableNameMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reservedModuleName.kt")
|
||||
public void testReservedModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/reservedModuleName.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/incremental")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Incremental extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIncremental() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/incremental"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("jsModule.kt")
|
||||
public void testJsModule() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/incremental/jsModule.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/inline")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Inline extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInline() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/inline"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inlinedObjectLiteralIsCheck.kt")
|
||||
public void testInlinedObjectLiteralIsCheck() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/inline/inlinedObjectLiteralIsCheck.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsExport")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsExport extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsExport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsExport"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("dataClass.kt")
|
||||
public void testDataClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/dataClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("exportedDefaultStub.kt")
|
||||
public void testExportedDefaultStub() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/exportedDefaultStub.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jsExportInClass.kt")
|
||||
public void testJsExportInClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/jsExportInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("recursiveExport.kt")
|
||||
public void testRecursiveExport() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsExport/recursiveExport.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsModule extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsModule() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsModule"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("externalClass.kt")
|
||||
public void testExternalClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalClassNameClash.kt")
|
||||
public void testExternalClassNameClash() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalClassNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalClassWithDefaults.kt")
|
||||
public void testExternalClassWithDefaults() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalClassWithDefaults.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalConstructor.kt")
|
||||
public void testExternalConstructor() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalConstructor.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunction.kt")
|
||||
public void testExternalFunction() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalFunctionNameClash.kt")
|
||||
public void testExternalFunctionNameClash() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalFunctionNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalObject.kt")
|
||||
public void testExternalObject() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalObject.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalPackage.kt")
|
||||
public void testExternalPackage() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalPackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalPackageInDifferentFile.kt")
|
||||
public void testExternalPackageInDifferentFile() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalPackageInDifferentFile.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("externalProperty.kt")
|
||||
public void testExternalProperty() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/externalProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interfaces.kt")
|
||||
public void testInterfaces() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/interfaces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelVarargFun.kt")
|
||||
public void testTopLevelVarargFun() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsModule/topLevelVarargFun.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsName")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsName extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsName() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsName"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("defaultJsName.kt")
|
||||
public void testDefaultJsName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsName/defaultJsName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jsTopLevelClashes.kt")
|
||||
public void testJsTopLevelClashes() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/jsName/jsTopLevelClashes.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/native")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Native extends AbstractIrBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNative() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/native"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritanceInNativeClass.kt")
|
||||
public void testInheritanceInNativeClass() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/native/inheritanceInNativeClass.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/examples")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -2385,21 +2873,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingClashFunctionsAndClasses.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manglingClashWithFunctionsWithoutParameters.kt")
|
||||
public void testManglingClashWithFunctionsWithoutParameters() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingClashWithFunctionsWithoutParameters.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manglingImportedFromObjectWithNI.kt")
|
||||
public void testManglingImportedFromObjectWithNI() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingImportedFromObjectWithNI.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("manglingStability.kt")
|
||||
public void testManglingStability() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/manglingStability.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namedArguments.kt")
|
||||
public void testNamedArguments() throws Exception {
|
||||
runTest("js/js.translator/testData/box/expression/function/namedArguments.kt");
|
||||
|
||||
Generated
-5
@@ -19551,11 +19551,6 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/properties/lazyInitializationOrder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lazyInitializationPure.kt")
|
||||
public void testLazyInitializationPure() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/lazyInitializationPure.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lazyInitializationSplitPerModule.kt")
|
||||
public void testLazyInitializationSplitPerModule() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/properties/lazyInitializationSplitPerModule.kt");
|
||||
|
||||
+153
@@ -1592,6 +1592,159 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class EsModules extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInEsModules() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRef")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRef extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRef() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRef"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRefPerFile")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRefPerFile extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRefPerFile() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRefPerFile"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/crossModuleRefPerModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class CrossModuleRefPerModule extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInCrossModuleRefPerModule() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/crossModuleRefPerModule"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/export")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Export extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenExternalMethodWithSameStableNameMethod.kt")
|
||||
public void testOverriddenExternalMethodWithSameStableNameMethod() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/overriddenExternalMethodWithSameStableNameMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reservedModuleName.kt")
|
||||
public void testReservedModuleName() throws Exception {
|
||||
runTest("js/js.translator/testData/box/esModules/export/reservedModuleName.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/incremental")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Incremental extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIncremental() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/incremental"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/inline")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Inline extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInline() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/inline"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsExport")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsExport extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsExport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsExport"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsModule")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsModule extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsModule() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsModule"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/jsName")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class JsName extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInJsName() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/jsName"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/esModules/native")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Native extends AbstractBoxJsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNative() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/esModules/native"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/box/examples")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
-181
@@ -1,181 +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.js.test.semantics;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
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("js/js.translator/testData/typescript-export")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class LegacyJsTypeScriptExportTestGenerated extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInTypescript_export() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/constructors")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Constructors extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInConstructors() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/constructors"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/declarations")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Declarations extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInDeclarations() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/declarations"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("declarations.kt")
|
||||
public void testDeclarations() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/declarations/declarations.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/inheritance")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Inheritance extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInheritance() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/inheritance"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritance.kt")
|
||||
public void testInheritance() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/inheritance/inheritance.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/moduleSystems")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class ModuleSystems extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInModuleSystems() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/moduleSystems"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("commonjs.kt")
|
||||
public void testCommonjs() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/moduleSystems/commonjs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("plain.kt")
|
||||
public void testPlain() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/moduleSystems/plain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("umd.kt")
|
||||
public void testUmd() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/moduleSystems/umd.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/namespaces")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Namespaces extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInNamespaces() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/namespaces"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("namespaces.kt")
|
||||
public void testNamespaces() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/namespaces/namespaces.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/primitives")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Primitives extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInPrimitives() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/primitives"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("primitives.kt")
|
||||
public void testPrimitives() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/primitives/primitives.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/selectiveExport")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class SelectiveExport extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSelectiveExport() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/selectiveExport"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("selectiveExport.kt")
|
||||
public void testSelectiveExport() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/selectiveExport/selectiveExport.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("js/js.translator/testData/typescript-export/visibility")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Visibility extends AbstractLegacyJsTypeScriptExportTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInVisibility() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/typescript-export/visibility"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("visibility.kt")
|
||||
public void testVisibility() throws Exception {
|
||||
runTest("js/js.translator/testData/typescript-export/visibility/visibility.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -31,6 +31,7 @@ object ModuleWrapperTranslation {
|
||||
ModuleKind.COMMON_JS -> wrapCommonJs(function, importedModules, program)
|
||||
ModuleKind.UMD -> wrapUmd(moduleId, function, importedModules, program)
|
||||
ModuleKind.PLAIN -> wrapPlain(moduleId, function, importedModules, program)
|
||||
ModuleKind.ES -> error("ES modules are not supported in legacy wrapper")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O {
|
||||
operator fun invoke() = "OK"
|
||||
}
|
||||
|
||||
inline fun callO() = O()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = O()
|
||||
if (a != "OK") return "fail: simple: $a"
|
||||
|
||||
val b = callO()
|
||||
if (b != "OK") return "fail: inline: $a"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
class A(val x: Int) {
|
||||
constructor(a: Int, b: Int) : this(a + b)
|
||||
}
|
||||
|
||||
external class B(x: Int) {
|
||||
constructor(a: Int, b: Int)
|
||||
|
||||
val x: Int
|
||||
}
|
||||
|
||||
// TODO: may be useful after implementing local classes in inline functions
|
||||
/*
|
||||
inline fun foo(p: Int, q: Int, r: Int): Pair<Int, Int> {
|
||||
class C(val x : Int) {
|
||||
constructor(a: Int, b: Int) : this(a + b)
|
||||
}
|
||||
return Pair(C(p).x, C(q, r).x)
|
||||
}
|
||||
*/
|
||||
|
||||
inline fun callPrimaryConstructor(x: Int) = A(x).x
|
||||
|
||||
inline fun callSecondaryConstructor(x: Int, y: Int) = A(x, y).x
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
function B(x, y) {
|
||||
this.x = x;
|
||||
if (typeof y !== 'undefined') {
|
||||
this.x += y;
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = A(23).x
|
||||
if (a != 23) return "fail: primary constructor: $a"
|
||||
|
||||
val b = A(40, 2).x
|
||||
if (b != 42) return "fail: secondary constructor: $b"
|
||||
|
||||
val c = B(99).x
|
||||
if (c != 99) return "fail: native primary constructor: $c"
|
||||
|
||||
val d = B(100, 11).x
|
||||
if (d != 111) return "fail: native secondary constructor: $d"
|
||||
|
||||
/*
|
||||
val (e, f) = foo(123, 320, 1)
|
||||
if (e != 123) return "fail: local primary constructor: $e"
|
||||
if (f != 321) return "fail: local secondary constructor: $f"
|
||||
*/
|
||||
|
||||
val g = callPrimaryConstructor(55)
|
||||
if (g != 55) return "fail: primary constructor from inline function: $g"
|
||||
|
||||
val h = callSecondaryConstructor(990, 9)
|
||||
if (h != 999) return "fail: secondary constructor from inline function: $h"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
open class A {
|
||||
fun foo() = 23
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
import lib.A
|
||||
|
||||
class B : A() {
|
||||
fun bar() = foo() + 1
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = B().bar()
|
||||
if (result != 24) return "fail: $result"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// FILE: lib1.mjs
|
||||
export default function() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// MODULE: lib2
|
||||
// FILE: lib2.kt
|
||||
@JsModule("./lib1.mjs")
|
||||
external fun foo(): String
|
||||
|
||||
// MODULE: lib3(lib2)
|
||||
// FILE: lib3.kt
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(lib3)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// FILE: lib-1.mjs
|
||||
export default function foo() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// MODULE: lib2
|
||||
// FILE: lib2.kt
|
||||
@JsModule("./lib-1.mjs")
|
||||
external fun foo(): String
|
||||
|
||||
// MODULE: lib3(lib2)
|
||||
// FILE: lib3.kt
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(lib3)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// FILE: lib1.mjs
|
||||
export function foo() {
|
||||
return "OK";
|
||||
}
|
||||
|
||||
// MODULE: lib2
|
||||
// FILE: lib2.kt
|
||||
@file:JsModule("./lib1.mjs")
|
||||
|
||||
external fun foo(): String
|
||||
|
||||
// MODULE: lib3(lib2)
|
||||
// FILE: lib3.kt
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(lib3)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
@@ -0,0 +1,16 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib1
|
||||
// FILE: lib1.kt
|
||||
|
||||
fun foo() = "OK"
|
||||
|
||||
// MODULE: lib2(lib1)
|
||||
// FILE: lib2.kt
|
||||
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(lib1, lib2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: 1
|
||||
// FILE: lib1.kt
|
||||
|
||||
fun foo() = "OK"
|
||||
|
||||
// MODULE: 2(1)
|
||||
// FILE: lib2.kt
|
||||
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
@@ -0,0 +1,19 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
fun bar(f: () -> String) = f()
|
||||
|
||||
inline fun foo(): String {
|
||||
return bar { "OK" }
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box() = foo()
|
||||
@@ -0,0 +1,37 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
var log = ""
|
||||
|
||||
object O {
|
||||
init {
|
||||
log += "O.init;"
|
||||
}
|
||||
|
||||
fun result() = "OK"
|
||||
}
|
||||
|
||||
fun getResult(): String {
|
||||
log += "before;"
|
||||
val result = O.result()
|
||||
log += "after;"
|
||||
return result
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val result = getResult()
|
||||
if (result != "OK") return "fail: unexpected result: $result"
|
||||
|
||||
if (log != "before;O.init;after;") return "fail: wrong evaluation order: $log"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O {
|
||||
val result = "OK"
|
||||
|
||||
inline fun foo(): String {
|
||||
val o = object {
|
||||
fun bar() = O
|
||||
}
|
||||
return fetch(o.bar())
|
||||
}
|
||||
}
|
||||
|
||||
fun fetch(o: O) = o.result
|
||||
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box() = O.foo()
|
||||
@@ -0,0 +1,21 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
var o: Any = O
|
||||
if (o !is O) return "fail1"
|
||||
if (!(o is O)) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
class A(val x: Int)
|
||||
|
||||
fun A.foo() = 23 + x
|
||||
|
||||
inline fun A.baz() = 99 + x
|
||||
|
||||
inline fun A.callFoo() = foo()
|
||||
|
||||
inline fun A.buzz(): Int {
|
||||
val o = object {
|
||||
fun f() = 111 + x
|
||||
}
|
||||
return o.f()
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = A(1).foo()
|
||||
if (a != 24) return "fail: simple function: $a"
|
||||
|
||||
val c = A(1).baz()
|
||||
if (c != 100) return "fail: inline function: $c"
|
||||
|
||||
val d = A(1).buzz()
|
||||
if (d != 112) return "fail: inline function with object expression: $d"
|
||||
|
||||
val e = A(2).callFoo()
|
||||
if (e != 25) return "fail: inline function calling another function: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
external fun bar(): Int = definedExternally
|
||||
|
||||
inline fun baz() = 99
|
||||
|
||||
inline fun callFoo() = foo()
|
||||
|
||||
inline fun buzz(): Int {
|
||||
val o = object {
|
||||
fun f() = 111
|
||||
}
|
||||
return o.f()
|
||||
}
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
function bar() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
fun box(): String {
|
||||
val a = lib.foo()
|
||||
if (a != 23) return "fail: simple function: $a"
|
||||
|
||||
val b = lib.bar()
|
||||
if (b != 42) return "fail: native function: $b"
|
||||
|
||||
val c = lib.baz()
|
||||
if (c != 99) return "fail: inline function: $c"
|
||||
|
||||
val d = lib.buzz()
|
||||
if (d != 111) return "fail: inline function with object expression: $d"
|
||||
|
||||
val e = lib.callFoo()
|
||||
if (e != 23) return "fail: inline function calling another function: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
var foo = 23
|
||||
|
||||
var bar: Int = 42
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
@JsName("faz") var baz = 99
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: lib.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo != 23) return "fail: simple property initial value: $foo"
|
||||
foo = 24
|
||||
if (foo != 24) return "fail: simple property new value: $foo"
|
||||
|
||||
if (bar != 42) return "fail: property with accessor initial value: $bar"
|
||||
bar = 43
|
||||
if (bar != 43) return "fail: property with accessor new value: $bar"
|
||||
|
||||
if (baz != 99) return "fail: renamed property initial value: $baz"
|
||||
baz = 100
|
||||
if (baz != 100) return "fail: renamed property new value: $baz"
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
val foo = 23
|
||||
|
||||
val boo: Int
|
||||
get() = 42
|
||||
|
||||
external val bar: Int = definedExternally
|
||||
|
||||
external val far: Int
|
||||
get() = definedExternally
|
||||
|
||||
// TODO: annotations like this are not serialized properly. Uncomment after KT-14529 gets fixed
|
||||
/*
|
||||
val fuzz: Int
|
||||
@JsName("getBuzz") get() = 55
|
||||
*/
|
||||
|
||||
inline fun fetchFoo() = foo
|
||||
|
||||
@JsName("fee")
|
||||
val tee = 2525
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
var bar = 99
|
||||
var far = 111
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: lib.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo != 23) return "fail: simple property: $foo"
|
||||
if (boo != 42) return "fail: property with accessor: $boo"
|
||||
if (bar != 99) return "fail: native property: $bar"
|
||||
if (far != 111) return "fail: native property with accessor: $far"
|
||||
//if (fuzz != 55) return "fail: property with JsName on accessor: $fuzz"
|
||||
if (tee != 2525) return "fail: native property with JsName: $tee"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1289
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O {
|
||||
operator fun invoke() = "OK"
|
||||
}
|
||||
|
||||
inline fun callO() = O()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = O()
|
||||
if (a != "OK") return "fail: simple: $a"
|
||||
|
||||
val b = callO()
|
||||
if (b != "OK") return "fail: inline: $a"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1291
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
class A(val x: Int) {
|
||||
constructor(a: Int, b: Int) : this(a + b)
|
||||
}
|
||||
|
||||
external class B(x: Int) {
|
||||
constructor(a: Int, b: Int)
|
||||
|
||||
val x: Int
|
||||
}
|
||||
|
||||
// TODO: may be useful after implementing local classes in inline functions
|
||||
/*
|
||||
inline fun foo(p: Int, q: Int, r: Int): Pair<Int, Int> {
|
||||
class C(val x : Int) {
|
||||
constructor(a: Int, b: Int) : this(a + b)
|
||||
}
|
||||
return Pair(C(p).x, C(q, r).x)
|
||||
}
|
||||
*/
|
||||
|
||||
inline fun callPrimaryConstructor(x: Int) = A(x).x
|
||||
|
||||
inline fun callSecondaryConstructor(x: Int, y: Int) = A(x, y).x
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
function B(x, y) {
|
||||
this.x = x;
|
||||
if (typeof y !== 'undefined') {
|
||||
this.x += y;
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = A(23).x
|
||||
if (a != 23) return "fail: primary constructor: $a"
|
||||
|
||||
val b = A(40, 2).x
|
||||
if (b != 42) return "fail: secondary constructor: $b"
|
||||
|
||||
val c = B(99).x
|
||||
if (c != 99) return "fail: native primary constructor: $c"
|
||||
|
||||
val d = B(100, 11).x
|
||||
if (d != 111) return "fail: native secondary constructor: $d"
|
||||
|
||||
/*
|
||||
val (e, f) = foo(123, 320, 1)
|
||||
if (e != 123) return "fail: local primary constructor: $e"
|
||||
if (f != 321) return "fail: local secondary constructor: $f"
|
||||
*/
|
||||
|
||||
val g = callPrimaryConstructor(55)
|
||||
if (g != 55) return "fail: primary constructor from inline function: $g"
|
||||
|
||||
val h = callSecondaryConstructor(990, 9)
|
||||
if (h != 999) return "fail: secondary constructor from inline function: $h"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1292
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
open class A {
|
||||
fun foo() = 23
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
import lib.A
|
||||
|
||||
class B : A() {
|
||||
fun bar() = foo() + 1
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = B().bar()
|
||||
if (result != 24) return "fail: $result"
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1283
|
||||
// MODULE: lib1
|
||||
// FILE: lib1.kt
|
||||
|
||||
fun foo() = "OK"
|
||||
|
||||
// MODULE: lib2(lib1)
|
||||
// FILE: lib2.kt
|
||||
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(lib1, lib2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1283
|
||||
// MODULE: 1
|
||||
// FILE: lib1.kt
|
||||
|
||||
fun foo() = "OK"
|
||||
|
||||
// MODULE: 2(1)
|
||||
// FILE: lib2.kt
|
||||
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
@@ -0,0 +1,21 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1283
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
fun bar(f: () -> String) = f()
|
||||
|
||||
inline fun foo(): String {
|
||||
return bar { "OK" }
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box() = foo()
|
||||
@@ -0,0 +1,39 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1289
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
var log = ""
|
||||
|
||||
object O {
|
||||
init {
|
||||
log += "O.init;"
|
||||
}
|
||||
|
||||
fun result() = "OK"
|
||||
}
|
||||
|
||||
fun getResult(): String {
|
||||
log += "before;"
|
||||
val result = O.result()
|
||||
log += "after;"
|
||||
return result
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val result = getResult()
|
||||
if (result != "OK") return "fail: unexpected result: $result"
|
||||
|
||||
if (log != "before;O.init;after;") return "fail: wrong evaluation order: $log"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1382
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O {
|
||||
val result = "OK"
|
||||
|
||||
inline fun foo(): String {
|
||||
val o = object {
|
||||
fun bar() = O
|
||||
}
|
||||
return fetch(o.bar())
|
||||
}
|
||||
}
|
||||
|
||||
fun fetch(o: O) = o.result
|
||||
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box() = O.foo()
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1284
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
var o: Any = O
|
||||
if (o !is O) return "fail1"
|
||||
if (!(o is O)) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1290
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
class A(val x: Int)
|
||||
|
||||
fun A.foo() = 23 + x
|
||||
|
||||
inline fun A.baz() = 99 + x
|
||||
|
||||
inline fun A.callFoo() = foo()
|
||||
|
||||
inline fun A.buzz(): Int {
|
||||
val o = object {
|
||||
fun f() = 111 + x
|
||||
}
|
||||
return o.f()
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = A(1).foo()
|
||||
if (a != 24) return "fail: simple function: $a"
|
||||
|
||||
val c = A(1).baz()
|
||||
if (c != 100) return "fail: inline function: $c"
|
||||
|
||||
val d = A(1).buzz()
|
||||
if (d != 112) return "fail: inline function with object expression: $d"
|
||||
|
||||
val e = A(2).callFoo()
|
||||
if (e != 25) return "fail: inline function calling another function: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1287
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
external fun bar(): Int = definedExternally
|
||||
|
||||
inline fun baz() = 99
|
||||
|
||||
inline fun callFoo() = foo()
|
||||
|
||||
inline fun buzz(): Int {
|
||||
val o = object {
|
||||
fun f() = 111
|
||||
}
|
||||
return o.f()
|
||||
}
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
function bar() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
fun box(): String {
|
||||
val a = lib.foo()
|
||||
if (a != 23) return "fail: simple function: $a"
|
||||
|
||||
val b = lib.bar()
|
||||
if (b != 42) return "fail: native function: $b"
|
||||
|
||||
val c = lib.baz()
|
||||
if (c != 99) return "fail: inline function: $c"
|
||||
|
||||
val d = lib.buzz()
|
||||
if (d != 111) return "fail: inline function with object expression: $d"
|
||||
|
||||
val e = lib.callFoo()
|
||||
if (e != 23) return "fail: inline function calling another function: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1286
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
var foo = 23
|
||||
|
||||
var bar: Int = 42
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
@JsName("faz") var baz = 99
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: lib.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo != 23) return "fail: simple property initial value: $foo"
|
||||
foo = 24
|
||||
if (foo != 24) return "fail: simple property new value: $foo"
|
||||
|
||||
if (bar != 42) return "fail: property with accessor initial value: $bar"
|
||||
bar = 43
|
||||
if (bar != 43) return "fail: property with accessor new value: $bar"
|
||||
|
||||
if (baz != 99) return "fail: renamed property initial value: $baz"
|
||||
baz = 100
|
||||
if (baz != 100) return "fail: renamed property new value: $baz"
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_FILE
|
||||
// EXPECTED_REACHABLE_NODES: 1287
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
val foo = 23
|
||||
|
||||
val boo: Int
|
||||
get() = 42
|
||||
|
||||
external val bar: Int = definedExternally
|
||||
|
||||
external val far: Int
|
||||
get() = definedExternally
|
||||
|
||||
// TODO: annotations like this are not serialized properly. Uncomment after KT-14529 gets fixed
|
||||
/*
|
||||
val fuzz: Int
|
||||
@JsName("getBuzz") get() = 55
|
||||
*/
|
||||
|
||||
inline fun fetchFoo() = foo
|
||||
|
||||
@JsName("fee")
|
||||
val tee = 2525
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
var bar = 99
|
||||
var far = 111
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: lib.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo != 23) return "fail: simple property: $foo"
|
||||
if (boo != 42) return "fail: property with accessor: $boo"
|
||||
if (bar != 99) return "fail: native property: $bar"
|
||||
if (far != 111) return "fail: native property with accessor: $far"
|
||||
//if (fuzz != 55) return "fail: property with JsName on accessor: $fuzz"
|
||||
if (tee != 2525) return "fail: native property with JsName: $tee"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1289
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O {
|
||||
operator fun invoke() = "OK"
|
||||
}
|
||||
|
||||
inline fun callO() = O()
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = O()
|
||||
if (a != "OK") return "fail: simple: $a"
|
||||
|
||||
val b = callO()
|
||||
if (b != "OK") return "fail: inline: $a"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1291
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
class A(val x: Int) {
|
||||
constructor(a: Int, b: Int) : this(a + b)
|
||||
}
|
||||
|
||||
external class B(x: Int) {
|
||||
constructor(a: Int, b: Int)
|
||||
|
||||
val x: Int
|
||||
}
|
||||
|
||||
// TODO: may be useful after implementing local classes in inline functions
|
||||
/*
|
||||
inline fun foo(p: Int, q: Int, r: Int): Pair<Int, Int> {
|
||||
class C(val x : Int) {
|
||||
constructor(a: Int, b: Int) : this(a + b)
|
||||
}
|
||||
return Pair(C(p).x, C(q, r).x)
|
||||
}
|
||||
*/
|
||||
|
||||
inline fun callPrimaryConstructor(x: Int) = A(x).x
|
||||
|
||||
inline fun callSecondaryConstructor(x: Int, y: Int) = A(x, y).x
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
function B(x, y) {
|
||||
this.x = x;
|
||||
if (typeof y !== 'undefined') {
|
||||
this.x += y;
|
||||
}
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = A(23).x
|
||||
if (a != 23) return "fail: primary constructor: $a"
|
||||
|
||||
val b = A(40, 2).x
|
||||
if (b != 42) return "fail: secondary constructor: $b"
|
||||
|
||||
val c = B(99).x
|
||||
if (c != 99) return "fail: native primary constructor: $c"
|
||||
|
||||
val d = B(100, 11).x
|
||||
if (d != 111) return "fail: native secondary constructor: $d"
|
||||
|
||||
/*
|
||||
val (e, f) = foo(123, 320, 1)
|
||||
if (e != 123) return "fail: local primary constructor: $e"
|
||||
if (f != 321) return "fail: local secondary constructor: $f"
|
||||
*/
|
||||
|
||||
val g = callPrimaryConstructor(55)
|
||||
if (g != 55) return "fail: primary constructor from inline function: $g"
|
||||
|
||||
val h = callSecondaryConstructor(990, 9)
|
||||
if (h != 999) return "fail: secondary constructor from inline function: $h"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1292
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
open class A {
|
||||
fun foo() = 23
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
import lib.A
|
||||
|
||||
class B : A() {
|
||||
fun bar() = foo() + 1
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val result = B().bar()
|
||||
if (result != 24) return "fail: $result"
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1283
|
||||
// MODULE: lib1
|
||||
// FILE: lib1.kt
|
||||
|
||||
fun foo() = "OK"
|
||||
|
||||
// MODULE: lib2(lib1)
|
||||
// FILE: lib2.kt
|
||||
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(lib1, lib2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1283
|
||||
// MODULE: 1
|
||||
// FILE: lib1.kt
|
||||
|
||||
fun foo() = "OK"
|
||||
|
||||
// MODULE: 2(1)
|
||||
// FILE: lib2.kt
|
||||
|
||||
inline fun bar() = foo()
|
||||
|
||||
// MODULE: main(2)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box() = bar()
|
||||
@@ -0,0 +1,21 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1283
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
fun bar(f: () -> String) = f()
|
||||
|
||||
inline fun foo(): String {
|
||||
return bar { "OK" }
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box() = foo()
|
||||
@@ -0,0 +1,39 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1289
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
var log = ""
|
||||
|
||||
object O {
|
||||
init {
|
||||
log += "O.init;"
|
||||
}
|
||||
|
||||
fun result() = "OK"
|
||||
}
|
||||
|
||||
fun getResult(): String {
|
||||
log += "before;"
|
||||
val result = O.result()
|
||||
log += "after;"
|
||||
return result
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val result = getResult()
|
||||
if (result != "OK") return "fail: unexpected result: $result"
|
||||
|
||||
if (log != "before;O.init;after;") return "fail: wrong evaluation order: $log"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1382
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O {
|
||||
val result = "OK"
|
||||
|
||||
inline fun foo(): String {
|
||||
val o = object {
|
||||
fun bar() = O
|
||||
}
|
||||
return fetch(o.bar())
|
||||
}
|
||||
}
|
||||
|
||||
fun fetch(o: O) = o.result
|
||||
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box() = O.foo()
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1284
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
object O
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
var o: Any = O
|
||||
if (o !is O) return "fail1"
|
||||
if (!(o is O)) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1290
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
class A(val x: Int)
|
||||
|
||||
fun A.foo() = 23 + x
|
||||
|
||||
inline fun A.baz() = 99 + x
|
||||
|
||||
inline fun A.callFoo() = foo()
|
||||
|
||||
inline fun A.buzz(): Int {
|
||||
val o = object {
|
||||
fun f() = 111 + x
|
||||
}
|
||||
return o.f()
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
val a = A(1).foo()
|
||||
if (a != 24) return "fail: simple function: $a"
|
||||
|
||||
val c = A(1).baz()
|
||||
if (c != 100) return "fail: inline function: $c"
|
||||
|
||||
val d = A(1).buzz()
|
||||
if (d != 112) return "fail: inline function with object expression: $d"
|
||||
|
||||
val e = A(2).callFoo()
|
||||
if (e != 25) return "fail: inline function calling another function: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1287
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
package lib
|
||||
|
||||
fun foo() = 23
|
||||
|
||||
external fun bar(): Int = definedExternally
|
||||
|
||||
inline fun baz() = 99
|
||||
|
||||
inline fun callFoo() = foo()
|
||||
|
||||
inline fun buzz(): Int {
|
||||
val o = object {
|
||||
fun f() = 111
|
||||
}
|
||||
return o.f()
|
||||
}
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
function bar() {
|
||||
return 42;
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
package main
|
||||
|
||||
fun box(): String {
|
||||
val a = lib.foo()
|
||||
if (a != 23) return "fail: simple function: $a"
|
||||
|
||||
val b = lib.bar()
|
||||
if (b != 42) return "fail: native function: $b"
|
||||
|
||||
val c = lib.baz()
|
||||
if (c != 99) return "fail: inline function: $c"
|
||||
|
||||
val d = lib.buzz()
|
||||
if (d != 111) return "fail: inline function with object expression: $d"
|
||||
|
||||
val e = lib.callFoo()
|
||||
if (e != 23) return "fail: inline function calling another function: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1286
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
var foo = 23
|
||||
|
||||
var bar: Int = 42
|
||||
get() = field
|
||||
set(value) {
|
||||
field = value
|
||||
}
|
||||
|
||||
@JsName("faz") var baz = 99
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: lib.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo != 23) return "fail: simple property initial value: $foo"
|
||||
foo = 24
|
||||
if (foo != 24) return "fail: simple property new value: $foo"
|
||||
|
||||
if (bar != 42) return "fail: property with accessor initial value: $bar"
|
||||
bar = 43
|
||||
if (bar != 43) return "fail: property with accessor new value: $bar"
|
||||
|
||||
if (baz != 99) return "fail: renamed property initial value: $baz"
|
||||
baz = 100
|
||||
if (baz != 100) return "fail: renamed property new value: $baz"
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// SPLIT_PER_MODULE
|
||||
// EXPECTED_REACHABLE_NODES: 1287
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
package lib
|
||||
|
||||
val foo = 23
|
||||
|
||||
val boo: Int
|
||||
get() = 42
|
||||
|
||||
external val bar: Int = definedExternally
|
||||
|
||||
external val far: Int
|
||||
get() = definedExternally
|
||||
|
||||
// TODO: annotations like this are not serialized properly. Uncomment after KT-14529 gets fixed
|
||||
/*
|
||||
val fuzz: Int
|
||||
@JsName("getBuzz") get() = 55
|
||||
*/
|
||||
|
||||
inline fun fetchFoo() = foo
|
||||
|
||||
@JsName("fee")
|
||||
val tee = 2525
|
||||
|
||||
// FILE: lib.js
|
||||
|
||||
var bar = 99
|
||||
var far = 111
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: lib.kt
|
||||
package main
|
||||
|
||||
import lib.*
|
||||
|
||||
fun box(): String {
|
||||
if (foo != 23) return "fail: simple property: $foo"
|
||||
if (boo != 42) return "fail: property with accessor: $boo"
|
||||
if (bar != 99) return "fail: native property: $bar"
|
||||
if (far != 111) return "fail: native property with accessor: $far"
|
||||
//if (fuzz != 55) return "fail: property with JsName on accessor: $fuzz"
|
||||
if (tee != 2525) return "fail: native property with JsName: $tee"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// EXPECTED_REACHABLE_NODES: 1252
|
||||
// INFER_MAIN_MODULE
|
||||
// ES_MODULES
|
||||
|
||||
// MODULE: export-all-file
|
||||
// FILE: lib.kt
|
||||
@file:JsExport
|
||||
|
||||
abstract class A {
|
||||
abstract fun foo(k: String): String
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun foo(k: String): String {
|
||||
return "O" + k
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: entry.mjs
|
||||
// ENTRY_ES_MODULE
|
||||
import { B } from "./export-all-file/index.js";
|
||||
console.assert(new B().foo("K") == "OK");
|
||||
@@ -0,0 +1,16 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// SKIP_MINIFICATION
|
||||
// INFER_MAIN_MODULE
|
||||
// SKIP_NODE_JS
|
||||
// ES_MODULES
|
||||
|
||||
// MODULE: non-identifier-module-name
|
||||
// FILE: lib.kt
|
||||
@JsName("foo")
|
||||
@JsExport
|
||||
public fun foo(k: String): String = "O$k"
|
||||
|
||||
// FILE: entry.mjs
|
||||
// ENTRY_ES_MODULE
|
||||
import { foo } from "./non-identifier-module-name/index.js";
|
||||
console.assert(foo("K") == "OK");
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// EXPECTED_REACHABLE_NODES: 1252
|
||||
// INFER_MAIN_MODULE
|
||||
|
||||
// ES_MODULES
|
||||
// MODULE: overriden-chain-non-export-intermediate
|
||||
// FILE: lib.kt
|
||||
@JsExport
|
||||
abstract class A {
|
||||
abstract fun foo(): String
|
||||
|
||||
abstract fun bar(): String
|
||||
}
|
||||
|
||||
abstract class B : A() {
|
||||
abstract fun baz(): String
|
||||
|
||||
override fun foo(): String = "foo"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class C : B() {
|
||||
override fun bar(): String = "bar"
|
||||
override fun baz(): String = "baz"
|
||||
|
||||
fun bay(): String = "bay"
|
||||
}
|
||||
|
||||
// FILE: entry.mjs
|
||||
// ENTRY_ES_MODULE
|
||||
import { C } from "./overriden-chain-non-export-intermediate/index.js";
|
||||
|
||||
function test(c) {
|
||||
if (c.foo() === "foo" && c.bar() === "bar" && c.bay() == "bay") return "OK"
|
||||
|
||||
return "fail"
|
||||
}
|
||||
|
||||
console.assert(test(new C()) == "OK");
|
||||
Vendored
+41
@@ -0,0 +1,41 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1252
|
||||
// INFER_MAIN_MODULE
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
|
||||
// MODULE: overriden-external-method-with-same-name-method
|
||||
// FILE: lib.kt
|
||||
external abstract class Foo {
|
||||
abstract fun o(): String
|
||||
}
|
||||
|
||||
abstract class Bar : Foo() {
|
||||
abstract fun String.o(): String
|
||||
|
||||
override fun o(): String {
|
||||
return "O".o()
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class Baz : Bar() {
|
||||
override fun String.o(): String {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: foo.js
|
||||
function Foo() {}
|
||||
Foo.prototype.k = function() {
|
||||
return "K"
|
||||
}
|
||||
|
||||
// FILE: entry.mjs
|
||||
// ENTRY_ES_MODULE
|
||||
import { Baz } from "./overriden-external-method-with-same-name-method/index.js";
|
||||
|
||||
function test(foo) {
|
||||
return foo.o() + foo.k()
|
||||
}
|
||||
|
||||
console.assert(test(new Baz()) == "OK");
|
||||
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1252
|
||||
// IGNORE_BACKEND: JS
|
||||
// INFER_MAIN_MODULE
|
||||
// ES_MODULES
|
||||
|
||||
// MODULE: overriden-external-method-with-same-stable-name-method
|
||||
// FILE: lib.kt
|
||||
external abstract class Foo {
|
||||
abstract fun o(): String
|
||||
}
|
||||
|
||||
abstract class Bar : Foo() {
|
||||
@JsName("oStable")
|
||||
abstract fun String.o(): String
|
||||
|
||||
override fun o(): String {
|
||||
return "O".o()
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class Baz : Bar() {
|
||||
override fun String.o(): String {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: foo.js
|
||||
function Foo() {}
|
||||
Foo.prototype.k = function() {
|
||||
return "K"
|
||||
}
|
||||
|
||||
// FILE: entry.mjs
|
||||
// ENTRY_ES_MODULE
|
||||
import { Baz } from "./overriden-external-method-with-same-stable-name-method/index.js";
|
||||
|
||||
function test(foo) {
|
||||
const oStable = foo.oStable("OK")
|
||||
if (oStable !== "OK") return "false: " + oStable
|
||||
return foo.o() + foo.k()
|
||||
}
|
||||
|
||||
console.assert(test(new Baz()) == "OK");
|
||||
@@ -0,0 +1,17 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// EXPECTED_REACHABLE_NODES: 1270
|
||||
// SKIP_MINIFICATION
|
||||
// INFER_MAIN_MODULE
|
||||
// ES_MODULES
|
||||
|
||||
// MODULE: if
|
||||
// FILE: lib.kt
|
||||
@JsName("foo")
|
||||
@JsExport
|
||||
public fun foo(k: String): String = "O$k"
|
||||
|
||||
// FILE: entry.mjs
|
||||
// ENTRY_ES_MODULE
|
||||
import { foo } from "./if/index.js";
|
||||
|
||||
console.assert(foo("K") == "OK");
|
||||
@@ -0,0 +1,41 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: a.kt
|
||||
@file:JsModule("./foo.mjs")
|
||||
|
||||
external fun fooF(): String
|
||||
|
||||
// FILE: b.kt
|
||||
@file:JsModule("./bar.mjs")
|
||||
|
||||
external fun barF(): String
|
||||
|
||||
// FILE: c.kt
|
||||
// RECOMPILE
|
||||
fun dummyF() = "dummy"
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
val foo = fooF()
|
||||
if (foo != "foo") return "fail1: $foo"
|
||||
|
||||
val bar = barF()
|
||||
if (bar != "bar") return "fail2: $bar"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: foo.mjs
|
||||
export function fooF() {
|
||||
return "foo";
|
||||
}
|
||||
|
||||
// FILE: bar.mjs
|
||||
export function barF() {
|
||||
return "bar";
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
|
||||
// FILE: main.kt
|
||||
interface I {
|
||||
fun ok(): String
|
||||
}
|
||||
|
||||
inline fun ok(): I {
|
||||
return object : I {
|
||||
override fun ok() = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@JsName("convolutedOk")
|
||||
@JsExport
|
||||
inline fun convolutedOk(): I {
|
||||
val fail = object : I {
|
||||
override fun ok() = "fail"
|
||||
}.ok()
|
||||
|
||||
return ok()
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun testOk(ok: Any): String {
|
||||
if (ok !is I) return "fail"
|
||||
return ok.ok()
|
||||
}
|
||||
|
||||
// FILE: entry.mjs
|
||||
// ENTRY_ES_MODULE
|
||||
import { convolutedOk, testOk } from "./JS_TESTS/index.js";
|
||||
|
||||
console.assert(testOk(convolutedOk()) == "OK");
|
||||
@@ -0,0 +1,55 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
|
||||
// SKIP_DCE_DRIVEN
|
||||
// SKIP_MINIFICATION
|
||||
// ES_MODULES
|
||||
|
||||
// FILE: api.kt
|
||||
|
||||
@JsExport
|
||||
data class Point(val x: Int, val y: Int) {
|
||||
override fun toString(): String = "[${x}::${y}]"
|
||||
}
|
||||
|
||||
// we need his class to make sure that there's more than one ping method in existence - due to peculiarities of current namer otherwise test can pass but JsExport won't be actually respected
|
||||
data class AltPoint(val x: Int, val y: Int)
|
||||
|
||||
// FILE: main.kt
|
||||
external interface JsResult {
|
||||
val copy00: String
|
||||
val copy01: String
|
||||
val copy10: String
|
||||
val copy11: String
|
||||
val component1: Int
|
||||
val component2: Int
|
||||
}
|
||||
|
||||
@JsModule("./dataClass.mjs")
|
||||
external fun jsBox(): JsResult
|
||||
|
||||
fun box(): String {
|
||||
val res = jsBox()
|
||||
if (res.copy00 != "[3::7]") {
|
||||
return "Fail1: ${res.copy00}"
|
||||
}
|
||||
if (res.copy01 != "[3::11]") {
|
||||
return "Fail2: ${res.copy01}"
|
||||
}
|
||||
if (res.copy10 != "[15::7]") {
|
||||
return "Fail3: ${res.copy10}"
|
||||
}
|
||||
if (res.copy11 != "[13::11]") {
|
||||
return "Fail4: ${res.copy11}"
|
||||
}
|
||||
if (res.component1 != 3) {
|
||||
return "Fail5: ${res.component1}"
|
||||
}
|
||||
if (res.component2 != 7) {
|
||||
return "Fail6: ${res.component2}"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Point } from "./JS_TESTS/index.js";
|
||||
|
||||
export default function() {
|
||||
var p = new Point(3, 7);
|
||||
|
||||
return {
|
||||
"copy00": p.copy().toString(),
|
||||
"copy01": p.copy(undefined, 11).toString(),
|
||||
"copy10": p.copy(15).toString(),
|
||||
"copy11": p.copy(13, 11).toString(),
|
||||
"component1": p.component1(),
|
||||
"component2": p.component2()
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,118 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// SKIP_DCE_DRIVEN
|
||||
// SKIP_MINIFICATION
|
||||
// ES_MODULES
|
||||
|
||||
@JsExport
|
||||
fun ping(a: String = "A", b: Int = 1): String {
|
||||
return "$a::$b"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
open class Ping(private val defaultSeed: Int = 3) {
|
||||
private fun calculate(n: Int) = n * n
|
||||
fun ping(s: Int = defaultSeed, c: (Int) -> Int = ::calculate): Int {
|
||||
return c(s)
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class Pong: Ping()
|
||||
|
||||
@JsExport
|
||||
@JsName("pong")
|
||||
fun bing(a: String = "A", b: Int = 1): String {
|
||||
return "$b::$a"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class Foo {
|
||||
@JsName("foo")
|
||||
fun value(value: Long = 5L) = if (value == 5L) "C" else "fail"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun transform(i: Int = 10, t: (Int) -> Int = {it * it}): Int {
|
||||
return t(i)
|
||||
}
|
||||
|
||||
external interface JsResult {
|
||||
val ping00: String
|
||||
val ping01: String
|
||||
val ping10: String
|
||||
val ping11: String
|
||||
|
||||
val pong00: String
|
||||
val pong01: String
|
||||
val pong10: String
|
||||
val pong11: String
|
||||
|
||||
val transform00: Int
|
||||
val transform11: Int
|
||||
|
||||
val Ping_ping00a: Int
|
||||
val Ping_ping00b: Int
|
||||
val Ping_ping11: Int
|
||||
|
||||
val Pong_ping00: Int
|
||||
|
||||
val Foo: String
|
||||
}
|
||||
|
||||
@JsModule("./exportedDefaultStub.mjs")
|
||||
external fun jsBox(): JsResult
|
||||
|
||||
fun box(): String {
|
||||
val res = jsBox()
|
||||
if (res.ping00 != "A::1") {
|
||||
return "fail0: ${res.ping00}"
|
||||
}
|
||||
if (res.ping01 != "A::10") {
|
||||
return "fail1: ${res.ping01}"
|
||||
}
|
||||
if (res.ping10 != "X::1") {
|
||||
return "fail2: ${res.ping10}"
|
||||
}
|
||||
if (res.ping11 != "Z::5") {
|
||||
return "fail3: ${res.ping11}"
|
||||
}
|
||||
|
||||
if (res.pong00 != "1::A") {
|
||||
return "fail4: ${res.pong00}"
|
||||
}
|
||||
if (res.pong01 != "10::A") {
|
||||
return "fail5: ${res.pong01}"
|
||||
}
|
||||
if (res.pong10 != "1::X") {
|
||||
return "fail6: ${res.pong10}"
|
||||
}
|
||||
if (res.pong11 != "5::Z") {
|
||||
return "fail7: ${res.pong11}"
|
||||
}
|
||||
|
||||
if (res.transform00 != 100) {
|
||||
return "fail8: ${res.transform00}"
|
||||
}
|
||||
if (res.transform11 != -125) {
|
||||
return "fail9: ${res.transform11}"
|
||||
}
|
||||
|
||||
if (res.Ping_ping00a != 9) {
|
||||
return "fail10: ${res.Ping_ping00a}"
|
||||
}
|
||||
if (res.Ping_ping00b != 100) {
|
||||
return "fail11: ${res.Ping_ping00b}"
|
||||
}
|
||||
if (res.Ping_ping11 != -64) {
|
||||
return "fail12: ${res.Ping_ping11}"
|
||||
}
|
||||
if (res.Pong_ping00 != 9) {
|
||||
return "fail13: ${res.Pong_ping00}"
|
||||
}
|
||||
|
||||
if (res.Foo != "C") {
|
||||
return "fail14: ${res.Foo}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import * as api from "./JS_TESTS/index.js";
|
||||
|
||||
export default function() {
|
||||
var ping = api.ping;
|
||||
var pong = api.pong;
|
||||
var transform = api.transform;
|
||||
var Ping = api.Ping;
|
||||
var Pong = api.Pong;
|
||||
var Foo = api.Foo;
|
||||
|
||||
return {
|
||||
"ping00": ping(),
|
||||
"ping01": ping(undefined, 10),
|
||||
"ping10": ping("X"),
|
||||
"ping11": ping("Z", 5),
|
||||
|
||||
"pong00": pong(),
|
||||
"pong01": pong(undefined, 10),
|
||||
"pong10": pong("X"),
|
||||
"pong11": pong("Z", 5),
|
||||
|
||||
"transform00": transform(),
|
||||
"transform11": transform(-5, function (it) {
|
||||
return it * it * it
|
||||
}),
|
||||
|
||||
"Ping_ping00a": new Ping().ping(),
|
||||
"Ping_ping00b": new Ping(10).ping(),
|
||||
"Ping_ping11": new Ping().ping(-4, function (it) {
|
||||
return it * it * it
|
||||
}),
|
||||
|
||||
"Pong_ping00": new Pong().ping(),
|
||||
"Foo": new Foo().foo()
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// SKIP_MINIFICATION
|
||||
// ES_MODULES
|
||||
// FILE: api.kt
|
||||
|
||||
@JsExport
|
||||
class A() {
|
||||
fun ping() = "ping"
|
||||
}
|
||||
|
||||
@JsExport
|
||||
class B() {
|
||||
@JsName("pong")
|
||||
fun ping() = "pong"
|
||||
}
|
||||
|
||||
// we need his class to make sure that there's more than one ping method in existence - due to peculiarities of current namer otherwise test can pass but JsExport won't be actually respected
|
||||
class C() {
|
||||
fun ping() = "pong"
|
||||
}
|
||||
|
||||
|
||||
// FILE: main.kt
|
||||
external interface JsResult {
|
||||
val res: String
|
||||
}
|
||||
|
||||
@JsModule("./jsExportInClass.mjs")
|
||||
external fun jsBox(): JsResult
|
||||
|
||||
fun box(): String {
|
||||
val res = jsBox().res
|
||||
if (res != "pingpong") {
|
||||
return "Fail: ${res}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { A, B } from "./JS_TESTS/index.js";
|
||||
|
||||
export default function() {
|
||||
return {
|
||||
"res": (new A().ping()) + (new B().pong())
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// SKIP_MINIFICATION
|
||||
// ES_MODULES
|
||||
|
||||
// FILE: api.kt
|
||||
@JsExport
|
||||
class Something<T: Something<T>> {
|
||||
fun ping(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@JsExport
|
||||
fun ping(s: Something<*>): String {
|
||||
return s.ping()
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
external interface JsResult {
|
||||
val pingCall: () -> String
|
||||
}
|
||||
|
||||
@JsModule("./recursiveExport.mjs")
|
||||
external fun jsBox(): JsResult
|
||||
|
||||
fun box(): String {
|
||||
return jsBox().pingCall()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { ping, Something } from "./JS_TESTS/index.js"
|
||||
|
||||
export default function() {
|
||||
return {
|
||||
"pingCall": function() {
|
||||
return ping(new Something())
|
||||
},
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1284
|
||||
// ES_MODULES
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
|
||||
package foo
|
||||
|
||||
@JsModule("./externalClass.mjs")
|
||||
external class A(x: Int = definedExternally) {
|
||||
val x: Int
|
||||
|
||||
fun foo(y: Int): Int = definedExternally
|
||||
|
||||
fun bar(vararg arg: String): String = definedExternally
|
||||
}
|
||||
|
||||
class C {
|
||||
val e = arrayOf("e")
|
||||
val f = arrayOf("f")
|
||||
val a = A(1)
|
||||
|
||||
fun qux() = a.bar(*e, *f)
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val a = A(23)
|
||||
assertEquals(23, a.x)
|
||||
assertEquals(65, a.foo(42))
|
||||
|
||||
assertEquals(C().qux(), "(ef)")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export default function A(x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
A.prototype.foo = function (y) {
|
||||
return this.x + y;
|
||||
};
|
||||
|
||||
A.prototype.bar = function() {
|
||||
return "(" + Array.prototype.join.call(arguments, "") + ")";
|
||||
};
|
||||
@@ -0,0 +1,62 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// FILE: a.kt
|
||||
@file:JsModule("./a.mjs")
|
||||
package a
|
||||
|
||||
external class A {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
external fun bar(): Int
|
||||
|
||||
external val prop: Int
|
||||
|
||||
// FILE: b.kt
|
||||
@file:JsModule("./b.mjs")
|
||||
package b
|
||||
|
||||
external class A {
|
||||
fun foo(): String
|
||||
}
|
||||
|
||||
external fun bar(): Int
|
||||
|
||||
external var prop: Int
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
import a.A as O
|
||||
import b.A as K
|
||||
|
||||
fun box(): String {
|
||||
if (a.bar() != 1) return "fail 1"
|
||||
if (a.prop != 10) return "fail 2"
|
||||
if (b.bar() != 2) return "fail 3"
|
||||
if (b.prop != 20) return "fail 4"
|
||||
|
||||
return O().foo() + K().foo()
|
||||
}
|
||||
|
||||
// FILE: a.mjs
|
||||
export function A() {}
|
||||
|
||||
A.prototype.foo = function () {
|
||||
return "O";
|
||||
};
|
||||
|
||||
export function bar() { return 1; }
|
||||
|
||||
export let prop = 10
|
||||
|
||||
|
||||
// FILE: b.mjs
|
||||
export function A() {}
|
||||
|
||||
A.prototype.foo = function () {
|
||||
return "K";
|
||||
};
|
||||
|
||||
export function bar() { return 2; }
|
||||
|
||||
export let prop = 20;
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1284
|
||||
// ES_MODULES
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
|
||||
package foo
|
||||
|
||||
@JsModule("./externalClassWithDefaults.mjs")
|
||||
external open class A(ss: String = definedExternally) {
|
||||
val s: String
|
||||
fun foo(y: String = definedExternally): String = definedExternally
|
||||
fun bar(y: String = definedExternally): String = definedExternally
|
||||
}
|
||||
|
||||
class C: A {
|
||||
constructor(ss: String) : super(ss) {}
|
||||
constructor() : super() {}
|
||||
|
||||
fun qux(s: String = "O") = s
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
val c = C()
|
||||
|
||||
val r1 = a.foo("O") + c.foo()
|
||||
if (r1 != "OK") return "Fail1: $r1"
|
||||
|
||||
val r2 = a.bar() + c.bar("K")
|
||||
if (r2 != "OK") return "Fail2: $r2"
|
||||
|
||||
val r3 = c.qux() + c.qux("K")
|
||||
if (r3 != "OK") return "Fail3: $r3"
|
||||
|
||||
if (a.s != "A") return "Fail4: ${a.s}"
|
||||
if (c.s != "A") return "Fail5: ${c.s}"
|
||||
|
||||
val a2 = A("A2")
|
||||
val c2 = C("C2")
|
||||
|
||||
val r6 = a2.s + c2.s
|
||||
if (r6 != "A2C2") return "Fail6: $r6"
|
||||
|
||||
return "OK"
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
export default function A(ss) {
|
||||
this.s = ss || "A"
|
||||
}
|
||||
A.prototype.foo = function (y) {
|
||||
return y || "K";
|
||||
};
|
||||
A.prototype.bar = function (y) {
|
||||
return y || "O";
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1334
|
||||
// ES_MODULES
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
|
||||
package foo
|
||||
|
||||
@JsModule("./externalConstructor.mjs")
|
||||
open external class A(data: String) {
|
||||
constructor(data: Int)
|
||||
constructor(data: Boolean)
|
||||
|
||||
val data: Any
|
||||
}
|
||||
|
||||
class B(data: String) : A(data)
|
||||
|
||||
class C(data: Int) : A(data)
|
||||
|
||||
class D(data: Boolean) : A(data)
|
||||
|
||||
fun box(): String {
|
||||
assertEquals("13", B("13").data)
|
||||
assertEquals(42, C(42).data)
|
||||
assertEquals(true, D(true).data)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function (data) {
|
||||
this.data = data
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
package foo
|
||||
|
||||
@JsModule("./externalFunction.mjs")
|
||||
external fun foo(y: Int): Int = definedExternally
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(65, foo(42))
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export default function(y) {
|
||||
return 23 + y;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
package foo
|
||||
|
||||
@JsModule("./externalFunctionNameClash.mjs")
|
||||
external fun foo(y: Int): Int = definedExternally
|
||||
|
||||
fun foo(y: String): String = y + "K"
|
||||
|
||||
fun box(): String {
|
||||
val foo10 = foo(10)
|
||||
if (foo10 != 33) return "Fail: $foo10"
|
||||
return "OK"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
export default function(y) {
|
||||
return 23 + y;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
package foo
|
||||
|
||||
@JsModule("./externalObject.mjs")
|
||||
external object A {
|
||||
val x: Int = definedExternally
|
||||
|
||||
fun foo(y: Int): Int = definedExternally
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(23, A.x)
|
||||
assertEquals(65, A.foo(42))
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
export default {
|
||||
x: 23,
|
||||
foo: function(y) {
|
||||
return this.x + y;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// FILE: a.kt
|
||||
@file:JsModule("./externalPackage.mjs")
|
||||
package foo
|
||||
|
||||
external class A(x: Int) {
|
||||
val x: Int
|
||||
|
||||
fun foo(y: Int): Int = definedExternally
|
||||
|
||||
class Nested {
|
||||
val y: Int
|
||||
}
|
||||
}
|
||||
|
||||
external object B {
|
||||
val x: Int = definedExternally
|
||||
|
||||
fun foo(y: Int): Int = definedExternally
|
||||
}
|
||||
|
||||
external fun foo(y: Int): Int = definedExternally
|
||||
|
||||
external val bar: Int = definedExternally
|
||||
|
||||
// FILE: b.kt
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
val a = A(23)
|
||||
assertEquals(23, a.x)
|
||||
assertEquals(65, a.foo(42))
|
||||
|
||||
val nested = A.Nested()
|
||||
assertEquals(55, nested.y)
|
||||
|
||||
assertEquals(123, B.x)
|
||||
assertEquals(265, B.foo(142))
|
||||
|
||||
assertEquals(365, foo(42))
|
||||
assertEquals(423, bar)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
export function A(x) {
|
||||
this.x = x;
|
||||
}
|
||||
A.prototype.foo = function (y) {
|
||||
return this.x + y;
|
||||
};
|
||||
|
||||
function Nested() {
|
||||
this.y = 55;
|
||||
}
|
||||
A.Nested = Nested;
|
||||
|
||||
export var B = {
|
||||
x: 123,
|
||||
foo: function(y) {
|
||||
return this.x + y;
|
||||
}
|
||||
};
|
||||
|
||||
export function foo(y) {
|
||||
return 323 + y;
|
||||
}
|
||||
|
||||
export var bar = 423;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
C = {
|
||||
f: function() {
|
||||
return 12345;
|
||||
}
|
||||
};
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// FILE: lib.kt
|
||||
@file:JsModule("./externalPackageInDifferentFile.mjs")
|
||||
package foo
|
||||
|
||||
external class A(x: Int = definedExternally) {
|
||||
val x: Int
|
||||
|
||||
fun foo(y: Int): Int = definedExternally
|
||||
}
|
||||
|
||||
external object B {
|
||||
val x: Int = definedExternally
|
||||
|
||||
fun foo(y: Int): Int = definedExternally
|
||||
}
|
||||
|
||||
external fun foo(y: Int): Int = definedExternally
|
||||
|
||||
external val bar: Int = definedExternally
|
||||
|
||||
// FILE: lib2.kt
|
||||
package foo
|
||||
|
||||
external object C {
|
||||
fun f(): Int = definedExternally
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
package foo
|
||||
|
||||
fun box(): String {
|
||||
val a = A(23)
|
||||
assertEquals(23, a.x)
|
||||
assertEquals(65, a.foo(42))
|
||||
|
||||
assertEquals(123, B.x)
|
||||
assertEquals(265, B.foo(142))
|
||||
|
||||
assertEquals(365, foo(42))
|
||||
assertEquals(423, bar)
|
||||
|
||||
assertEquals(12345, C.f())
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
function A(x) {
|
||||
this.x = x;
|
||||
}
|
||||
A.prototype.foo = function (y) {
|
||||
return this.x + y;
|
||||
};
|
||||
|
||||
var B = {
|
||||
x: 123,
|
||||
foo: function(y) {
|
||||
return this.x + y;
|
||||
}
|
||||
};
|
||||
|
||||
function foo(y) {
|
||||
return 323 + y;
|
||||
}
|
||||
|
||||
var bar = 423;
|
||||
|
||||
export { A, B, foo, bar };
|
||||
@@ -0,0 +1,11 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
package foo
|
||||
|
||||
@JsModule("./externalProperty.mjs")
|
||||
external val foo: Int = definedExternally
|
||||
|
||||
fun box(): String {
|
||||
assertEquals(23, foo)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export default 23;
|
||||
@@ -0,0 +1,33 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: JS
|
||||
// ES_MODULES
|
||||
// FILE: bar.kt
|
||||
@file:JsModule("./interfaces.mjs")
|
||||
@file:JsQualifier("foo")
|
||||
package foo
|
||||
|
||||
external interface Bar {
|
||||
fun ping(): String
|
||||
}
|
||||
|
||||
// FILE: baz.kt
|
||||
@file:JsModule("./interfaces.mjs")
|
||||
package boo
|
||||
|
||||
external interface Baz {
|
||||
fun pong(): Int
|
||||
}
|
||||
|
||||
// FILE: root.kt
|
||||
@file:JsModule("./interfaces.mjs")
|
||||
import foo.Bar
|
||||
import boo.Baz
|
||||
|
||||
external val bar: Bar
|
||||
external val baz: Baz
|
||||
|
||||
// FILE: test.kt
|
||||
fun box(): String {
|
||||
if (bar.ping() != "ping" || baz.pong() != 194) return "Fail"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
export var bar = {
|
||||
ping() {
|
||||
return "ping"
|
||||
}
|
||||
};
|
||||
|
||||
export var baz = {
|
||||
pong() {
|
||||
return 194
|
||||
}
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user