aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2012-08-14 16:57:48 +0000
committerPekka Enberg <penberg@kernel.org>2012-08-14 16:59:41 +0000
commit57be06787adcdfbc01feacdc7195e6f614a80164 (patch)
treef23cbff8451f00237b5d9360b0207aef53a0600c
parente1c68efb093df34b96660820dca71a78e862c7e7 (diff)
downloadjato-57be06787adcdfbc01feacdc7195e6f614a80164.tar.gz
test/functional: Merge java/lang/reflect/Method test cases
There are two different test cases for java/lang/reflect/Method. Merge them to a single file. Signed-off-by: Pekka Enberg <penberg@kernel.org>
-rw-r--r--Makefile1
-rw-r--r--test/functional/java/lang/reflect/MethodTest.java128
-rw-r--r--test/functional/test/java/lang/reflect/MethodTest.java126
-rwxr-xr-xtools/test.py1
4 files changed, 122 insertions, 134 deletions
diff --git a/Makefile b/Makefile
index 732ee06f..467bcdf0 100644
--- a/Makefile
+++ b/Makefile
@@ -321,7 +321,6 @@ REGRESSION_TEST_SUITE_CLASSES = \
test/functional/jato/internal/VM.java \
test/functional/java/lang/JNITest.java \
test/functional/java/lang/reflect/ClassTest.java \
- test/functional/java/lang/reflect/MethodTest.java \
test/functional/jvm/ArgsTest.java \
test/functional/jvm/ArrayExceptionsTest.java \
test/functional/jvm/ArrayMemberTest.java \
diff --git a/test/functional/java/lang/reflect/MethodTest.java b/test/functional/java/lang/reflect/MethodTest.java
deleted file mode 100644
index 5ed73b78..00000000
--- a/test/functional/java/lang/reflect/MethodTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2009 Pekka Enberg
- *
- * This file is released under the GPL version 2 with the following
- * clarification and special exception:
- *
- * Linking this library statically or dynamically with other modules is
- * making a combined work based on this library. Thus, the terms and
- * conditions of the GNU General Public License cover the whole
- * combination.
- *
- * As a special exception, the copyright holders of this library give you
- * permission to link this library with independent modules to produce an
- * executable, regardless of the license terms of these independent
- * modules, and to copy and distribute the resulting executable under terms
- * of your choice, provided that you also meet, for each linked independent
- * module, the terms and conditions of the license of that module. An
- * independent module is a module which is not derived from or based on
- * this library. If you modify this library, you may extend this exception
- * to your version of the library, but you are not obligated to do so. If
- * you do not wish to do so, delete this exception statement from your
- * version.
- *
- * Please refer to the file LICENSE for details.
- */
-package java.lang.reflect;
-
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import jvm.TestCase;
-
-/**
- * @author Pekka Enberg
- */
-public class MethodTest extends TestCase {
- public static interface I {
- int x();
- }
-
- public static class A implements I {
- public int y() {
- return 0;
- }
-
- public int x() {
- return 1;
- }
- }
-
- private static void testMethodModifiers() throws Exception {
- assertEquals(Modifier.FINAL | Modifier.PUBLIC, modifiers("publicFinalInstanceMethod"));
- assertEquals(Modifier.STATIC | Modifier.PUBLIC, modifiers("publicClassMethod"));
- assertEquals(Modifier.PUBLIC, modifiers("publicInstanceMethod"));
- }
-
- private static int modifiers(String name) throws Exception {
- Method m = Klass.class.getMethod(name, new Class[] { });
- return m.getModifiers();
- }
-
- public static class Klass {
- public final void publicFinalInstanceMethod() { }
- public static void publicClassMethod() { }
- public void publicInstanceMethod() { }
-
- public static int intIncrement(int x) {
- return x + 1;
- }
-
- public static long longIncrement(long x) {
- return x + 1;
- }
-
- public static char charMirror(char x) {
- return x;
- }
-
- public static boolean boolMirror(boolean x) {
- return x;
- }
-
- public static void throwsMethod() throws Exception {
- }
- }
-
- public static Object invoke(String name, Class<?> arg_class, Object arg) {
- try {
- return Klass.class.getMethod(name, new Class[] { arg_class }).invoke(null, new Object[] { arg });
- } catch (Exception e) {
- fail();
- return null;
- }
- }
-
- public static void testMethodReflectionInvoke() {
- assertEquals(Integer.valueOf(2), invoke("intIncrement", int.class, Integer.valueOf(1)));
- assertEquals(Long.valueOf(0xdeadbeefcafebabfl), invoke("longIncrement", long.class, Long.valueOf(0xdeadbeefcafebabel)));
- assertEquals(Boolean.FALSE, invoke("boolMirror", boolean.class, Boolean.FALSE));
- assertEquals(Boolean.TRUE, invoke("boolMirror", boolean.class, Boolean.TRUE));
- assertEquals(Character.valueOf('x'), invoke("charMirror", char.class, Character.valueOf('x')));
- }
-
- public static void testInvokeOnInterfaceMethod() {
- A a = new A();
- Object result = null;
-
- try {
- Method xMethod = I.class.getMethod("x", new Class[0]);
- result = xMethod.invoke(a, new Object[0]);
- } catch (Exception e) {
- fail();
- }
-
- assertEquals(Integer.valueOf(1), result);
- }
-
- public static void testMethodGetExceptionTypes() throws Exception {
- Method m = Klass.class.getMethod("throwsMethod", new Class[] { });
- assertEquals(Arrays.<Class<?>>asList(Exception.class), Arrays.asList(m.getExceptionTypes()));
- }
-
- public static void main(String[] args) throws Exception {
- testMethodModifiers();
- testMethodReflectionInvoke();
- testInvokeOnInterfaceMethod();
- testMethodGetExceptionTypes();
- }
-}
diff --git a/test/functional/test/java/lang/reflect/MethodTest.java b/test/functional/test/java/lang/reflect/MethodTest.java
index e9c99c91..1d5ae2d0 100644
--- a/test/functional/test/java/lang/reflect/MethodTest.java
+++ b/test/functional/test/java/lang/reflect/MethodTest.java
@@ -1,11 +1,39 @@
-package test.java.lang.reflect;
+/*
+ * Copyright (C) 2009, 2012 Pekka Enberg
+ *
+ * This file is released under the GPL version 2 with the following
+ * clarification and special exception:
+ *
+ * Linking this library statically or dynamically with other modules is
+ * making a combined work based on this library. Thus, the terms and
+ * conditions of the GNU General Public License cover the whole
+ * combination.
+ *
+ * As a special exception, the copyright holders of this library give you
+ * permission to link this library with independent modules to produce an
+ * executable, regardless of the license terms of these independent
+ * modules, and to copy and distribute the resulting executable under terms
+ * of your choice, provided that you also meet, for each linked independent
+ * module, the terms and conditions of the license of that module. An
+ * independent module is a module which is not derived from or based on
+ * this library. If you modify this library, you may extend this exception
+ * to your version of the library, but you are not obligated to do so. If
+ * you do not wish to do so, delete this exception statement from your
+ * version.
+ *
+ * Please refer to the file LICENSE for details.
+ */
-import jvm.TestCase;
+package test.java.lang.reflect;
-import java.lang.reflect.Method;
+import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import jvm.TestCase;
public class MethodTest extends TestCase {
public static void testGetAnnotation() throws Exception {
@@ -167,7 +195,97 @@ public class MethodTest extends TestCase {
public @interface Tag2 { }
+ public static interface I {
+ int x();
+ }
+
+ public static class A implements I {
+ public int y() {
+ return 0;
+ }
+
+ public int x() {
+ return 1;
+ }
+ }
+
+ private static void testMethodModifiers() throws Exception {
+ assertEquals(Modifier.FINAL | Modifier.PUBLIC, modifiers("publicFinalInstanceMethod"));
+ assertEquals(Modifier.STATIC | Modifier.PUBLIC, modifiers("publicClassMethod"));
+ assertEquals(Modifier.PUBLIC, modifiers("publicInstanceMethod"));
+ }
+
+ private static int modifiers(String name) throws Exception {
+ Method m = Klass.class.getMethod(name, new Class[] { });
+ return m.getModifiers();
+ }
+
+ public static class Klass {
+ public final void publicFinalInstanceMethod() { }
+ public static void publicClassMethod() { }
+ public void publicInstanceMethod() { }
+
+ public static int intIncrement(int x) {
+ return x + 1;
+ }
+
+ public static long longIncrement(long x) {
+ return x + 1;
+ }
+
+ public static char charMirror(char x) {
+ return x;
+ }
+
+ public static boolean boolMirror(boolean x) {
+ return x;
+ }
+
+ public static void throwsMethod() throws Exception {
+ }
+ }
+
+ public static Object invoke(String name, Class<?> arg_class, Object arg) {
+ try {
+ return Klass.class.getMethod(name, new Class[] { arg_class }).invoke(null, new Object[] { arg });
+ } catch (Exception e) {
+ fail();
+ return null;
+ }
+ }
+
+ public static void testMethodReflectionInvoke() {
+ assertEquals(Integer.valueOf(2), invoke("intIncrement", int.class, Integer.valueOf(1)));
+ assertEquals(Long.valueOf(0xdeadbeefcafebabfl), invoke("longIncrement", long.class, Long.valueOf(0xdeadbeefcafebabel)));
+ assertEquals(Boolean.FALSE, invoke("boolMirror", boolean.class, Boolean.FALSE));
+ assertEquals(Boolean.TRUE, invoke("boolMirror", boolean.class, Boolean.TRUE));
+ assertEquals(Character.valueOf('x'), invoke("charMirror", char.class, Character.valueOf('x')));
+ }
+
+ public static void testInvokeOnInterfaceMethod() {
+ A a = new A();
+ Object result = null;
+
+ try {
+ Method xMethod = I.class.getMethod("x", new Class[0]);
+ result = xMethod.invoke(a, new Object[0]);
+ } catch (Exception e) {
+ fail();
+ }
+
+ assertEquals(Integer.valueOf(1), result);
+ }
+
+ public static void testMethodGetExceptionTypes() throws Exception {
+ Method m = Klass.class.getMethod("throwsMethod", new Class[] { });
+ assertEquals(Arrays.<Class<?>>asList(Exception.class), Arrays.asList(m.getExceptionTypes()));
+ }
+
public static void main(String[] args) throws Exception {
+ testMethodModifiers();
+ testMethodReflectionInvoke();
+ testInvokeOnInterfaceMethod();
+ testMethodGetExceptionTypes();
testGetAnnotation();
}
}
diff --git a/tools/test.py b/tools/test.py
index c1c2f310..ac868b36 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -29,7 +29,6 @@ TESTS = [
, ( "jvm/ArgsTest", 0, NO_SYSTEM_CLASSLOADER, [ "i386", "x86_64" ] )
, ( "java.lang.JNITest", 0, NO_SYSTEM_CLASSLOADER, [ "i386" ] )
, ( "java.lang.reflect.ClassTest", 0, NO_SYSTEM_CLASSLOADER, [ "i386", "x86_64" ] )
-, ( "java.lang.reflect.MethodTest", 0, NO_SYSTEM_CLASSLOADER, [ "i386", "x86_64" ] )
, ( "jvm.ArrayExceptionsTest", 0, NO_SYSTEM_CLASSLOADER, [ "i386", "x86_64" ] )
, ( "jvm.ArrayMemberTest", 0, NO_SYSTEM_CLASSLOADER, [ "i386", "x86_64" ] )
, ( "jvm.ArrayTest", 0, NO_SYSTEM_CLASSLOADER, [ "i386", "x86_64" ] )