Add simple tests for using nested namespace.

This commit is contained in:
Pavel V. Talanov
2012-03-19 14:14:35 +04:00
parent 20d6729012
commit 6f87634b25
6 changed files with 24 additions and 5 deletions
@@ -40,5 +40,9 @@ public class MultiNamespaceTest extends MultipleFilesTranslationTest {
checkFooBoxIsTrue("namespaceVariableVisibleFromOtherNamespace");
}
public void testNestedNamespaceFunctionCalledFromOtherNamespace() throws Exception {
checkFooBoxIsTrue("nestedNamespaceFunctionCalledFromOtherNamespace");
}
}
@@ -34,4 +34,7 @@ public final class NamespaceTest extends SingleFileTranslationTest {
runFunctionOutputTest("deeplyNestedNamespace.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true);
}
public void testDeeplyNestedNamespaceFunctionCalled() throws Exception {
runFunctionOutputTest("deeplyNestedNamespaceFunctionCalled.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true);
}
}
@@ -42,8 +42,8 @@ public final class QualifiedExpressionTranslator {
JsExpression receiver = translateReceiver(expression, context);
PropertyAccessTranslator result =
PropertyAccessTranslator.newInstance(getNotNullSimpleNameSelector(expression), receiver,
CallType.getCallTypeForQualifiedExpression(expression), context);
PropertyAccessTranslator.newInstance(getNotNullSimpleNameSelector(expression), receiver,
CallType.getCallTypeForQualifiedExpression(expression), context);
result.setCallType(CallType.getCallTypeForQualifiedExpression(expression));
return result;
}
@@ -65,12 +65,15 @@ public final class QualifiedExpressionTranslator {
if (PropertyAccessTranslator.canBePropertyGetterCall(selector, context)) {
assert selector instanceof JetSimpleNameExpression : "Selectors for properties must be simple names.";
return PropertyAccessTranslator.translateAsPropertyGetterCall
((JetSimpleNameExpression) selector, receiver, callType, context);
((JetSimpleNameExpression)selector, receiver, callType, context);
}
if (selector instanceof JetCallExpression) {
return CallExpressionTranslator.translate((JetCallExpression) selector, receiver, callType, context);
return CallExpressionTranslator.translate((JetCallExpression)selector, receiver, callType, context);
}
throw new AssertionError("Unexpected qualified expression");
if (selector instanceof JetSimpleNameExpression) {
return ReferenceTranslator.translateSimpleName((JetSimpleNameExpression)selector, context);
}
throw new AssertionError("Unexpected qualified expression: " + selector.getText());
}
//TODO: if has duplications
@@ -0,0 +1,3 @@
package a.foo
fun box() = b.bar.f()
@@ -0,0 +1,2 @@
package b.bar
fun f() = true
@@ -0,0 +1,4 @@
package foo1.foo2.foo3.foo5.foo6.foo7.foo8
fun box() = f()
fun f() = true