Moved all but one test cases from AnnotationJDRTest to loadJava.

This commit is contained in:
Evgeny Gerashchenko
2013-03-11 16:28:48 +04:00
parent b8abd0eb94
commit 0f5de451ec
11 changed files with 74 additions and 142 deletions
@@ -1,6 +1,4 @@
package annotations;
import java.lang.String;
package test;
@interface MyAnnotationWithParam {
MyAnnotation value();
@@ -1,4 +1,4 @@
package annotations;
package test;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@@ -1,4 +1,4 @@
package annotations;
package test;
import java.lang.String;
import java.lang.annotation.ElementType;
@@ -1,4 +1,4 @@
package annotations;
package test;
import java.lang.String;
import java.lang.annotation.ElementType;
@@ -1,4 +1,4 @@
package annotations;
package test;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -1,4 +1,4 @@
package annotations;
package test;
@MyAnnotation(MyEnum.ONE)
class MyTest {}
@@ -1,4 +1,4 @@
package annotations;
package test;
@MyAnnotation(first = "f", second = "s")
class MyTest {}
@@ -1,11 +1,11 @@
package annotations;
@B(@A("test"))
@interface A {
String value();
}
@B(@A("test"))
@interface B {
A value();
}
package test;
@B(@A("test"))
@interface A {
String value();
}
@B(@A("test"))
@interface B {
A value();
}
@@ -1,4 +1,4 @@
package annotations;
package test;
@interface A {
B value();
@@ -69,126 +69,6 @@ public class AnnotationJavaDescriptorResolverTest extends AbstractJavaResolverDe
checkSimpleCompileTimeConstant(actualCompileTimeConstant, DEFAULT_PACKAGE + ".MyEnum", "MyEnum.ONE");
}
public void testCustomAnnotation() throws IOException {
compileJavaFile("customAnnotation.java", null);
String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation";
AnnotationDescriptor annotation = getAnnotationInClassByType("MyTest", annotationTypeName);
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
checkSimpleCompileTimeConstant(actualCompileTimeConstant, DEFAULT_PACKAGE + ".MyEnum", "MyEnum.ONE");
}
public void testCustomAnnotationWithDefaultParameter() throws IOException {
compileJavaFile("customAnnotationWithDefaultParameter.java", null);
String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation";
AnnotationDescriptor annotation = getAnnotationInClassByType("MyTest", annotationTypeName);
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "first");
checkSimpleCompileTimeConstant(actualCompileTimeConstant, "jet.String", "\"f\"");
actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "second");
checkSimpleCompileTimeConstant(actualCompileTimeConstant, "jet.String", "\"s\"");
}
public void testAnnotationWithAnnotationInParam() throws IOException {
compileJavaFile("annotationWithAnnotationInParam.java", null);
String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotationWithParam";
AnnotationDescriptor annotation = getAnnotationInClassByType("A",
annotationTypeName);
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
assert actualCompileTimeConstant instanceof AnnotationValue;
checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value",
DEFAULT_PACKAGE + ".MyAnnotation", "jet.String", "\"test\"");
String annotationTypeName2 = DEFAULT_PACKAGE + ".MyAnnotationWithParam2";
AnnotationDescriptor annotation2 = getAnnotationInClassByType("B", annotationTypeName2);
actualCompileTimeConstant = getCompileTimeConstant(annotation2, annotationTypeName2, "value");
assert actualCompileTimeConstant instanceof AnnotationValue;
checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value",
DEFAULT_PACKAGE + ".MyAnnotation2", "jet.Array<jet.String>?", "[\"test\", \"test2\"]");
String annotationTypeName3 = DEFAULT_PACKAGE + ".MyAnnotationWithParam3";
AnnotationDescriptor annotation3 = getAnnotationInClassByType("C", annotationTypeName3);
actualCompileTimeConstant = getCompileTimeConstant(annotation3, annotationTypeName3, "value");
assert actualCompileTimeConstant instanceof AnnotationValue;
checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "first",
DEFAULT_PACKAGE + ".MyAnnotation3", "jet.String", "\"f\"");
checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "second",
DEFAULT_PACKAGE + ".MyAnnotation3", "jet.String", "\"s\"");
}
public void testRecursiveAnnotation() throws IOException {
compileJavaFile("recursiveAnnotation.java", null);
String annotationTypeName = DEFAULT_PACKAGE + ".B";
AnnotationDescriptor annotation = getAnnotationInClassByType("A", annotationTypeName);
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
assert actualCompileTimeConstant instanceof AnnotationValue;
checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value",
DEFAULT_PACKAGE + ".A", "jet.String", "\"test\"");
AnnotationDescriptor annotation2 = getAnnotationInClassByType("B", annotationTypeName);
actualCompileTimeConstant = getCompileTimeConstant(annotation2, annotationTypeName, "value");
assert actualCompileTimeConstant instanceof AnnotationValue;
checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value",
DEFAULT_PACKAGE + ".A", "jet.String", "\"test\"");
}
public void testRecursiveAnnotation2() throws IOException {
compileJavaFile("recursiveAnnotation2.java", null);
String annotationTypeName = DEFAULT_PACKAGE + ".A";
AnnotationDescriptor annotation = getAnnotationInClassByType("B", annotationTypeName);
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
assert actualCompileTimeConstant instanceof AnnotationValue;
checkAnnotationCompileTimeConstant((AnnotationValue) actualCompileTimeConstant, "value",
DEFAULT_PACKAGE + ".B", "jet.String", "\"test\"");
}
public void testAnnotationWithEnumInParam() throws IOException {
compileJavaFile("annotationWithEnumInParam.java", null);
String annotationTypeName = "java.lang.annotation.Retention";
AnnotationDescriptor annotation = getAnnotationInClassByType("retentionAnnotation", annotationTypeName);
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
checkSimpleCompileTimeConstant(actualCompileTimeConstant, "java.lang.annotation.RetentionPolicy", "RetentionPolicy.RUNTIME");
}
public void testAnnotationWithArrayOfEnumInParam() throws IOException {
compileJavaFile("annotationWithArrayOfEnumInParam.java", null);
String annotationTypeName = "java.lang.annotation.Target";
AnnotationDescriptor annotation = getAnnotationInClassByType("targetAnnotation", annotationTypeName);
assertEquals("Number of arguments is incorrect", 1, annotation.getAllValueArguments().size());
String[] values = new String[] {"ElementType.FIELD", "ElementType.CONSTRUCTOR"};
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
assert actualCompileTimeConstant instanceof ArrayValue;
checkArrayCompileTimeConstant((ArrayValue) actualCompileTimeConstant, "jet.Array<java.lang.annotation.ElementType>?",
"java.lang.annotation.ElementType", values);
}
public void testAnnotationWithArrayOfStringInParam() throws IOException {
compileJavaFile("annotationWithArrayOfStringInParam.java", null);
String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation";
AnnotationDescriptor annotation = getAnnotationInClassByType("A", annotationTypeName);
assertEquals("Number of arguments is incorrect", 1, annotation.getAllValueArguments().size());
String[] values = new String[] {"\"a\"", "\"b\"", "\"c\""};
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
assert actualCompileTimeConstant instanceof ArrayValue;
checkArrayCompileTimeConstant((ArrayValue) actualCompileTimeConstant, "jet.Array<jet.String>?", "jet.String", values);
}
public void testAnnotationWithEmptyArrayInParam() throws IOException {
compileJavaFile("annotationWithEmptyArrayInParam.java", null);
String annotationTypeName = DEFAULT_PACKAGE + ".MyAnnotation";
AnnotationDescriptor annotation = getAnnotationInClassByType("A", annotationTypeName);
assertEquals("Number of arguments is incorrect", 1, annotation.getAllValueArguments().size());
String[] values = new String[] {};
CompileTimeConstant<?> actualCompileTimeConstant = getCompileTimeConstant(annotation, annotationTypeName, "value");
assert actualCompileTimeConstant instanceof ArrayValue;
checkArrayCompileTimeConstant((ArrayValue) actualCompileTimeConstant, "jet.Array<jet.String>?", "jet.String", values);
}
private static void compareJetTypeWithClass(@NotNull JetType actualType, @NotNull String expectedType) {
assertEquals(expectedType, DescriptorRenderer.TEXT.renderType(actualType));
}
@@ -971,7 +971,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
}
@TestMetadata("compiler/testData/loadJava/compiledJava")
@InnerTestClasses({CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.SignaturePropagation.class, CompiledJava.Static.class})
@InnerTestClasses({CompiledJava.Annotations.class, CompiledJava.ProtectedPackage.class, CompiledJava.ProtectedStatic.class, CompiledJava.SignaturePropagation.class, CompiledJava.Static.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);
@@ -987,6 +987,59 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/SubclassFromNested.java");
}
@TestMetadata("compiler/testData/loadJava/compiledJava/annotations")
public static class Annotations extends AbstractLoadJavaTest {
public void testAllFilesPresentInAnnotations() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/loadJava/compiledJava/annotations"), Pattern.compile("^(.+)\\.java$"), true);
}
@TestMetadata("AnnotationWithAnnotationInParam.java")
public void testAnnotationWithAnnotationInParam() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithAnnotationInParam.java");
}
@TestMetadata("AnnotationWithArrayOfEnumInParam.java")
public void testAnnotationWithArrayOfEnumInParam() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfEnumInParam.java");
}
@TestMetadata("AnnotationWithArrayOfStringInParam.java")
public void testAnnotationWithArrayOfStringInParam() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithArrayOfStringInParam.java");
}
@TestMetadata("AnnotationWithEmptyArrayInParam.java")
public void testAnnotationWithEmptyArrayInParam() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEmptyArrayInParam.java");
}
@TestMetadata("AnnotationWithEnumInParam.java")
public void testAnnotationWithEnumInParam() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/AnnotationWithEnumInParam.java");
}
@TestMetadata("CustomAnnotation.java")
public void testCustomAnnotation() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/CustomAnnotation.java");
}
@TestMetadata("CustomAnnotationWithDefaultParameter.java")
public void testCustomAnnotationWithDefaultParameter() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/CustomAnnotationWithDefaultParameter.java");
}
@TestMetadata("RecursiveAnnotation.java")
public void testRecursiveAnnotation() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation.java");
}
@TestMetadata("RecursiveAnnotation2.java")
public void testRecursiveAnnotation2() throws Exception {
doTestCompiledJava("compiler/testData/loadJava/compiledJava/annotations/RecursiveAnnotation2.java");
}
}
@TestMetadata("compiler/testData/loadJava/compiledJava/protectedPackage")
public static class ProtectedPackage extends AbstractLoadJavaTest {
public void testAllFilesPresentInProtectedPackage() throws Exception {
@@ -1102,6 +1155,7 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
public static Test innerSuite() {
TestSuite suite = new TestSuite("CompiledJava");
suite.addTestSuite(CompiledJava.class);
suite.addTestSuite(Annotations.class);
suite.addTestSuite(ProtectedPackage.class);
suite.addTestSuite(ProtectedStatic.class);
suite.addTestSuite(SignaturePropagation.class);