Reformat and cleanup most JVM codegen test classes

This commit is contained in:
Alexander Udalov
2019-03-29 14:56:35 +01:00
parent 23a214710b
commit 7fdb9c990e
43 changed files with 491 additions and 580 deletions
@@ -71,7 +71,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(getDeprecatedAnnotationFromList(srcClassMethod.getParameterAnnotations()[0]));
}
public void testAnnotationForParamInInstanceFunction() throws NoSuchFieldException, NoSuchMethodException {
public void testAnnotationForParamInInstanceFunction() throws NoSuchMethodException {
loadText("class A() { fun x(@[java.lang.Deprecated] i: Int) {}}");
Class<?> aClass = generateClass("A");
Method x = aClass.getMethod("x", int.class);
@@ -81,7 +81,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testAnnotationForParamInInstanceExtensionFunction() throws NoSuchFieldException, NoSuchMethodException {
public void testAnnotationForParamInInstanceExtensionFunction() throws NoSuchMethodException {
loadText("class A() { fun String.x(@[java.lang.Deprecated] i: Int) {}}");
Class<?> aClass = generateClass("A");
Method x = aClass.getMethod("x", String.class, int.class);
@@ -91,7 +91,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testParamInConstructor() throws NoSuchFieldException, NoSuchMethodException {
public void testParamInConstructor() throws NoSuchMethodException {
loadText("class A (@[java.lang.Deprecated] x: Int) {}");
Class<?> aClass = generateClass("A");
Constructor constructor = aClass.getDeclaredConstructor(int.class);
@@ -101,7 +101,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testParamInEnumConstructor() throws NoSuchFieldException, NoSuchMethodException {
public void testParamInEnumConstructor() throws NoSuchMethodException {
loadText("enum class E(@[java.lang.Deprecated] p: String)");
Class<?> klass = generateClass("E");
Constructor constructor = klass.getDeclaredConstructor(String.class, int.class, String.class);
@@ -111,7 +111,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(getDeprecatedAnnotationFromList(annotations));
}
public void testParamInInnerConstructor() throws NoSuchFieldException, NoSuchMethodException {
public void testParamInInnerConstructor() throws NoSuchMethodException {
loadText("class Outer { inner class Inner(@[java.lang.Deprecated] x: Int) }");
Class<?> outer = generateClass("Outer");
Class<?> inner = outer.getDeclaredClasses()[0];
@@ -134,7 +134,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNull(aClass.getDeclaredMethod("setX", int.class).getAnnotation(Deprecated.class));
assertNotNull(aClass.getDeclaredField("x").getAnnotation(Deprecated.class));
}
public void testAnnotationWithParamForParamInFunction() throws Exception {
loadText("import java.lang.annotation.*\n" +
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: String)\n" +
@@ -162,7 +162,7 @@ public class AnnotationGenTest extends CodegenTestCase {
}
}
return null;
}
}
public void testConstructor() throws NoSuchFieldException, NoSuchMethodException {
loadText("class A @[java.lang.Deprecated] constructor() {}");
@@ -196,14 +196,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertEquals("java.lang.annotation.Annotation", interfaces[0].getName());
}
public void testAnnotationClassWithStringProperty()
throws
NoSuchFieldException,
NoSuchMethodException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException,
InvocationTargetException {
public void testAnnotationClassWithStringProperty() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException {
loadText("import java.lang.annotation.*\n" +
"" +
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: String)\n" +
@@ -231,13 +224,7 @@ public class AnnotationGenTest extends CodegenTestCase {
}
public void testAnnotationClassWithAnnotationProperty()
throws
NoSuchFieldException,
NoSuchMethodException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException,
InvocationTargetException {
throws NoSuchMethodException, ClassNotFoundException, IllegalAccessException, InvocationTargetException {
loadText("import java.lang.annotation.*\n" +
"" +
"annotation class C(val c: String)\n" +
@@ -270,13 +257,7 @@ public class AnnotationGenTest extends CodegenTestCase {
}
public void testAnnotationClassWithStringArrayProperty()
throws
NoSuchFieldException,
NoSuchMethodException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException,
InvocationTargetException {
throws ClassNotFoundException, IllegalAccessException, InvocationTargetException {
loadText("import java.lang.annotation.*\n" +
"" +
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: Array<String>)\n" +
@@ -301,18 +282,11 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(bClassAnnotation);
Object invoke = methods[0].invoke(bClassAnnotation);
assertEquals("239", ((String[])invoke)[0]);
assertEquals("932", ((String[])invoke)[1]);
assertEquals("239", ((String[]) invoke)[0]);
assertEquals("932", ((String[]) invoke)[1]);
}
public void testAnnotationClassWithIntArrayProperty()
throws
NoSuchFieldException,
NoSuchMethodException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException,
InvocationTargetException {
public void testAnnotationClassWithIntArrayProperty() throws ClassNotFoundException, IllegalAccessException, InvocationTargetException {
loadText("import java.lang.annotation.*\n" +
"" +
"@java.lang.annotation.Retention(RetentionPolicy.RUNTIME) annotation class A(val a: IntArray)\n" +
@@ -337,18 +311,11 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(bClassAnnotation);
Object invoke = methods[0].invoke(bClassAnnotation);
assertEquals(239, ((int[])invoke)[0]);
assertEquals(932, ((int[])invoke)[1]);
assertEquals(239, ((int[]) invoke)[0]);
assertEquals(932, ((int[]) invoke)[1]);
}
public void testAnnotationClassWithEnumArrayProperty()
throws
NoSuchFieldException,
NoSuchMethodException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException,
InvocationTargetException {
public void testAnnotationClassWithEnumArrayProperty() {
loadText("import java.lang.annotation.*\n" +
"" +
"@java.lang.annotation.Target(ElementType.TYPE, ElementType.METHOD) annotation class A");
@@ -363,13 +330,7 @@ public class AnnotationGenTest extends CodegenTestCase {
}
public void testAnnotationClassWithAnnotationArrayProperty()
throws
NoSuchFieldException,
NoSuchMethodException,
ClassNotFoundException,
IllegalAccessException,
InstantiationException,
InvocationTargetException {
throws ClassNotFoundException, IllegalAccessException, InvocationTargetException {
loadText("import java.lang.annotation.*\n" +
"import java.lang.annotation.Retention\n" +
"" +
@@ -388,7 +349,7 @@ public class AnnotationGenTest extends CodegenTestCase {
assertNotNull(bClassAnnotation);
Object invoke = methods[0].invoke(bClassAnnotation);
Retention[] invoke1 = (Retention[])invoke;
Retention[] invoke1 = (Retention[]) invoke;
assertEquals(2, invoke1.length);
assertEquals(invoke1[0].value(), RetentionPolicy.RUNTIME);
assertEquals(invoke1[1].value(), RetentionPolicy.SOURCE);