changeset 7028:0353b031235a

added tests for instanceof with array types
author Doug Simon <doug.simon@oracle.com>
date Mon, 26 Nov 2012 18:20:34 +0100
parents 58dbea9fb973
children d918b5ba3e89
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java
diffstat 2 files changed, 52 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Mon Nov 26 16:51:43 2012 +0100
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Mon Nov 26 18:20:34 2012 +0100
@@ -257,6 +257,7 @@
             Assert.assertTrue("expected " + expect.exception, actual.exception != null);
             Assert.assertEquals(expect.exception.getClass(), actual.exception.getClass());
         } else {
+            //System.out.println(name + "(" + Arrays.toString(args) + "): expected=" + expect.returnValue + ", actual=" + actual.returnValue);
             assertEquals(expect.returnValue, actual.returnValue);
         }
     }
@@ -288,8 +289,13 @@
     protected InstalledCode getCode(final ResolvedJavaMethod method, final StructuredGraph graph, boolean forceCompile) {
         if (!forceCompile) {
             InstalledCode cached = cache.get(method);
-            if (cached != null && cached.isValid()) {
-                return cached;
+            if (cached != null) {
+                if (cached.isValid()) {
+                    return cached;
+                } else {
+                    //System.out.println(cached.getMethod() + " was invalidated");
+                }
+
             }
         }
         InstalledCode installedCode = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(compilationId++), true), new Callable<InstalledCode>() {
--- a/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java	Mon Nov 26 16:51:43 2012 +0100
+++ b/graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/InstanceOfTest.java	Mon Nov 26 18:20:34 2012 +0100
@@ -327,22 +327,63 @@
 
     abstract static class A {}
     static class B extends A {}
+    static class C extends B {}
+    abstract static class D extends C {}
 
     public static boolean isArrayOfA(Object o) {
         return o instanceof A[];
     }
 
     public static boolean isArrayOfB(Object o) {
-        return o instanceof A[];
+        return o instanceof B[];
+    }
+
+    public static boolean isArrayOfC(Object o) {
+        return o instanceof C[];
+    }
+
+    public static boolean isArrayOfD(Object o) {
+        return o instanceof D[];
     }
 
     @Test
     public void testArray() {
-        Object bArray = new A[10];
-        Object aArray = new B[10];
+        Object aArray = new A[10];
+        test("isArrayOfA", aArray);
+
+        Object bArray = new B[10];
         test("isArrayOfA", aArray);
         test("isArrayOfA", bArray);
         test("isArrayOfB", aArray);
         test("isArrayOfB", bArray);
+
+        Object cArray = new C[10];
+        test("isArrayOfA", aArray);
+        test("isArrayOfA", bArray);
+        test("isArrayOfA", cArray);
+        test("isArrayOfB", aArray);
+        test("isArrayOfB", bArray);
+        test("isArrayOfB", cArray);
+        test("isArrayOfC", aArray);
+        test("isArrayOfC", bArray);
+        test("isArrayOfC", cArray);
+
+        Object dArray = new D[10];
+        test("isArrayOfA", aArray);
+        test("isArrayOfA", bArray);
+        test("isArrayOfA", cArray);
+        test("isArrayOfA", dArray);
+        test("isArrayOfB", aArray);
+        test("isArrayOfB", bArray);
+        test("isArrayOfB", cArray);
+        test("isArrayOfB", dArray);
+        test("isArrayOfC", aArray);
+        test("isArrayOfC", bArray);
+        test("isArrayOfC", cArray);
+        test("isArrayOfC", dArray);
+        test("isArrayOfD", aArray);
+        test("isArrayOfD", bArray);
+        test("isArrayOfD", cArray);
+        test("isArrayOfD", dArray);
     }
 }