Got rid of "namespace" word in compiler code.

This commit is contained in:
Evgeny Gerashchenko
2014-01-10 22:25:23 +04:00
parent 093afeb05c
commit b41a3f8558
55 changed files with 194 additions and 191 deletions
@@ -36,18 +36,20 @@ public abstract class MultipleFilesTranslationTest extends BasicTest {
generateJavaScriptFiles(fullFilePaths, dirName, MainCallParameters.noCall(), ecmaVersions);
}
protected void runMultiFileTest(@NotNull String dirName, @NotNull String namespaceName,
protected void runMultiFileTest(@NotNull String dirName, @NotNull String packageName,
@NotNull String functionName, @NotNull Object expectedResult) throws Exception {
runMultiFileTests(DEFAULT_ECMA_VERSIONS, dirName, namespaceName, functionName, expectedResult);
runMultiFileTests(DEFAULT_ECMA_VERSIONS, dirName, packageName, functionName, expectedResult);
}
protected void runMultiFileTests(@NotNull Iterable<EcmaVersion> ecmaVersions, @NotNull String dirName,
@NotNull String namespaceName,
protected void runMultiFileTests(
@NotNull Iterable<EcmaVersion> ecmaVersions,
@NotNull String dirName,
@NotNull String packageName,
@NotNull String functionName,
@NotNull Object expectedResult)
throws Exception {
@NotNull Object expectedResult
) throws Exception {
generateJsFromDir(dirName, ecmaVersions);
runRhinoTests(dirName + ".kt", ecmaVersions, new RhinoFunctionResultChecker(namespaceName, functionName, expectedResult));
runRhinoTests(dirName + ".kt", ecmaVersions, new RhinoFunctionResultChecker(packageName, functionName, expectedResult));
}
public void checkFooBoxIsTrue(@NotNull String dirName) throws Exception {
@@ -77,11 +77,11 @@ public final class OutputPrefixPostfixTest extends SingleFileTranslationTest {
protected void runFunctionOutputTest(
@NotNull Iterable<EcmaVersion> ecmaVersions,
@NotNull String kotlinFilename,
@NotNull String namespaceName,
@NotNull String packageName,
@NotNull String functionName,
@NotNull Object expectedResult
) throws Exception {
super.runFunctionOutputTest(ecmaVersions, kotlinFilename, namespaceName, functionName, expectedResult);
super.runFunctionOutputTest(ecmaVersions, kotlinFilename, packageName, functionName, expectedResult);
for (EcmaVersion ecmaVersion : ecmaVersions) {
String output = FileUtil.loadFile(new File(getOutputFilePath(filename, ecmaVersion)));
@@ -31,17 +31,19 @@ public abstract class SingleFileTranslationTest extends BasicTest {
super(main);
}
public void runFunctionOutputTest(@NotNull String kotlinFilename, @NotNull String namespaceName,
public void runFunctionOutputTest(@NotNull String kotlinFilename, @NotNull String packageName,
@NotNull String functionName, @NotNull Object expectedResult) throws Exception {
runFunctionOutputTest(DEFAULT_ECMA_VERSIONS, kotlinFilename, namespaceName, functionName, expectedResult);
runFunctionOutputTest(DEFAULT_ECMA_VERSIONS, kotlinFilename, packageName, functionName, expectedResult);
}
protected void runFunctionOutputTest(@NotNull Iterable<EcmaVersion> ecmaVersions, @NotNull String kotlinFilename,
@NotNull String namespaceName,
protected void runFunctionOutputTest(
@NotNull Iterable<EcmaVersion> ecmaVersions,
@NotNull String kotlinFilename,
@NotNull String packageName,
@NotNull String functionName,
@NotNull Object expectedResult) throws Exception {
generateJavaScriptFiles(kotlinFilename, MainCallParameters.noCall(), ecmaVersions);
runRhinoTests(kotlinFilename, ecmaVersions, new RhinoFunctionResultChecker(namespaceName, functionName, expectedResult));
runRhinoTests(kotlinFilename, ecmaVersions, new RhinoFunctionResultChecker(packageName, functionName, expectedResult));
}
public void checkFooBoxIsTrue(@NotNull String filename, @NotNull Iterable<EcmaVersion> ecmaVersions) throws Exception {
@@ -25,8 +25,8 @@ import org.mozilla.javascript.NativeJavaObject;
*/
public class RhinoFunctionNativeObjectResultChecker extends RhinoFunctionResultChecker {
public RhinoFunctionNativeObjectResultChecker(@Nullable String namespaceName, String functionName, Object expectedResult) {
super(namespaceName, functionName, expectedResult);
public RhinoFunctionNativeObjectResultChecker(@Nullable String packageName, String functionName, Object expectedResult) {
super(packageName, functionName, expectedResult);
}
public RhinoFunctionNativeObjectResultChecker(String functionName, Object expectedResult) {
@@ -28,17 +28,17 @@ import static org.junit.Assert.assertEquals;
public class RhinoFunctionResultChecker implements RhinoResultChecker {
private final String moduleId;
private final String namespaceName;
private final String packageName;
private final String functionName;
private final Object expectedResult;
public RhinoFunctionResultChecker(@Nullable String namespaceName, String functionName, Object expectedResult) {
this(Config.REWRITABLE_MODULE_NAME, namespaceName, functionName, expectedResult);
public RhinoFunctionResultChecker(@Nullable String packageName, String functionName, Object expectedResult) {
this(Config.REWRITABLE_MODULE_NAME, packageName, functionName, expectedResult);
}
public RhinoFunctionResultChecker(@Nullable String moduleId, @Nullable String namespaceName, String functionName, Object expectedResult) {
public RhinoFunctionResultChecker(@Nullable String moduleId, @Nullable String packageName, String functionName, Object expectedResult) {
this.moduleId = moduleId;
this.namespaceName = namespaceName;
this.packageName = packageName;
this.functionName = functionName;
this.expectedResult = expectedResult;
}
@@ -56,8 +56,8 @@ public class RhinoFunctionResultChecker implements RhinoResultChecker {
protected void assertResultValid(Object result, Context context) {
String ecmaVersion = context.getLanguageVersion() == Context.VERSION_1_8 ? "ecma5" : "ecma3";
assertEquals("Result of " + namespaceName + "." + functionName + "() is not what expected (" + ecmaVersion + ")!", expectedResult, result);
String report = namespaceName + "." + functionName + "() = " + Context.toString(result);
assertEquals("Result of " + packageName + "." + functionName + "() is not what expected (" + ecmaVersion + ")!", expectedResult, result);
String report = packageName + "." + functionName + "() = " + Context.toString(result);
System.out.println(report);
}
@@ -67,15 +67,15 @@ public class RhinoFunctionResultChecker implements RhinoResultChecker {
protected String functionCallString() {
StringBuilder sb = new StringBuilder();
if (namespaceName != null) {
if (packageName != null) {
sb.append("Kotlin.modules");
if (moduleId.contains(".")) {
sb.append("['").append(moduleId).append("']");
} else {
sb.append(".").append(moduleId);
}
if (namespaceName != Namer.getRootNamespaceName()) {
sb.append('.').append(namespaceName);
if (packageName != Namer.getRootPackageName()) {
sb.append('.').append(packageName);
}
sb.append('.');
}
@@ -36,7 +36,7 @@ public final class ExamplesTest extends SingleFileTranslationTest {
@Override
public void runTest() throws Exception {
runFunctionOutputTest(filename, Namer.getRootNamespaceName(), "box", "OK");
runFunctionOutputTest(filename, Namer.getRootPackageName(), "box", "OK");
}
public static Test suite() throws Exception {
@@ -42,7 +42,7 @@ public final class MiscTest extends AbstractExpressionTest {
}
public void testClassWithoutNamespace() throws Exception {
runFunctionOutputTest("classWithoutNamespace.kt", Namer.getRootNamespaceName(), "box", true);
runFunctionOutputTest("classWithoutNamespace.kt", Namer.getRootPackageName(), "box", true);
}
public void testIfElseAsExpressionWithThrow() throws Exception {
@@ -156,7 +156,7 @@ public final class MiscTest extends AbstractExpressionTest {
//TODO: see http://youtrack.jetbrains.com/issue/KT-2564
@SuppressWarnings("UnusedDeclaration")
public void TODO_testNamespaceLevelVarInRoot() throws Exception {
runFunctionOutputTest("namespaceLevelVarInRoot.kt", Namer.getRootNamespaceName(), "box", "OK");
runFunctionOutputTest("namespaceLevelVarInRoot.kt", Namer.getRootPackageName(), "box", "OK");
}
public void testLazyPropertyGetterNotCalledOnStart() throws Exception {