KT-3008 Fix JS backend tests
This commit is contained in:
Vendored
+2
-2
@@ -7,6 +7,7 @@ where possible options include:
|
|||||||
-meta-info Generate metadata
|
-meta-info Generate metadata
|
||||||
-kjsm Generate kjsm-files (for creating libraries)
|
-kjsm Generate kjsm-files (for creating libraries)
|
||||||
-target <version> Generate JS files for specific ECMA version (only ECMA 5 is supported)
|
-target <version> Generate JS files for specific ECMA version (only ECMA 5 is supported)
|
||||||
|
-module-kind Kind of a module generated by compiler. Supported values are: plain (by default), amd, commonjs, umd.
|
||||||
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
|
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
|
||||||
-output-prefix <path> Path to file which will be added to the beginning of output file
|
-output-prefix <path> Path to file which will be added to the beginning of output file
|
||||||
-output-postfix <path> Path to file which will be added to the end of output file
|
-output-postfix <path> Path to file which will be added to the end of output file
|
||||||
@@ -17,5 +18,4 @@ where possible options include:
|
|||||||
-help (-h) Print a synopsis of standard options
|
-help (-h) Print a synopsis of standard options
|
||||||
-X Print a synopsis of advanced options
|
-X Print a synopsis of advanced options
|
||||||
-P plugin:<pluginId>:<optionName>=<value>
|
-P plugin:<pluginId>:<optionName>=<value>
|
||||||
Pass an option to a plugin
|
Pass an option to a plugin
|
||||||
OK
|
|
||||||
@@ -83,7 +83,7 @@ public abstract class JsConfig {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ModuleKind getModuleKind() {
|
public ModuleKind getModuleKind() {
|
||||||
return configuration.getNotNull(JSConfigurationKeys.MODULE_KIND);
|
return configuration.get(JSConfigurationKeys.MODULE_KIND, ModuleKind.PLAIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract boolean checkLibFilesAndReportErrors(@NotNull Function1<String, Unit> report);
|
public abstract boolean checkLibFilesAndReportErrors(@NotNull Function1<String, Unit> report);
|
||||||
|
|||||||
@@ -193,6 +193,7 @@ public final class RhinoUtils {
|
|||||||
private static ScriptableObject initScope(@NotNull EcmaVersion version, @NotNull Context context, @NotNull List<String> jsLibraries) {
|
private static ScriptableObject initScope(@NotNull EcmaVersion version, @NotNull Context context, @NotNull List<String> jsLibraries) {
|
||||||
ScriptableObject scope = context.initStandardObjects();
|
ScriptableObject scope = context.initStandardObjects();
|
||||||
try {
|
try {
|
||||||
|
context.evaluateString(scope, "var Kotlin = {};", ".", 1, null);
|
||||||
runFileWithRhino(getKotlinLibFile(version), context, scope);
|
runFileWithRhino(getKotlinLibFile(version), context, scope);
|
||||||
runFileWithRhino(TEST_DATA_DIR_PATH + "kotlin_lib.js", context, scope);
|
runFileWithRhino(TEST_DATA_DIR_PATH + "kotlin_lib.js", context, scope);
|
||||||
runFileWithRhino(TEST_DATA_DIR_PATH + "maps.js", context, scope);
|
runFileWithRhino(TEST_DATA_DIR_PATH + "maps.js", context, scope);
|
||||||
|
|||||||
@@ -41,7 +41,10 @@ import org.jetbrains.kotlin.resolve.BindingTrace;
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject;
|
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.*;
|
import static org.jetbrains.kotlin.js.translate.utils.AnnotationsUtils.*;
|
||||||
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.pureFqn;
|
import static org.jetbrains.kotlin.js.translate.utils.JsAstUtils.pureFqn;
|
||||||
@@ -542,6 +545,13 @@ public final class StaticContext {
|
|||||||
|
|
||||||
JsNameRef result = getQualifierForParentPackage(((PackageFragmentDescriptor) containingDescriptor).getFqName());
|
JsNameRef result = getQualifierForParentPackage(((PackageFragmentDescriptor) containingDescriptor).getFqName());
|
||||||
|
|
||||||
|
// TODO: remove this dirty hack
|
||||||
|
if (descriptor instanceof ClassDescriptor && DescriptorUtils.isTopLevelDeclaration(descriptor)) {
|
||||||
|
if (DescriptorUtils.getFqNameFromTopLevelClass(descriptor).toString().equals("Annotation")) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String moduleName = getExternalModuleName(descriptor);
|
String moduleName = getExternalModuleName(descriptor);
|
||||||
if (moduleName == null) {
|
if (moduleName == null) {
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@@ -217,7 +217,6 @@ public final class Translation {
|
|||||||
TranslationContext context = TranslationContext.rootContext(staticContext, rootFunction);
|
TranslationContext context = TranslationContext.rootContext(staticContext, rootFunction);
|
||||||
statements.addAll(PackageDeclarationTranslator.translateFiles(files, context));
|
statements.addAll(PackageDeclarationTranslator.translateFiles(files, context));
|
||||||
defineModule(context, statements, config.getModuleId());
|
defineModule(context, statements, config.getModuleId());
|
||||||
statements.add(new JsReturn(program.getRootScope().declareName(Namer.getRootPackageName()).makeRef()));
|
|
||||||
|
|
||||||
mayBeGenerateTests(files, config, rootBlock, context);
|
mayBeGenerateTests(files, config, rootBlock, context);
|
||||||
|
|
||||||
@@ -241,6 +240,8 @@ public final class Translation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
statements.add(new JsReturn(program.getRootScope().declareName(Namer.getRootPackageName()).makeRef()));
|
||||||
|
|
||||||
JsBlock block = program.getGlobalBlock();
|
JsBlock block = program.getGlobalBlock();
|
||||||
block.getStatements().addAll(wrapIfNecessary(config.getModuleId(), rootFunction, importedModuleList, program,
|
block.getStatements().addAll(wrapIfNecessary(config.getModuleId(), rootFunction, importedModuleList, program,
|
||||||
config.getModuleKind()));
|
config.getModuleKind()));
|
||||||
@@ -362,7 +363,7 @@ public final class Translation {
|
|||||||
statement = invocation.makeStmt();
|
statement = invocation.makeStmt();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
statement = JsAstUtils.newVar(program.getScope().declareName(moduleId), function);
|
statement = JsAstUtils.newVar(program.getScope().declareName(moduleId), invocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Collections.singletonList(statement);
|
return Collections.singletonList(statement);
|
||||||
|
|||||||
Reference in New Issue
Block a user