From: Bernhard Urban Date: Wed, 29 Aug 2012 10:53:15 +0000 (+0200) Subject: instanceOf: test anonymous interface X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mate.git;a=commitdiff_plain;h=1e63f480bc9f7fe5808cd903670a315a9bc178fd instanceOf: test anonymous interface --- diff --git a/tests/InstanceOf3.java b/tests/InstanceOf3.java index 580f615..1fbe206 100644 --- a/tests/InstanceOf3.java +++ b/tests/InstanceOf3.java @@ -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) {