1.1 --- a/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/CollectionsTest.java Sat Dec 27 20:38:32 2014 +0100
1.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/compact/tck/CollectionsTest.java Wed Jan 07 14:17:22 2015 +0100
1.3 @@ -113,6 +113,20 @@
1.4 Arrays.toString(ret);
1.5 }
1.6
1.7 + @Compare public int collectionsShuffle() {
1.8 + ArrayList<Integer> positions = new ArrayList<>();
1.9 + for (int i = 0; i < 16; i++) {
1.10 + positions.add(i);
1.11 + }
1.12 + Collections.shuffle(positions);
1.13 +
1.14 + int sum = 0;
1.15 + for (Integer p : positions) {
1.16 + sum += p;
1.17 + }
1.18 + return sum;
1.19 + }
1.20 +
1.21 @Factory
1.22 public static Object[] create() {
1.23 return VMTest.create(CollectionsTest.class);
2.1 --- a/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java Sat Dec 27 20:38:32 2014 +0100
2.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java Wed Jan 07 14:17:22 2015 +0100
2.3 @@ -38,7 +38,7 @@
2.4 private static long mul(long x, long y) {
2.5 return (x * y);
2.6 }
2.7 -
2.8 +
2.9 private static long div(long x, long y) {
2.10 return (x / y);
2.11 }
2.12 @@ -82,6 +82,14 @@
2.13 private static double dadd(double x, double y) {
2.14 return x + y;
2.15 }
2.16 +
2.17 + private static long mul64shr64(long base, int mul, int shr) {
2.18 + long tmp = base * mul;
2.19 + if (shr == -1) {
2.20 + return tmp;
2.21 + }
2.22 + return tmp >> shr;
2.23 + }
2.24
2.25 public static int compare(long x, long y, int zero) {
2.26 final int xyResult = compareL(x, y, zero);
2.27 @@ -411,6 +419,21 @@
2.28 return compare(0x8000000000000000l, 0x7fffffffffffffffl, 0);
2.29 }
2.30
2.31 + @Compare public int intConversionProblemInRandom() {
2.32 + long res = mul64shr64(16, 1561751147, 31);
2.33 + return (int) res;
2.34 + }
2.35 +
2.36 + @Compare public long shiftProblemInRandom() {
2.37 + long res = mul64shr64(16, 1561751147, 31);
2.38 + return res;
2.39 + }
2.40 +
2.41 + @Compare public long multiplyProblemInRandom() {
2.42 + long res = mul64shr64(16, 1561751147, -1);
2.43 + return res;
2.44 + }
2.45 +
2.46 @Factory
2.47 public static Object[] create() {
2.48 return VMTest.create(LongArithmeticTest.class);
3.1 --- a/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Sat Dec 27 20:38:32 2014 +0100
3.2 +++ b/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Wed Jan 07 14:17:22 2015 +0100
3.3 @@ -199,7 +199,7 @@
3.4 low += (low < 0) ? (__m32 + 1) : 0;
3.5 return low;
3.6 } else {
3.7 - var low = this >> x;
3.8 + var low = this >>> x;
3.9 var hi_reminder = this.high32() << (32 - x);
3.10 low |= hi_reminder;
3.11 low += (low < 0) ? (__m32 + 1) : 0;