Moved compiledJava cases to generated test.

This commit is contained in:
Evgeny Gerashchenko
2013-03-06 16:44:57 +04:00
parent b109a104f1
commit e943b9c9ab
32 changed files with 949 additions and 858 deletions
@@ -1,5 +1,6 @@
package test; package test;
//TODO: move to LoadJavaTestGenerated when possible
public enum MyEnum { public enum MyEnum {
ENTRY, ENTRY,
ANOTHER; ANOTHER;
@@ -0,0 +1,21 @@
package test;
//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 sourceJava test data
public interface ReturnInnerSubclassOfSupersInner {
class Super<A> {
class Inner {
Super<A> get() {
throw new UnsupportedOperationException();
}
}
}
class Sub<B> extends Super<B> {
class Inner extends Super<B>.Inner {
Sub<B> get() {
throw new UnsupportedOperationException();
}
}
}
}
@@ -0,0 +1,22 @@
package test
public trait ReturnInnerSubclassOfSupersInner : java.lang.Object {
public open class Sub</*0*/ B> : test.ReturnInnerSubclassOfSupersInner.Super<B> {
public constructor Sub</*0*/ B>()
public/*package*/ open inner class Inner : test.ReturnInnerSubclassOfSupersInner.Super.Inner {
public/*package*/ constructor Inner()
public/*package*/ open override /*1*/ fun get() : test.ReturnInnerSubclassOfSupersInner.Sub<B>?
}
}
public open class Super</*0*/ A> : java.lang.Object {
public constructor Super</*0*/ A>()
public/*package*/ open inner class Inner : java.lang.Object {
public/*package*/ constructor Inner()
public/*package*/ open fun get() : test.ReturnInnerSubclassOfSupersInner.Super<A>?
}
}
}
@@ -69,7 +69,11 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
checkLoadedNamespaces(txtFile, kotlinNamespace, javaNamespaceAndContext.first, javaNamespaceAndContext.second); checkLoadedNamespaces(txtFile, kotlinNamespace, javaNamespaceAndContext.first, javaNamespaceAndContext.second);
} }
protected void doTestCompiledJava(@NotNull String expectedFileName, @NotNull String... javaFileNames) throws Exception { protected void doTestCompiledJava(@NotNull String javaFileName) throws Exception {
doTestCompiledJava(new File(javaFileName.replaceFirst("\\.java$", ".txt")), javaFileName);
}
protected void doTestCompiledJava(@NotNull File expectedFile, @NotNull String... javaFileNames) throws Exception {
JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea( JetTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
getTestRootDisposable(), ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK); getTestRootDisposable(), ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK);
@@ -79,7 +83,6 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
return new File(s); return new File(s);
} }
}); });
File expectedFile = new File(expectedFileName);
File tmpDir = JetTestUtils.tmpDir(expectedFile.getName()); File tmpDir = JetTestUtils.tmpDir(expectedFile.getName());
Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext
@@ -18,6 +18,8 @@ package org.jetbrains.jet.jvm.compiler;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.io.File;
/* /*
LoadJavaTestGenerated should be used instead if possible. LoadJavaTestGenerated should be used instead if possible.
*/ */
@@ -28,100 +30,11 @@ public final class LoadJavaCustomTest extends AbstractLoadJavaTest {
public void testPackageLocalVisibility() throws Exception { public void testPackageLocalVisibility() throws Exception {
String dir = PATH + "/packageLocalVisibility/simple/"; String dir = PATH + "/packageLocalVisibility/simple/";
String javaDir = dir + "/java"; String javaDir = dir + "/java";
doTestCompiledJava(dir + "/expected.txt", doTestCompiledJava(new File(dir + "/expected.txt"),
javaDir + "/test/JFrame.java", javaDir + "/test/JFrame.java",
javaDir + "/awt/Frame.java"); javaDir + "/awt/Frame.java");
} }
public void testInner() throws Exception {
doSimpleTest();
}
public void testProtectedStaticVisibility() throws Exception {
String dir = PATH + "/protectedStaticVisibility/constructor/";
doTestCompiledJava(dir + "ConstructorInProtectedStaticNestedClass.txt",
dir + "ConstructorInProtectedStaticNestedClass.java");
}
public void testProtectedPackageFun() throws Exception {
String dir = PATH + "/protectedPackageVisibility/";
doTestCompiledJava(dir + "ProtectedPackageFun.txt",
dir + "ProtectedPackageFun.java");
}
public void testProtectedPackageConstructor() throws Exception {
String dir = PATH + "/protectedPackageVisibility/";
doTestCompiledJava(dir + "ProtectedPackageConstructor.txt",
dir + "ProtectedPackageConstructor.java");
}
public void testProtectedPackageProperty() throws Exception {
String dir = PATH + "/protectedPackageVisibility/";
doTestCompiledJava(dir + "ProtectedPackageProperty.txt",
dir + "ProtectedPackageProperty.java");
}
public void testStaticFinal() throws Exception {
String dir = "/staticFinal/";
doTestCompiledJava(PATH + dir + "expected.txt",
PATH + dir + "test.java");
}
private void doSimpleTest() throws Exception {
doTestCompiledJava(PATH + "/" + getTestName(true) + ".txt",
PATH + "/" + getTestName(true) + ".java");
}
public void testKotlinSignatureTwoSuperclassesInconsistentGenericTypes() throws Exception {
String dir = PATH + "/kotlinSignature/";
doTestCompiledJava(dir + "TwoSuperclassesInconsistentGenericTypes.txt",
dir + "TwoSuperclassesInconsistentGenericTypes.java");
}
public void testKotlinSignatureTwoSuperclassesVarargAndNot() throws Exception {
String dir = PATH + "/kotlinSignature/";
doTestCompiledJava(dir + "TwoSuperclassesVarargAndNot.txt",
dir + "TwoSuperclassesVarargAndNot.java");
}
//TODO: move to LoadJavaTestGenerated when possible
public void testEnum() throws Exception {
String dir = PATH + "/enum";
String javaDir = dir + "/java";
doTestCompiledJava(dir + "/expected.txt",
javaDir + "/MyEnum.java");
}
public void testRawSuperType() throws Exception {
String dir = PATH + "/rawSuperType/";
doTestCompiledJava(dir + "RawSuperType.txt",
dir + "RawSuperType.java");
}
public void testSubclassWithRawType() throws Exception {
String dir = PATH + "/subclassWithRawType/";
doTestCompiledJava(dir + "SubclassWithRawType.txt",
dir + "SubclassWithRawType.java");
}
public void testArraysInSubtypes() throws Exception {
String dir = PATH + "/arraysInSubtypes/";
doTestCompiledJava(dir + "ArraysInSubtypes.txt",
dir + "ArraysInSubtypes.java");
}
public void testMethodTypeParameterErased() throws Exception {
String dir = PATH + "/methodTypeParameterErased/";
doTestCompiledJava(dir + "MethodTypeParameterErased.txt",
dir + "MethodTypeParameterErased.java");
}
public void testReturnInnerSubclassOfSupersInner() throws Exception {
String dir = PATH + "/returnInnerSubclassOfSupersInner/";
doTestCompiledJava(dir + "ReturnInnerSubclassOfSupersInner.txt",
dir + "test/ReturnInnerSubclassOfSupersInner.java");
}
public void testReturnInnerSubclassOfSupersInnerNoCompile() throws Exception { 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. // 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/"; String dir = PATH + "/returnInnerSubclassOfSupersInner/";
@@ -30,9 +30,11 @@ 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")
@TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin") @InnerTestClasses({LoadJavaTestGenerated.CompiledJavaCompareWithKotlin.class, LoadJavaTestGenerated.CompiledJava.class})
@InnerTestClasses({LoadJavaTestGenerated.Annotation.class, LoadJavaTestGenerated.Constructor.class, LoadJavaTestGenerated.JavaBean.class, LoadJavaTestGenerated.KotlinSignature.class, LoadJavaTestGenerated.Library.class, LoadJavaTestGenerated.Modality.class, LoadJavaTestGenerated.NotNull.class, LoadJavaTestGenerated.Vararg.class})
public class LoadJavaTestGenerated extends AbstractLoadJavaTest { 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})
public static class CompiledJavaCompareWithKotlin extends AbstractLoadJavaTest {
public void testAllFilesPresentInCompiledJavaCompareWithKotlin() throws Exception { public void testAllFilesPresentInCompiledJavaCompareWithKotlin() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJavaCompareWithKotlin"), Pattern.compile("^(.+)\\.java$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJavaCompareWithKotlin"), Pattern.compile("^(.+)\\.java$"), true);
} }
@@ -953,9 +955,9 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
} }
public static Test suite() { public static Test innerSuite() {
TestSuite suite = new TestSuite("LoadJavaTestGenerated"); TestSuite suite = new TestSuite("CompiledJavaCompareWithKotlin");
suite.addTestSuite(LoadJavaTestGenerated.class); suite.addTestSuite(CompiledJavaCompareWithKotlin.class);
suite.addTestSuite(Annotation.class); suite.addTestSuite(Annotation.class);
suite.addTestSuite(Constructor.class); suite.addTestSuite(Constructor.class);
suite.addTestSuite(JavaBean.class); suite.addTestSuite(JavaBean.class);
@@ -966,4 +968,132 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
suite.addTestSuite(Vararg.class); suite.addTestSuite(Vararg.class);
return suite; return suite;
} }
}
@TestMetadata("compiler/testData/loadJava/compiledJava")
@InnerTestClasses({CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.SignaturePropagation.class, CompiledJava.StaticFinal.class})
public static class CompiledJava extends AbstractLoadJavaTest {
public void testAllFilesPresentInCompiledJava() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("inner.java")
public void testInner() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/inner.java");
}
@TestMetadata("MyEnum.java")
public void testMyEnum() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/MyEnum.java");
}
@TestMetadata("compiler/testData/loadJava/compiledJava/protectedPackage")
public static class ProtectedPackage extends AbstractLoadJavaTest {
public void testAllFilesPresentInProtectedPackage() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/protectedPackage"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("ProtectedPackageConstructor.java")
public void testProtectedPackageConstructor() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/protectedPackage/ProtectedPackageConstructor.java");
}
@TestMetadata("ProtectedPackageFun.java")
public void testProtectedPackageFun() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/protectedPackage/ProtectedPackageFun.java");
}
@TestMetadata("ProtectedPackageProperty.java")
public void testProtectedPackageProperty() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/protectedPackage/ProtectedPackageProperty.java");
}
}
@TestMetadata("compiler/testData/loadJava/compiledJava/protectedStatic")
public static class ProtectedStatic extends AbstractLoadJavaTest {
public void testAllFilesPresentInProtectedStatic() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/protectedStatic"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("ConstructorInProtectedStaticNestedClass.java")
public void testConstructorInProtectedStaticNestedClass() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/protectedStatic/ConstructorInProtectedStaticNestedClass.java");
}
}
@TestMetadata("compiler/testData/loadJava/compiledJava/signaturePropagation")
public static class SignaturePropagation extends AbstractLoadJavaTest {
public void testAllFilesPresentInSignaturePropagation() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/signaturePropagation"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("ArraysInSubtypes.java")
public void testArraysInSubtypes() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/signaturePropagation/ArraysInSubtypes.java");
}
@TestMetadata("MethodTypeParameterErased.java")
public void testMethodTypeParameterErased() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/signaturePropagation/MethodTypeParameterErased.java");
}
@TestMetadata("RawSuperType.java")
public void testRawSuperType() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/signaturePropagation/RawSuperType.java");
}
@TestMetadata("ReturnInnerSubclassOfSupersInner.java")
public void testReturnInnerSubclassOfSupersInner() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/signaturePropagation/ReturnInnerSubclassOfSupersInner.java");
}
@TestMetadata("SubclassWithRawType.java")
public void testSubclassWithRawType() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/signaturePropagation/SubclassWithRawType.java");
}
@TestMetadata("TwoSuperclassesInconsistentGenericTypes.java")
public void testTwoSuperclassesInconsistentGenericTypes() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesInconsistentGenericTypes.java");
}
@TestMetadata("TwoSuperclassesVarargAndNot.java")
public void testTwoSuperclassesVarargAndNot() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/signaturePropagation/TwoSuperclassesVarargAndNot.java");
}
}
@TestMetadata("compiler/testData/loadJava/compiledJava/staticFinal")
public static class StaticFinal extends AbstractLoadJavaTest {
public void testAllFilesPresentInStaticFinal() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/staticFinal"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("test.java")
public void testTest() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/staticFinal/test.java");
}
}
public static Test innerSuite() {
TestSuite suite = new TestSuite("CompiledJava");
suite.addTestSuite(CompiledJava.class);
suite.addTestSuite(ProtectedPackage.class);
suite.addTestSuite(ProtectedStatic.class);
suite.addTestSuite(SignaturePropagation.class);
suite.addTestSuite(StaticFinal.class);
return suite;
}
}
public static Test suite() {
TestSuite suite = new TestSuite("LoadJavaTestGenerated");
suite.addTest(CompiledJavaCompareWithKotlin.innerSuite());
suite.addTest(CompiledJava.innerSuite());
return suite;
}
} }
@@ -147,7 +147,8 @@ public class GenerateTests {
"compiler/tests/", "compiler/tests/",
"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")
); );
generateTest( generateTest(