Added tests for ignoring Object methods when loading interface.

This commit is contained in:
Evgeny Gerashchenko
2013-03-26 21:18:20 +04:00
parent ecf882fc21
commit 8f079f6d41
7 changed files with 82 additions and 6 deletions
@@ -70,6 +70,14 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
}
protected void doTestCompiledJava(@NotNull String javaFileName) throws Exception {
doTestCompiledJava(javaFileName, DONT_INCLUDE_METHODS_OF_OBJECT);
}
protected void doTestCompiledJavaIncludeObjectMethods(@NotNull String javaFileName) throws Exception {
doTestCompiledJava(javaFileName, RECURSIVE);
}
private void doTestCompiledJava(@NotNull String javaFileName, Configuration configuration) throws Exception {
final File srcDir = new File(tmpdir, "src");
File compiledDir = new File(tmpdir, "compiled");
assertTrue(srcDir.mkdir());
@@ -97,7 +105,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext = compileJavaAndLoadTestNamespaceAndBindingContextFromBinary(
srcFiles, compiledDir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
checkJavaNamespace(new File(javaFileName.replaceFirst("\\.java$", ".txt")), javaNamespaceAndContext.first, javaNamespaceAndContext.second);
checkJavaNamespace(new File(javaFileName.replaceFirst("\\.java$", ".txt")), javaNamespaceAndContext.first, javaNamespaceAndContext.second, configuration);
}
protected void doTestSourceJava(@NotNull String javaFileName) throws Exception {
@@ -111,7 +119,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext = loadTestNamespaceAndBindingContextFromJavaRoot(
tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second);
checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second, DONT_INCLUDE_METHODS_OF_OBJECT);
}
protected void doTestJavaAgainstKotlin(String expectedFileName) throws Exception {
@@ -153,7 +161,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
LoadDescriptorUtil.TEST_PACKAGE_FQNAME, DescriptorSearchRule.INCLUDE_KOTLIN);
assert namespaceDescriptor != null : "Test namespace not found";
checkJavaNamespace(expectedFile, namespaceDescriptor, trace.getBindingContext());
checkJavaNamespace(expectedFile, namespaceDescriptor, trace.getBindingContext(), DONT_INCLUDE_METHODS_OF_OBJECT);
}
private static void checkForLoadErrorsAndCompare(
@@ -200,12 +208,13 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
private static void checkJavaNamespace(
final File txtFile,
final NamespaceDescriptor javaNamespace,
BindingContext bindingContext
BindingContext bindingContext,
final Configuration configuration
) {
checkForLoadErrorsAndCompare(javaNamespace, bindingContext, new Runnable() {
@Override
public void run() {
compareNamespaceWithFile(javaNamespace, DONT_INCLUDE_METHODS_OF_OBJECT, txtFile);
compareNamespaceWithFile(javaNamespace, configuration, txtFile);
}
});
}
@@ -30,7 +30,7 @@ import org.jetbrains.jet.jvm.compiler.AbstractLoadJavaTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.SourceJava.class, LoadJavaTestGenerated.JavaAgainstKotlin.class})
@InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJavaIncludeObjectMethods.class, LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.SourceJava.class, LoadJavaTestGenerated.JavaAgainstKotlin.class})
public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
@TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin")
@InnerTestClasses({CompiledJavaCompareWithKotlin.Annotation.class, CompiledJavaCompareWithKotlin.Constructor.class, CompiledJavaCompareWithKotlin.JavaBean.class, CompiledJavaCompareWithKotlin.KotlinSignature.class, CompiledJavaCompareWithKotlin.Library.class, CompiledJavaCompareWithKotlin.Modality.class, CompiledJavaCompareWithKotlin.NotNull.class, CompiledJavaCompareWithKotlin.Vararg.class})
@@ -970,6 +970,24 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
}
}
@TestMetadata("compiler/testData/loadJava/compiledJavaIncludeObjectMethods")
public static class CompiledJavaIncludeObjectMethods extends AbstractLoadJavaTest {
public void testAllFilesPresentInCompiledJavaIncludeObjectMethods() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJavaIncludeObjectMethods"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("ClassWithObjectMethod.java")
public void testClassWithObjectMethod() throws Exception {
doTestCompiledJavaIncludeObjectMethods("compiler/testData/loadJava/compiledJavaIncludeObjectMethods/ClassWithObjectMethod.java");
}
@TestMetadata("InterfaceWithObjectMethods.java")
public void testInterfaceWithObjectMethods() throws Exception {
doTestCompiledJavaIncludeObjectMethods("compiler/testData/loadJava/compiledJavaIncludeObjectMethods/InterfaceWithObjectMethods.java");
}
}
@TestMetadata("compiler/testData/loadJava/compiledJava")
@InnerTestClasses({CompiledJava.Annotations.class, CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.SignaturePropagation.class, CompiledJava.SingleAbstractMethod.class, CompiledJava.Static.class})
public static class CompiledJava extends AbstractLoadJavaTest {
@@ -1323,6 +1341,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
public static Test suite() {
TestSuite suite = new TestSuite("LoadJavaTestGenerated");
suite.addTest(CompiledJavaCompareWithKotlin.innerSuite());
suite.addTestSuite(CompiledJavaIncludeObjectMethods.class);
suite.addTest(CompiledJava.innerSuite());
suite.addTestSuite(SourceJava.class);
suite.addTest(JavaAgainstKotlin.innerSuite());