Merging this test from default branch ReducedStack
authorJaroslav Tulach <jaroslav.tulach@apidesign.org>
Sun, 16 Feb 2014 20:36:47 +0100
branchReducedStack
changeset 1461cfba11aaf2b5
parent 1459 6575d1848af3
parent 1460 ef506621d1ee
child 1462 1e7ff3ba3666
Merging this test from default branch
     1.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java	Sat Feb 15 23:16:11 2014 +0100
     1.2 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java	Sun Feb 16 20:36:47 2014 +0100
     1.3 @@ -77,16 +77,22 @@
     1.4              new byte[] { (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)13, (byte)126 }
     1.5          );
     1.6      }
     1.7 -    /* XXX: JavaScript cannot represent as big longs as Java. 
     1.8 +    @Test public void deserializeMiddleLong() throws Exception {
     1.9 +        final byte[] arr = new byte[] {
    1.10 +            (byte)0, (byte)0, (byte)64, (byte)32, (byte)23, (byte)0, (byte)0, (byte)0
    1.11 +        };
    1.12 +        long exp = Numbers.deserLong(arr, 16);
    1.13 +        assertExec("Should be " + exp, Numbers.class, "deserLong__J_3BI", 
    1.14 +            Double.valueOf(exp), arr, 16);
    1.15 +    }
    1.16      @Test public void deserializeLargeLong() throws Exception {
    1.17          final byte[] arr = new byte[] {
    1.18              (byte)64, (byte)8, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0, (byte)0
    1.19          };
    1.20 -        long exp = Numbers.deserLong(arr);
    1.21 -        assertExec("Should be " + exp, "org_apidesign_vm4brwsr_Numbers_deserLong__JAB", 
    1.22 -            Double.valueOf(exp), arr);
    1.23 +        long exp = Numbers.deserLong(arr, 32);
    1.24 +        assertExec("Should be " + exp, Numbers.class, "deserLong__J_3BI", 
    1.25 +            Double.valueOf(exp), arr, 32);
    1.26      }
    1.27 -    */
    1.28      
    1.29      @Test public void deserializeFloatInJava() throws Exception {
    1.30          float f = 54324.32423f;
     2.1 --- a/rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java	Sat Feb 15 23:16:11 2014 +0100
     2.2 +++ b/rt/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java	Sun Feb 16 20:36:47 2014 +0100
     2.3 @@ -55,6 +55,9 @@
     2.4          DataInputStream dis = new DataInputStream(is);
     2.5          return dis.readLong();
     2.6      }
     2.7 +    static long deserLong(byte[] arr, int shift) throws IOException {
     2.8 +        return deserLong(arr) >> shift;
     2.9 +    }
    2.10      static int deserInt() throws IOException {
    2.11          byte[] arr = {(byte) 71, (byte) 84, (byte) 52, (byte) 83};
    2.12          ByteArrayInputStream is = new ByteArrayInputStream(arr);