Moved sourceJava cases to generated test.

This commit is contained in:
Evgeny Gerashchenko
2013-03-07 14:37:10 +04:00
parent b96df65733
commit a0b780c7bb
12 changed files with 43 additions and 21 deletions
@@ -1,6 +1,8 @@
package test; package test;
//Note: this test could be written in simple load java test, but KT-3128 prevents from writing Kotlin counterpart for it //Note: this test could be written in simple load java test, but KT-3128 prevents from writing Kotlin counterpart for it
//See the same test data in compiledJava test data.
//Test data is duplicated because Java PSI used to have some differences when loading parallel generic hierarchies from cls and source code.
public interface ReturnInnerSubclassOfSupersInner { public interface ReturnInnerSubclassOfSupersInner {
class Super<A> { class Super<A> {
class Inner { class Inner {
@@ -18,6 +18,7 @@ package org.jetbrains.jet.jvm.compiler;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.PsiFile; import com.intellij.psi.PsiFile;
import com.intellij.util.Function; import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil; import com.intellij.util.containers.ContainerUtil;
@@ -89,11 +90,16 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second); checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second);
} }
protected void doTestSourceJava(@NotNull String expectedFileName, @NotNull String javaRoot) throws Exception { protected void doTestSourceJava(@NotNull String javaFileName) throws Exception {
File expectedFile = new File(expectedFileName); File originalJavaFile = new File(javaFileName);
File expectedFile = new File(javaFileName.replaceFirst("\\.java$", ".txt"));
File testPackageDir = new File(tmpdir, "test");
assertTrue(testPackageDir.mkdir());
FileUtil.copy(originalJavaFile, new File(testPackageDir, originalJavaFile.getName()));
Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext = loadTestNamespaceAndBindingContextFromJavaRoot( Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext = loadTestNamespaceAndBindingContextFromJavaRoot(
new File(javaRoot), getTestRootDisposable(), ConfigurationKind.JDK_ONLY); tmpdir, getTestRootDisposable(), ConfigurationKind.JDK_ONLY);
checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second); checkJavaNamespace(expectedFile, javaNamespaceAndContext.first, javaNamespaceAndContext.second);
} }
@@ -35,22 +35,6 @@ public final class LoadJavaCustomTest extends AbstractLoadJavaTest {
javaDir + "/awt/Frame.java"); javaDir + "/awt/Frame.java");
} }
public void testReturnInnerSubclassOfSupersInnerNoCompile() throws Exception {
// Test is here because Java PSI used to have some differences when loading parallel generic hierarchies from cls and source code.
String dir = PATH + "/returnInnerSubclassOfSupersInner/";
doTestSourceJava(dir + "ReturnInnerSubclassOfSupersInner.txt", dir);
}
public void testReturnNotSubtype() throws Exception {
String dir = PATH + "/returnNotSubtype/";
doTestSourceJava(dir + "ReturnNotSubtype.txt", dir);
}
public void testErrorTypes() throws Exception {
String dir = PATH + "/errorTypes/";
doTestSourceJava(dir + "ErrorTypes.txt", dir);
}
public static class SubclassingKotlinInJavaTest extends AbstractLoadJavaTest { public static class SubclassingKotlinInJavaTest extends AbstractLoadJavaTest {
public void testSubclassingKotlinInJava() throws Exception { public void testSubclassingKotlinInJava() throws Exception {
doTestJavaAgainstKotlin(PATH + "/" + getTestName(true)); doTestJavaAgainstKotlin(PATH + "/" + getTestName(true));
@@ -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 */ /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all") @SuppressWarnings("all")
@InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJava.class}) @InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJava.class, LoadJavaTestGenerated.SourceJava.class})
public class LoadJavaTestGenerated extends AbstractLoadJavaTest { public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
@TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin") @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}) @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})
@@ -1090,10 +1090,39 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
} }
} }
@TestMetadata("compiler/testData/loadJava/sourceJava")
public static class SourceJava extends AbstractLoadJavaTest {
public void testAllFilesPresentInSourceJava() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/sourceJava"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("ErrorTypes.java")
public void testErrorTypes() throws Exception {
doTestSourceJava("compiler/testData/loadJava/sourceJava/ErrorTypes.java");
}
@TestMetadata("ReturnInnerSubclassOfSupersInner.java")
public void testReturnInnerSubclassOfSupersInner() throws Exception {
doTestSourceJava("compiler/testData/loadJava/sourceJava/ReturnInnerSubclassOfSupersInner.java");
}
@TestMetadata("ReturnNotSubtype.java")
public void testReturnNotSubtype() throws Exception {
doTestSourceJava("compiler/testData/loadJava/sourceJava/ReturnNotSubtype.java");
}
@TestMetadata("WrongNumberOfGenericParameters.java")
public void testWrongNumberOfGenericParameters() throws Exception {
doTestSourceJava("compiler/testData/loadJava/sourceJava/WrongNumberOfGenericParameters.java");
}
}
public static Test suite() { public static Test suite() {
TestSuite suite = new TestSuite("LoadJavaTestGenerated"); TestSuite suite = new TestSuite("LoadJavaTestGenerated");
suite.addTest(CompiledJavaCompareWithKotlin.innerSuite()); suite.addTest(CompiledJavaCompareWithKotlin.innerSuite());
suite.addTest(CompiledJava.innerSuite()); suite.addTest(CompiledJava.innerSuite());
suite.addTestSuite(SourceJava.class);
return suite; return suite;
} }
} }
@@ -148,7 +148,8 @@ public class GenerateTests {
"LoadJavaTestGenerated", "LoadJavaTestGenerated",
AbstractLoadJavaTest.class, AbstractLoadJavaTest.class,
testModel("compiler/testData/loadJava/compiledJavaCompareWithKotlin", true, "java", "doTest"), testModel("compiler/testData/loadJava/compiledJavaCompareWithKotlin", true, "java", "doTest"),
testModel("compiler/testData/loadJava/compiledJava", true, "java", "doTestCompiledJava") testModel("compiler/testData/loadJava/compiledJava", true, "java", "doTestCompiledJava"),
testModel("compiler/testData/loadJava/sourceJava", true, "java", "doTestSourceJava")
); );
generateTest( generateTest(