More test on array reflection arrays
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Tue, 15 Jan 2013 09:00:43 +0100
brancharrays
changeset 449c370708a2d17
parent 448 ac05de5a8786
child 450 f2891b169df3
More test on array reflection
vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java
     1.1 --- a/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Mon Jan 14 18:21:48 2013 +0100
     1.2 +++ b/vmtest/src/test/java/org/apidesign/bck2brwsr/tck/ReflectionTest.java	Tue Jan 15 09:00:43 2013 +0100
     1.3 @@ -115,6 +115,35 @@
     1.4          return (new String[3][4][5][6][7][8][9]).getClass().getName();
     1.5      }
     1.6      
     1.7 +    @Compare public String classForByte() throws Exception {
     1.8 +        return Class.forName("[Z").getName();
     1.9 +    }
    1.10 +    
    1.11 +    @Compare public String componentGetNameForObjectArray() {
    1.12 +        return (new Object[3]).getClass().getComponentType().getName();
    1.13 +    }
    1.14 +    @Compare public boolean sameComponentGetNameForObjectArray() {
    1.15 +        return (new Object[3]).getClass().getComponentType() == Object.class;
    1.16 +    }
    1.17 +    @Compare public String componentGetNameForSimpleIntArray() {
    1.18 +        return (new int[3]).getClass().getComponentType().getName();
    1.19 +    }
    1.20 +    @Compare public String componentGetNameForMultiIntArray() {
    1.21 +        return (new int[3][4][5][6][7][8][9]).getClass().getComponentType().getName();
    1.22 +    }
    1.23 +    @Compare public String componentGetNameForMultiStringArray() {
    1.24 +        Class<?> c = (new String[3][4][5][6][7][8][9]).getClass();
    1.25 +        StringBuilder sb = new StringBuilder();
    1.26 +        for (;;) {
    1.27 +            sb.append(c.getName()).append("\n");
    1.28 +            c = c.getComponentType();
    1.29 +            if (c == null) {
    1.30 +                break;
    1.31 +            }
    1.32 +        }
    1.33 +        return sb.toString();
    1.34 +    }
    1.35 +    
    1.36      @Compare public boolean isArray() {
    1.37          return new Object[0].getClass().isArray();
    1.38      }