# HG changeset patch # User Martin Soch # Date 1381323029 -7200 # Node ID 7bc78045adfda5cea1c0d38a80013b164f9640c9 # Parent f73c1a0234fb9c494081a744b36924614e11911a Fix for bug 5408, error in shift operations on Long. diff -r f73c1a0234fb -r 7bc78045adfd rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java Mon Oct 07 14:20:58 2013 +0200 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/EnumsTest.java Wed Oct 09 14:50:29 2013 +0200 @@ -1,3 +1,20 @@ +/** + * Back 2 Browser Bytecode Translator + * Copyright (C) 2012 Jaroslav Tulach + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. Look for COPYING file in the top folder. + * If not, see http://opensource.org/licenses/GPL-2.0. + */ package org.apidesign.bck2brwsr.tck; import java.util.EnumMap; @@ -15,7 +32,6 @@ B, W; } - /* @Compare public String enumSet() { try { throw new Exception(); } catch (Exception ex) {} EnumSet c = EnumSet.allOf(Color.class); @@ -26,7 +42,6 @@ EnumSet c = EnumSet.of(Color.B, Color.W); return c.toString(); } - */ @Compare public boolean enumFirstContains() { EnumSet c = EnumSet.of(Color.B); diff -r f73c1a0234fb -r 7bc78045adfd rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java --- a/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java Mon Oct 07 14:20:58 2013 +0200 +++ b/rt/emul/compact/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java Wed Oct 09 14:50:29 2013 +0200 @@ -304,6 +304,14 @@ @Compare public long shiftL3() { return shl(0x00fa37d7763e0ca1l, 45); } + + @Compare public long shiftL4() { + return shl(0x00fa37d7763e0ca1l, 0); + } + + @Compare public long shiftL5() { + return shl(0x00fa37d7763e0ca1l, 70); + } @Compare public long shiftR1() { return shr(0x00fa37d7763e0ca1l, 5); @@ -316,6 +324,14 @@ @Compare public long shiftR3() { return shr(0x00fa37d7763e0ca1l, 45); } + + @Compare public long shiftR4() { + return shr(0x00fa37d7763e0ca1l, 0); + } + + @Compare public long shiftR5() { + return shr(0x00fa37d7763e0ca1l, 70); + } @Compare public long uShiftR1() { return ushr(0x00fa37d7763e0ca1l, 5); @@ -324,14 +340,30 @@ @Compare public long uShiftR2() { return ushr(0x00fa37d7763e0ca1l, 45); } + + @Compare public long uShiftR3() { + return ushr(0x00fa37d7763e0ca1l, 0); + } + + @Compare public long uShiftR4() { + return ushr(0x00fa37d7763e0ca1l, 70); + } - @Compare public long uShiftR3() { + @Compare public long uShiftR5() { return ushr(0xf0fa37d7763e0ca1l, 5); } - @Compare public long uShiftR4() { + @Compare public long uShiftR6() { return ushr(0xf0fa37d7763e0ca1l, 45); } + + @Compare public long uShiftR7() { + return ushr(0xf0fa37d7763e0ca1l, 0); + } + + @Compare public long uShiftR8() { + return ushr(0xf0fa37d7763e0ca1l, 70); + } @Compare public long and1() { return and(0x00fa37d7763e0ca1l, 0xa7b3432fff00123el); diff -r f73c1a0234fb -r 7bc78045adfd rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js --- a/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Mon Oct 07 14:20:58 2013 +0200 +++ b/rt/emul/mini/src/main/resources/org/apidesign/vm4brwsr/emul/lang/java_lang_Number.js Wed Oct 09 14:50:29 2013 +0200 @@ -176,6 +176,8 @@ }; numberPrototype.shl64 = function(x) { + x &= 0x3f; + if (x == 0) return this; if (x >= 32) { var hi = this << (x - 32); return hi.next32(0); @@ -190,6 +192,8 @@ }; numberPrototype.shr64 = function(x) { + x &= 0x3f; + if (x == 0) return this; if (x >= 32) { var low = this.high32() >> (x - 32); low += (low < 0) ? (__m32 + 1) : 0; @@ -205,6 +209,8 @@ }; numberPrototype.ushr64 = function(x) { + x &= 0x3f; + if (x == 0) return this; if (x >= 32) { var low = this.high32() >>> (x - 32); low += (low < 0) ? (__m32 + 1) : 0;