# HG changeset patch # User Jaroslav Tulach # Date 1392577563 -3600 # Node ID ef506621d1eed1ec610499ccfd2bb07a13bd833f # Parent 3ec3ae9699ef2c4fc9a7bd3459364f5aac7a322b More tests of the bit operations on longs diff -r 3ec3ae9699ef -r ef506621d1ee rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Fri Feb 07 10:03:44 2014 +0100 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Sun Feb 16 20:06:03 2014 +0100 @@ -77,16 +77,22 @@ new byte[] { (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)13, (byte)126 } ); } - /* XXX: JavaScript cannot represent as big longs as Java. + @Test public void deserializeMiddleLong() throws Exception { + final byte[] arr = new byte[] { + (byte)0, (byte)0, (byte)64, (byte)32, (byte)23, (byte)0, (byte)0, (byte)0 + }; + long exp = Numbers.deserLong(arr, 16); + assertExec("Should be " + exp, Numbers.class, "deserLong__J_3BI", + Double.valueOf(exp), arr, 16); + } @Test public void deserializeLargeLong() throws Exception { final byte[] arr = new byte[] { (byte)64, (byte)8, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0 }; - long exp = Numbers.deserLong(arr); - assertExec("Should be " + exp, "org_apidesign_vm4brwsr_Numbers_deserLong__JAB", - Double.valueOf(exp), arr); + long exp = Numbers.deserLong(arr, 32); + assertExec("Should be " + exp, Numbers.class, "deserLong__J_3BI", + Double.valueOf(exp), arr, 32); } - */ @Test public void deserializeFloatInJava() throws Exception { float f = 54324.32423f; diff -r 3ec3ae9699ef -r ef506621d1ee rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java Fri Feb 07 10:03:44 2014 +0100 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java Sun Feb 16 20:06:03 2014 +0100 @@ -55,6 +55,9 @@ DataInputStream dis = new DataInputStream(is); return dis.readLong(); } + static long deserLong(byte[] arr, int shift) throws IOException { + return deserLong(arr) >> shift; + } static int deserInt() throws IOException { byte[] arr = {(byte) 71, (byte) 84, (byte) 52, (byte) 83}; ByteArrayInputStream is = new ByteArrayInputStream(arr);