js: rename "anonymous" ns to "root"
also use constant field instead of hardcoded literal in tests
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.k2js.test.rhino;
|
package org.jetbrains.k2js.test.rhino;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.k2js.translate.context.Namer;
|
||||||
import org.jetbrains.k2js.utils.GenerationUtils;
|
import org.jetbrains.k2js.utils.GenerationUtils;
|
||||||
import org.mozilla.javascript.Context;
|
import org.mozilla.javascript.Context;
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
@@ -58,7 +59,7 @@ public final class RhinoSystemOutputChecker implements RhinoResultChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void runMain(Context context, Scriptable scope) {
|
private void runMain(Context context, Scriptable scope) {
|
||||||
String callToMain = GenerationUtils.generateCallToMain("Anonymous", arguments);
|
String callToMain = GenerationUtils.generateCallToMain(Namer.getRootNamespaceName(), arguments);
|
||||||
context.evaluateString(scope, callToMain, "function call", 0, null);
|
context.evaluateString(scope, callToMain, "function call", 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import junit.framework.Test;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.k2js.test.BasicTest;
|
import org.jetbrains.k2js.test.BasicTest;
|
||||||
import org.jetbrains.k2js.test.SingleFileTranslationTest;
|
import org.jetbrains.k2js.test.SingleFileTranslationTest;
|
||||||
|
import org.jetbrains.k2js.translate.context.Namer;
|
||||||
|
|
||||||
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
||||||
public final class ExamplesTest extends SingleFileTranslationTest {
|
public final class ExamplesTest extends SingleFileTranslationTest {
|
||||||
@@ -35,7 +36,7 @@ public final class ExamplesTest extends SingleFileTranslationTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runTest() throws Exception {
|
public void runTest() throws Exception {
|
||||||
runFunctionOutputTest(filename, "Anonymous", "box", "OK");
|
runFunctionOutputTest(filename, Namer.getRootNamespaceName(), "box", "OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.test.semantics;
|
package org.jetbrains.k2js.test.semantics;
|
||||||
|
|
||||||
|
import org.jetbrains.k2js.translate.context.Namer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Pavel Talanov
|
* @author Pavel Talanov
|
||||||
*/
|
*/
|
||||||
@@ -58,7 +60,7 @@ public class FunctionTest extends AbstractExpressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testEnclosingThis() throws Exception {
|
public void testEnclosingThis() throws Exception {
|
||||||
runFunctionOutputTest("enclosingThis.kt", "Anonymous", "box", "OK");
|
runFunctionOutputTest("enclosingThis.kt", Namer.getRootNamespaceName(), "box", "OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.k2js.test.semantics;
|
package org.jetbrains.k2js.test.semantics;
|
||||||
|
|
||||||
|
import org.jetbrains.k2js.translate.context.Namer;
|
||||||
import org.mozilla.javascript.JavaScriptException;
|
import org.mozilla.javascript.JavaScriptException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +46,7 @@ public final class MiscTest extends AbstractExpressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testClassWithoutNamespace() throws Exception {
|
public void testClassWithoutNamespace() throws Exception {
|
||||||
runFunctionOutputTest("classWithoutNamespace.kt", "Anonymous", "box", true);
|
runFunctionOutputTest("classWithoutNamespace.kt", Namer.getRootNamespaceName(), "box", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIfElseAsExpressionWithThrow() throws Exception {
|
public void testIfElseAsExpressionWithThrow() throws Exception {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public final class Namer {
|
|||||||
private static final String BACKING_FIELD_PREFIX = "$";
|
private static final String BACKING_FIELD_PREFIX = "$";
|
||||||
private static final String SUPER_METHOD_NAME = "super_init";
|
private static final String SUPER_METHOD_NAME = "super_init";
|
||||||
private static final String KOTLIN_OBJECT_NAME = "Kotlin";
|
private static final String KOTLIN_OBJECT_NAME = "Kotlin";
|
||||||
private static final String ANONYMOUS_NAMESPACE = "Anonymous";
|
private static final String ROOT_NAMESPACE = "Root";
|
||||||
private static final String RECEIVER_PARAMETER_NAME = "receiver";
|
private static final String RECEIVER_PARAMETER_NAME = "receiver";
|
||||||
private static final String CLASSES_OBJECT_NAME = "classes";
|
private static final String CLASSES_OBJECT_NAME = "classes";
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ public final class Namer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static String getAnonymousNamespaceName() {
|
public static String getRootNamespaceName() {
|
||||||
return ANONYMOUS_NAMESPACE;
|
return ROOT_NAMESPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ public final class JsDescriptorUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
public static String getNameForNamespace(@NotNull NamespaceDescriptor descriptor) {
|
public static String getNameForNamespace(@NotNull NamespaceDescriptor descriptor) {
|
||||||
if (descriptor.getContainingDeclaration() instanceof ModuleDescriptor) {
|
if (descriptor.getContainingDeclaration() instanceof ModuleDescriptor) {
|
||||||
return Namer.getAnonymousNamespaceName();
|
return Namer.getRootNamespaceName();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return descriptor.getName();
|
return descriptor.getName();
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public final class PsiUtils {
|
|||||||
String name = namespaceHeader.getName();
|
String name = namespaceHeader.getName();
|
||||||
assert name != null : "NamespaceHeader must have a name";
|
assert name != null : "NamespaceHeader must have a name";
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
return Namer.getAnonymousNamespaceName();
|
return Namer.getRootNamespaceName();
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user