vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java
brancharithmetic
changeset 657 b42bfe334128
parent 630 04e312a7887e
child 669 3754580b6c67
     1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java	Fri Feb 01 09:00:30 2013 +0100
     1.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java	Mon Feb 04 09:41:33 2013 +0100
     1.3 @@ -219,6 +219,56 @@
     1.4          );
     1.5      }
     1.6      
     1.7 +    @Test public void longMultiplyMax() throws Exception {
     1.8 +        final long res = Long.MAX_VALUE * 2l;
     1.9 +        assertExec("Multiplication MAX*2",
    1.10 +            Numbers.class, "mulL__J_3B_3B",
    1.11 +            Double.valueOf(res),
    1.12 +            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
    1.13 +            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02 }
    1.14 +        );
    1.15 +    }
    1.16 +    
    1.17 +    @Test public void longMultiplyMaxAndMax() throws Exception {
    1.18 +        final long res = Long.MAX_VALUE * Long.MAX_VALUE;
    1.19 +        assertExec("Multiplication MAX*MAX",
    1.20 +            Numbers.class, "mulL__J_3B_3B",
    1.21 +            Double.valueOf(res),
    1.22 +            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff },
    1.23 +            new byte[] { (byte)0x7f, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff }
    1.24 +        );
    1.25 +    }
    1.26 +    
    1.27 +    @Test public void longMultiplyMin() throws Exception {
    1.28 +        final long res = Long.MIN_VALUE * 2l;
    1.29 +        assertExec("Multiplication MIN*2",
    1.30 +            Numbers.class, "mulL__J_3B_3B",
    1.31 +            Double.valueOf(res),
    1.32 +            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
    1.33 +            new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02 }
    1.34 +        );
    1.35 +    }
    1.36 +    
    1.37 +    @Test public void longMultiplyMinAndMin() throws Exception {
    1.38 +        final long res = Long.MIN_VALUE * Long.MIN_VALUE;
    1.39 +        assertExec("Multiplication MIN*2",
    1.40 +            Numbers.class, "mulL__J_3B_3B",
    1.41 +            Double.valueOf(res),
    1.42 +            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 },
    1.43 +            new byte[] { (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }
    1.44 +        );
    1.45 +    }
    1.46 +    
    1.47 +    @Test public void longMultiplyPrecision() throws Exception {
    1.48 +        final long res = 0x00fa37d7763e0ca1l * 0xa7b3432fff00123el;
    1.49 +        assertExec("Multiplication",
    1.50 +            Numbers.class, "mulL__J_3B_3B",
    1.51 +            Double.valueOf(res),
    1.52 +            new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 },
    1.53 +            new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e }
    1.54 +        );
    1.55 +    }
    1.56 +    
    1.57      @Test public void longShiftL1() throws Exception {
    1.58          final long res = 0x00fa37d7763e0ca1l << 5;
    1.59          assertExec("Long << 5",