1.1 --- a/emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js Mon Dec 31 17:50:27 2012 +0100
1.2 +++ b/emul/src/main/resources/org/apidesign/vm4brwsr/emul/java_lang_String.js Thu Jan 03 09:14:57 2013 +0100
1.3 @@ -6,4 +6,11 @@
1.4 for(var i = 0; i < this.length; i++) this[i] = null;
1.5 return this;
1.6 };
1.7 -
1.8 +Array.prototype.clone__Ljava_lang_Object_2 = function() {
1.9 + var s = this.length;
1.10 + var ret = new Array(s);
1.11 + for (var i = 0; i < s; i++) {
1.12 + ret[i] = this[i];
1.13 + }
1.14 + return ret;
1.15 +};
2.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/Array.java Mon Dec 31 17:50:27 2012 +0100
2.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/Array.java Thu Jan 03 09:14:57 2013 +0100
2.3 @@ -82,11 +82,17 @@
2.4 }
2.5 return sum;
2.6 }
2.7 - public static int simple() {
2.8 - int[] arr = { 0, 1, 2, 3, 4, 5 };
2.9 + private static final int[] arr = { 0, 1, 2, 3, 4, 5 };
2.10 + public static int simple(boolean clone) {
2.11 + int[] ar;
2.12 + if (clone) {
2.13 + ar = arr.clone();
2.14 + } else {
2.15 + ar = arr;
2.16 + }
2.17
2.18 int sum = 0;
2.19 - for (int a : arr) {
2.20 + for (int a : ar) {
2.21 sum += a;
2.22 }
2.23 return sum;
3.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/ArrayTest.java Mon Dec 31 17:50:27 2012 +0100
3.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/ArrayTest.java Thu Jan 03 09:14:57 2013 +0100
3.3 @@ -18,7 +18,6 @@
3.4 package org.apidesign.vm4brwsr;
3.5
3.6 import javax.script.Invocable;
3.7 -import javax.script.ScriptException;
3.8 import static org.testng.Assert.*;
3.9 import org.testng.annotations.BeforeClass;
3.10 import org.testng.annotations.Test;
3.11 @@ -29,8 +28,14 @@
3.12 */
3.13 public class ArrayTest {
3.14 @Test public void verifySimpleIntOperation() throws Exception {
3.15 - assertExec("CheckTheSum", Array.class, "simple__I",
3.16 - Double.valueOf(15)
3.17 + assertExec("CheckTheSum", Array.class, "simple__IZ",
3.18 + Double.valueOf(15), false
3.19 + );
3.20 + }
3.21 +
3.22 + @Test public void cloneOnArray() throws Exception {
3.23 + assertExec("CheckTheSum on clone", Array.class, "simple__IZ",
3.24 + Double.valueOf(15), true
3.25 );
3.26 }
3.27