instanceOf: test anonymous interface
authorBernhard Urban <lewurm@gmail.com>
Wed, 29 Aug 2012 10:53:15 +0000 (12:53 +0200)
committerBernhard Urban <lewurm@gmail.com>
Sun, 2 Sep 2012 08:09:51 +0000 (10:09 +0200)
tests/InstanceOf3.java

index 580f61553c401aeb2f5b0ccad7727b88eb626283..1fbe2060c28e5456f17ed2bc55b27b24de26356f 100644 (file)
@@ -6,6 +6,9 @@ public class InstanceOf3 {
        static interface i3 extends i2 { };
        static interface i4 extends i3 { };
        static interface i5 { };
+       static interface i6 extends i3 { };
+       static interface i7 extends i4, i6 { };
+       static interface i8 extends i2, i7 { };
        static class c1 { };
        static class c2 extends c1 implements i1 { };
        static class c3 extends c2 implements i4 { };
@@ -13,18 +16,35 @@ public class InstanceOf3 {
 
        public static void main(String []args) {
                Object x = new c3();
-               checkInstance(x instanceof i1, "x", "i1");
-               checkInstance(x instanceof i2, "x", "i2");
-               checkInstance(x instanceof i3, "x", "i3");
-               checkInstance(x instanceof i4, "x", "i4");
-               checkInstance(x instanceof i5, "x", "i5");
+               i2 y = new i3() { };
+               i6 z = new i6() { };
+               i7 u = new i7() { };
+               i8 v = new i8() { };
+
                checkInstance(x instanceof c1, "x", "c1");
                checkInstance(x instanceof c2, "x", "c2");
                checkInstance(x instanceof c3, "x", "c3");
                checkInstance(x instanceof c4, "x", "c4");
                checkInstance(x instanceof String, "x", "String");
                checkInstance(x instanceof Integer, "x", "Integer");
-               checkInstance(x instanceof Object, "x", "Object");
+
+               checkInterfaces(x, "x");
+               checkInterfaces(y, "y");
+               checkInterfaces(z, "z");
+               checkInterfaces(u, "u");
+               checkInterfaces(v, "v");
+       }
+
+       public static void checkInterfaces(Object y, String name) {
+               checkInstance(y instanceof Object, name, "Object");
+               checkInstance(y instanceof i1, name, "i1");
+               checkInstance(y instanceof i2, name, "i2");
+               checkInstance(y instanceof i3, name, "i3");
+               checkInstance(y instanceof i4, name, "i4");
+               checkInstance(y instanceof i5, name, "i5");
+               checkInstance(y instanceof i6, name, "i6");
+               checkInstance(y instanceof i7, name, "i7");
+               checkInstance(y instanceof i8, name, "i8");
        }
 
        public static void checkInstance(boolean cond, String obj, String classname) {