KJS: move println to kotlin.io; import kotlin.io by default in Default platform

This commit is contained in:
Zalim Bashorov
2016-12-24 22:45:08 +03:00
parent 7f10ce072f
commit 6ea6e4ab98
19 changed files with 112 additions and 104 deletions
@@ -17,10 +17,10 @@
package org.jetbrains.kotlin.js.test.rhino;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.js.facade.K2JSTranslator;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable;
import static org.jetbrains.kotlin.js.test.rhino.RhinoUtils.GET_KOTLIN_OUTPUT;
import static org.junit.Assert.assertTrue;
public final class RhinoSystemOutputChecker implements RhinoResultChecker {
@@ -44,7 +44,7 @@ public final class RhinoSystemOutputChecker implements RhinoResultChecker {
@NotNull
private static String getSystemOutput(@NotNull Context context, @NotNull Scriptable scope) {
Object output = context.evaluateString(scope, K2JSTranslator.GET_SYSTEM_OUT, "test", 0, null);
Object output = context.evaluateString(scope, GET_KOTLIN_OUTPUT, "test", 0, null);
RhinoUtils.flushSystemOut(context, scope);
assertTrue("Output should be a string.", output instanceof String);
return (String) output;
@@ -22,7 +22,6 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.js.config.EcmaVersion;
import org.jetbrains.kotlin.js.facade.K2JSTranslator;
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
import org.mozilla.javascript.*;
@@ -47,7 +46,11 @@ public final class RhinoUtils {
public static final int OPTIMIZATION_OFF = -1;
public static final int OPTIMIZATION_DEFAULT = 0;
private static final int OPTIMIZATION_DEFAULT = 0;
private static final String SETUP_KOTLIN_OUTPUT = "kotlin.kotlin.io.output = new kotlin.kotlin.io.BufferedOutput();";
private static final String FLUSH_KOTLIN_OUTPUT = "kotlin.kotlin.io.output.flush();";
public static final String GET_KOTLIN_OUTPUT = "kotlin.kotlin.io.output.buffer;";
@NotNull
private static final Map<EcmaVersion, ScriptableObject> versionToScope = ContainerUtil.newHashMap();
@@ -140,7 +143,7 @@ public final class RhinoUtils {
Scriptable scope = getScope(ecmaVersion, context, jsLibraries);
putGlobalVariablesIntoScope(scope, variables);
context.evaluateString(scope, "kotlin.out = new kotlin.BufferedOutput();", "setup Kotlin.out", 0, null);
context.evaluateString(scope, SETUP_KOTLIN_OUTPUT, "setup kotlin output", 0, null);
for (String filename : fileNames) {
runFileWithRhino(filename, context, scope);
@@ -219,7 +222,7 @@ public final class RhinoUtils {
}
static void flushSystemOut(@NotNull Context context, @NotNull Scriptable scope) {
context.evaluateString(scope, K2JSTranslator.FLUSH_SYSTEM_OUT, "test", 0, null);
context.evaluateString(scope, FLUSH_KOTLIN_OUTPUT, "test", 0, null);
}
@Nullable