Very simple test for resolving static members of java classes
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
public class Simple {
|
||||
public static void bar() {}
|
||||
|
||||
public void foo() {}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace test
|
||||
|
||||
public open class test.Simple : java.lang.Object {
|
||||
public final /*constructor*/ fun <init>(): test.Simple
|
||||
public open fun foo(): jet.Tuple0
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Simple
|
||||
|
||||
public open fun bar(): jet.Tuple0
|
||||
@@ -37,6 +37,11 @@ public abstract class AbstractJavaResolverDescriptorTest extends TestCaseWithTmp
|
||||
|
||||
protected JavaDescriptorResolver javaDescriptorResolver;
|
||||
|
||||
protected void compileJavaFile(@NotNull String fileRelativePath)
|
||||
throws IOException {
|
||||
compileJavaFile(fileRelativePath, null);
|
||||
}
|
||||
|
||||
protected void compileJavaFile(@NotNull String fileRelativePath, @Nullable String classPath)
|
||||
throws IOException {
|
||||
File javaFile = new File(getPath() + fileRelativePath);
|
||||
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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 junit.framework.Assert;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.jetbrains.jet.test.util.NamespaceComparator.DONT_INCLUDE_METHODS_OF_OBJECT;
|
||||
import static org.jetbrains.jet.test.util.NamespaceComparator.compareNamespaces;
|
||||
|
||||
public final class StaticMembersJavaDescriptorResolverTest extends AbstractJavaResolverDescriptorTest {
|
||||
|
||||
private static final String PATH = "compiler/testData/javaDescriptorResolver/staticMembers/";
|
||||
private static final String DEFAULT_PACKAGE = "test";
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected String getPath() {
|
||||
return PATH;
|
||||
}
|
||||
|
||||
public void testSimple() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws IOException {
|
||||
String name = getTestName(false);
|
||||
compileJavaFile(name + ".java");
|
||||
NamespaceDescriptor namespaceWithClass = javaDescriptorResolver.resolveNamespace(new FqName(DEFAULT_PACKAGE));
|
||||
Assert.assertNotNull(namespaceWithClass);
|
||||
compareNamespaces(namespaceWithClass, namespaceWithClass, DONT_INCLUDE_METHODS_OF_OBJECT, new File(PATH + name + "_non_static.txt"));
|
||||
|
||||
NamespaceDescriptor namespaceWithStaticMembers = javaDescriptorResolver.resolveNamespace(new FqName(DEFAULT_PACKAGE + "." + name));
|
||||
Assert.assertNotNull(namespaceWithStaticMembers);
|
||||
compareNamespaces(namespaceWithStaticMembers, namespaceWithStaticMembers, DONT_INCLUDE_METHODS_OF_OBJECT,
|
||||
new File(PATH + name + "_static.txt"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user