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;
//TODO: move to LoadJavaTestGenerated when possible
public enum MyEnum {
ENTRY,
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);
}
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(
getTestRootDisposable(), ConfigurationKind.JDK_AND_ANNOTATIONS, TestJdkKind.MOCK_JDK);
@@ -79,7 +83,6 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
return new File(s);
}
});
File expectedFile = new File(expectedFileName);
File tmpDir = JetTestUtils.tmpDir(expectedFile.getName());
Pair<NamespaceDescriptor, BindingContext> javaNamespaceAndContext
@@ -18,6 +18,8 @@ package org.jetbrains.jet.jvm.compiler;
import org.jetbrains.annotations.NotNull;
import java.io.File;
/*
LoadJavaTestGenerated should be used instead if possible.
*/
@@ -28,100 +30,11 @@ public final class LoadJavaCustomTest extends AbstractLoadJavaTest {
public void testPackageLocalVisibility() throws Exception {
String dir = PATH + "/packageLocalVisibility/simple/";
String javaDir = dir + "/java";
doTestCompiledJava(dir + "/expected.txt",
doTestCompiledJava(new File(dir + "/expected.txt"),
javaDir + "/test/JFrame.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 {
// 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/";
File diff suppressed because it is too large Load Diff
@@ -147,7 +147,8 @@ public class GenerateTests {
"compiler/tests/",
"LoadJavaTestGenerated",
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(