Get rid of LoadJavaDescriptorsTest.

Implement the same test via existing LoadJavaDescriptorsTest.
Move test data.
This commit is contained in:
Pavel V. Talanov
2012-08-23 13:31:03 +04:00
parent 971b27fe61
commit 9dc611c4fe
6 changed files with 26 additions and 85 deletions
@@ -1,5 +1,6 @@
package test;
class A implements B.C {
public class inner implements B.C {
}
class B {
@@ -0,0 +1,5 @@
namespace test
public open class test.inner : test.B.C {
public final /*constructor*/ fun <init>(): test.inner
}
@@ -0,0 +1,3 @@
namespace test
public final val foo: jet.String
@@ -1,4 +1,3 @@
class StaticFinal {
public class test {
public static final String foo = "aaa";
}
@@ -1,82 +0,0 @@
/*
* 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.jet.jvm.compiler;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.CompileCompilerDependenciesTest;
import org.jetbrains.jet.ConfigurationKind;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.TestJdkKind;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.di.InjectorForJavaSemanticServices;
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.resolve.java.DescriptorSearchRule;
import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.test.TestCaseWithTmpdir;
import org.junit.Assert;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
/**
* @author Stepan Koltsov
* @see AbstractReadJavaBinaryClassTest
*/
public class JavaDescriptorResolverTest extends TestCaseWithTmpdir {
// This test can be implemented in ReadJavaBinaryClassTest, but it is simpler here
public void testInner() throws Exception {
compileFileResolveDescriptor("inner.java", new FqName("A"));
}
// We cannot declare class and namespace with same name in Kotlin
// http://youtrack.jetbrains.com/issue/KT-1388
public void testStaticFinal() throws Exception {
JavaDescriptorResolver javaDescriptorResolver = compileFileGetJavaDescriptorResolver("staticFinal.java");
NamespaceDescriptor ns = javaDescriptorResolver.resolveNamespace(new FqName("StaticFinal"),
DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
Collection<VariableDescriptor> foos = ns.getMemberScope().getProperties(Name.identifier("foo"));
Assert.assertEquals(1, foos.size());
VariableDescriptor foo = foos.iterator().next();
Assert.assertFalse(foo.getType().isNullable());
}
private ClassDescriptor compileFileResolveDescriptor(@NotNull String fileRelativePath, @NotNull FqName fqName) throws IOException {
JavaDescriptorResolver javaDescriptorResolver = compileFileGetJavaDescriptorResolver(fileRelativePath);
ClassDescriptor classDescriptor = javaDescriptorResolver.resolveClass(fqName, DescriptorSearchRule.ERROR_IF_FOUND_IN_KOTLIN);
Assert.assertNotNull(classDescriptor);
return classDescriptor;
}
private JavaDescriptorResolver compileFileGetJavaDescriptorResolver(String fileRelativePath) throws IOException {
JetTestUtils.compileJavaFile(new File("compiler/testData/javaDescriptorResolver/" + fileRelativePath), tmpdir);
JetCoreEnvironment jetCoreEnvironment =
new JetCoreEnvironment(myTestRootDisposable, CompileCompilerDependenciesTest.compilerConfigurationForTests(
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, JetTestUtils.getAnnotationsJar(), tmpdir));
InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices(BuiltinsScopeExtensionMode.ALL,
jetCoreEnvironment.getProject());
return injector.getJavaDescriptorResolver();
}
}
@@ -66,6 +66,21 @@ public final class LoadJavaDescriptorsTest extends KotlinTestWithEnvironment {
javaDir + "/awt/Frame.java");
}
public void testInner() throws Exception {
doSimpleTest();
}
public void testStaticFinal() throws Exception {
String dir = "/staticFinal/";
doTest(PATH + dir + "expected.txt",
PATH + dir + "test.java");
}
private void doSimpleTest() throws Exception {
doTest(PATH + "/" + getTestName(false) + ".txt",
PATH + "/" + getTestName(false) + ".java");
}
public void testEnum() throws Exception {
String dir = PATH + "/enum";
String javaDir = dir + "/java";