Rename namespace class to {package.name}Package

Conflicts:

	compiler/jet.as.java.psi/src/org/jetbrains/jet/asJava/JavaElementFinder.java
This commit is contained in:
Natalia.Ukhorskaya
2013-01-11 12:00:27 +04:00
parent 0f2fa6bade
commit 47abdcf565
113 changed files with 436 additions and 193 deletions
@@ -0,0 +1,104 @@
/*
* Copyright 2010-2013 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.jet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
import static org.jetbrains.jet.lang.resolve.java.PackageClassUtils.*;
public class PackageClassNameTest {
@Test
public void testPackageName1() {
doTest("kotlin", "KotlinPackage", "_DefaultPackage");
}
@Test
public void testPackageName2() {
doTest("kotlin.io", "IoPackage", "KotlinPackage");
}
@Test
public void testPackageName3() {
doTest("kotlin.io.foo", "FooPackage", "IoPackage");
}
@Test
public void testPackageName4() {
doTest("kotlinTest.ioTest", "IoTestPackage", "KotlinTestPackage");
}
@Test
public void testPackageName5() {
doTest(FqName.ROOT, "_DefaultPackage", null);
}
@Test
public void testPackageName6() {
doTest(FqName.ROOT.child(Name.identifier("kotlin")), "KotlinPackage", "_DefaultPackage");
}
@Test
public void testIsPackageClass1() {
doTestIsPackageClass("", true);
}
@Test
public void testIsPackageClass2() {
doTestIsPackageClass("kotlin", false);
}
@Test
public void testIsPackageClass3() {
doTestIsPackageClass("kotlin.KotlinPackage", true);
}
@Test
public void testIsPackageClass4() {
doTestIsPackageClass("kotlin.test.SomeClass", false);
}
@Test
public void testIsPackageClass5() {
doTestIsPackageClass("kotlin.io.IoPackage", true);
}
@Test
public void testInnerIsPackage() {
doTestIsPackageClass("kotlin.io.IoPackage$Foo", false);
}
private void doTest(@NotNull String name, @NotNull String expectedForChild, @Nullable String expectedForParent) {
doTest(new FqName(name), expectedForChild, expectedForParent);
}
private void doTest(@NotNull FqName name, @NotNull String expectedForChild, @Nullable String expectedForParent) {
assertEquals("Wrong result for child [" + name + "].", expectedForChild, getPackageClassName(name));
if (expectedForParent != null) {
assertEquals("Wrong result for parent [" + name + "].", expectedForParent, getPackageClassName(name.parent()));
}
}
private void doTestIsPackageClass(String testedName, boolean expected) {
assertEquals("Wrong result for [" + testedName + "].", expected, isPackageClass(new FqName(testedName)));
}
}