Added tests for ignoring Object methods when loading interface.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package test;
|
||||
|
||||
public final class ClassWithObjectMethod {
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package test
|
||||
|
||||
public final class ClassWithObjectMethod : java.lang.Object {
|
||||
public constructor ClassWithObjectMethod()
|
||||
protected open override /*1*/ /*fake_override*/ fun clone() : jet.Any?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ p0 : jet.Any?) : jet.Boolean
|
||||
protected open override /*1*/ /*fake_override*/ fun finalize() : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun getClass() : java.lang.Class<out jet.Any?>?
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode() : jet.Int
|
||||
public final override /*1*/ /*fake_override*/ fun notify() : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun notifyAll() : jet.Unit
|
||||
public open override /*1*/ fun toString() : jet.String?
|
||||
public final override /*1*/ /*fake_override*/ fun wait() : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long) : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long, /*1*/ p1 : jet.Int) : jet.Unit
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package test;
|
||||
|
||||
public interface InterfaceWithObjectMethods {
|
||||
int hashCode();
|
||||
boolean equals(Object obj);
|
||||
Object clone();
|
||||
String toString();
|
||||
void finalize();
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package test
|
||||
|
||||
public trait InterfaceWithObjectMethods : java.lang.Object {
|
||||
public abstract override /*1*/ fun clone() : jet.Any?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ p0 : jet.Any?) : jet.Boolean
|
||||
public abstract override /*1*/ fun finalize() : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun getClass() : java.lang.Class<out jet.Any?>?
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode() : jet.Int
|
||||
public final override /*1*/ /*fake_override*/ fun notify() : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun notifyAll() : jet.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString() : jet.String?
|
||||
public final override /*1*/ /*fake_override*/ fun wait() : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long) : jet.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun wait(/*0*/ p0 : jet.Long, /*1*/ p1 : jet.Int) : jet.Unit
|
||||
}
|
||||
@@ -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());
|
||||
|
||||
@@ -149,6 +149,7 @@ public class GenerateTests {
|
||||
"LoadJavaTestGenerated",
|
||||
AbstractLoadJavaTest.class,
|
||||
testModel("compiler/testData/loadJava/compiledJavaCompareWithKotlin", true, "java", "doTest"),
|
||||
testModel("compiler/testData/loadJava/compiledJavaIncludeObjectMethods", true, "java", "doTestCompiledJavaIncludeObjectMethods"),
|
||||
testModel("compiler/testData/loadJava/compiledJava", true, "java", "doTestCompiledJava"),
|
||||
testModel("compiler/testData/loadJava/sourceJava", true, "java", "doTestSourceJava"),
|
||||
testModel("compiler/testData/loadJava/javaAgainstKotlin", true, "txt", "doTestJavaAgainstKotlin")
|
||||
|
||||
Reference in New Issue
Block a user