Support a simple case with nested namespaces.

This commit is contained in:
Pavel V. Talanov
2012-03-19 13:44:45 +04:00
parent ff3c0a20a0
commit 37cf07b557
4 changed files with 45 additions and 1 deletions
@@ -0,0 +1,37 @@
/*
* Copyright 2010-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.k2js.test.semantics;
import org.jetbrains.k2js.test.SingleFileTranslationTest;
/**
* @author Pavel Talanov
*/
public final class NamespaceTest extends SingleFileTranslationTest {
public NamespaceTest() {
super("namespace/");
}
public void testNestedNamespace() throws Exception {
runFunctionOutputTest("nestedNamespace.kt", "foo.bar", "box", true);
}
public void testDeeplyNestedNamespace() throws Exception {
runFunctionOutputTest("deeplyNestedNamespace.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true);
}
}
@@ -31,6 +31,7 @@ import java.util.Set;
import static org.jetbrains.k2js.translate.utils.BindingUtils.getAllNonNativeNamespaceDescriptors;
import static org.jetbrains.k2js.translate.utils.DescriptorUtils.getAllClassesDefinedInNamespace;
import static org.jetbrains.k2js.translate.utils.NamespaceSortingUtils.sortNamespacesUsingQualificationOrder;
/**
* @author Pavel Talanov
@@ -50,7 +51,7 @@ public final class NamespaceDeclarationTranslator extends AbstractTranslator {
private NamespaceDeclarationTranslator(@NotNull List<NamespaceDescriptor> namespaceDescriptors,
@NotNull TranslationContext context) {
super(context);
this.namespaceDescriptors = namespaceDescriptors;
this.namespaceDescriptors = sortNamespacesUsingQualificationOrder(namespaceDescriptors);
this.classDeclarationTranslator = new ClassDeclarationTranslator(getAllClasses(), context);
}
@@ -0,0 +1,3 @@
package foo1.foo2.foo3.foo5.foo6.foo7.foo8
fun box() = true
@@ -0,0 +1,3 @@
package foo.bar
fun box() = true