1.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/Array.java Tue May 06 08:36:54 2014 +0200
1.2 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/Array.java Tue May 06 10:08:42 2014 +0200
1.3 @@ -115,9 +115,42 @@
1.4 }
1.5
1.6 public static boolean instanceOfArray(Object obj) {
1.7 + if ("string-array".equals(obj)) {
1.8 + obj = new String[] { "Ahoj" };
1.9 + }
1.10 return obj instanceof Object[];
1.11 }
1.12
1.13 + public static boolean castArray(int type) {
1.14 + try {
1.15 + Object orig = new Object();
1.16 + Object res = orig;
1.17 + if (type == 0) {
1.18 + Object[] arr = new Integer[1];
1.19 + String[] str = (String[]) arr;
1.20 + res = str;
1.21 + }
1.22 + if (type == 1) {
1.23 + Object[] arr = null;
1.24 + String[] str = (String[]) arr;
1.25 + res = str;
1.26 + }
1.27 + if (type == 2) {
1.28 + Object[] arr = new String[1];
1.29 + String[] str = (String[]) arr;
1.30 + res = str;
1.31 + }
1.32 + if (type == 3) {
1.33 + Object[] arr = new String[1];
1.34 + CharSequence[] str = (CharSequence[]) arr;
1.35 + res = str;
1.36 + }
1.37 + return res != orig;
1.38 + } catch (ClassCastException ex) {
1.39 + return false;
1.40 + }
1.41 + }
1.42 +
1.43 public static int sum(int size) {
1.44 int[] arr = new int[size];
1.45 return arr[0] + arr[1];