KT-3008 Fix JS backend tests

This commit is contained in:
Alexey Andreev
2016-04-12 12:31:00 +03:00
parent 848d7f92fa
commit b556b6efca
5 changed files with 18 additions and 6 deletions
+2 -2
View File
@@ -7,6 +7,7 @@ where possible options include:
-meta-info Generate metadata
-kjsm Generate kjsm-files (for creating libraries)
-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)
-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
@@ -17,5 +18,4 @@ where possible options include:
-help (-h) Print a synopsis of standard options
-X Print a synopsis of advanced options
-P plugin:<pluginId>:<optionName>=<value>
Pass an option to a plugin
OK
Pass an option to a plugin
@@ -83,7 +83,7 @@ public abstract class JsConfig {
@NotNull
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);
@@ -193,6 +193,7 @@ public final class RhinoUtils {
private static ScriptableObject initScope(@NotNull EcmaVersion version, @NotNull Context context, @NotNull List<String> jsLibraries) {
ScriptableObject scope = context.initStandardObjects();
try {
context.evaluateString(scope, "var Kotlin = {};", ".", 1, null);
runFileWithRhino(getKotlinLibFile(version), context, scope);
runFileWithRhino(TEST_DATA_DIR_PATH + "kotlin_lib.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.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.JsAstUtils.pureFqn;
@@ -542,6 +545,13 @@ public final class StaticContext {
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);
if (moduleName == null) {
return result;
@@ -217,7 +217,6 @@ public final class Translation {
TranslationContext context = TranslationContext.rootContext(staticContext, rootFunction);
statements.addAll(PackageDeclarationTranslator.translateFiles(files, context));
defineModule(context, statements, config.getModuleId());
statements.add(new JsReturn(program.getRootScope().declareName(Namer.getRootPackageName()).makeRef()));
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();
block.getStatements().addAll(wrapIfNecessary(config.getModuleId(), rootFunction, importedModuleList, program,
config.getModuleKind()));
@@ -362,7 +363,7 @@ public final class Translation {
statement = invocation.makeStmt();
}
else {
statement = JsAstUtils.newVar(program.getScope().declareName(moduleId), function);
statement = JsAstUtils.newVar(program.getScope().declareName(moduleId), invocation);
}
return Collections.singletonList(statement);