diff -r 3754580b6c67 -r eecf6077ec4e vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Tue Feb 05 15:03:22 2013 +0100 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Tue Feb 05 16:40:01 2013 +0100 @@ -168,7 +168,7 @@ new byte[] { (byte)0x80, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 } ); } - + @Test public void longNegate3() throws Exception { final long res = -0xfffffffffffffeddl; assertExec("Long negate", @@ -178,7 +178,6 @@ ); } - @Test public void longAddOverflow() throws Exception { final long res = Long.MAX_VALUE + 1l; assertExec("Addition 1+MAX", @@ -278,7 +277,239 @@ new byte[] { (byte)0xa7, (byte)0xb3, (byte)0x43, (byte)0x2f, (byte)0xff, (byte)0x00, (byte)0x12, (byte)0x3e } ); } - + + @Test public void longDivideSmallPositiveNumbers() throws Exception { + final long res = 0xabcdef / 0x123; + assertExec("Division Small Positive Numbers", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x23 } + ); + } + + @Test public void longDivideSmallNegativeNumbers() throws Exception { + final long res = -0xabcdef / -0x123; + assertExec("Division Small Negative Numbers", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x11 }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd } + ); + } + + @Test public void longDivideSmallMixedNumbers() throws Exception { + final long res = 0xabcdef / -0x123; + assertExec("Division Small Mixed Numbers", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd } + ); + } + + @Test public void longDividePositiveNumbersOneDigitDenom() + throws Exception { + final long res = 0xabcdef0102ffffL / 0x654; + assertExec("Division Positive Numbers One Digit Denom", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef, (byte)0x01, (byte)0x02, (byte)0xff, (byte)0xff }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 } + ); + } + + @Test public void longDivideNegativeNumbersOneDigitDenom() + throws Exception { + final long res = -0xabcdef0102ffffL / -0x654; + assertExec("Division Negative Numbers One Digit Denom", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xf9, (byte)0xac } + ); + } + + @Test public void longDivideMixedNumbersOneDigitDenom() + throws Exception { + final long res = -0xabcdef0102ffffL / 0x654; + assertExec("Division Mixed Numbers One Digit Denom", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 } + ); + } + + @Test public void longDividePositiveNumbersMultiDigitDenom() + throws Exception { + final long res = 0x7ffefc003322aabbL / 0x89ab1000L; + assertExec("Division Positive Numbers Multi Digit Denom", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x89, (byte)0xab, (byte)0x10, (byte)0x00 } + ); + } + + @Test public void longDivideNegativeNumbersMultiDigitDenom() + throws Exception { + final long res = -0x7ffefc003322aabbL / -0x123489ab1001L; + assertExec("Division Negative Numbers Multi Digit Denom", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x80, (byte)0x01, (byte)0x03, (byte)0xff, (byte)0xcc, (byte)0xdd, (byte)0x55, (byte)0x45 }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xed, (byte)0xcb, (byte)0x76, (byte)0x54, (byte)0xef, (byte)0xff } + ); + } + + @Test public void longDivideMixedNumbersMultiDigitDenom() + throws Exception { + final long res = 0x7ffefc003322aabbL / -0x38f49b0b7574e36L; + assertExec("Division Mixed Numbers Multi Digit Denom", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb }, + new byte[] { (byte)0xfc, (byte)0x70, (byte)0xb6, (byte)0x4f, (byte)0x48, (byte)0xa8, (byte)0xb1, (byte)0xca } + ); + } + + @Test public void longDivideWithOverflow() throws Exception { + final long res = 0x8000fffe0000L / 0x8000ffffL; + assertExec("Division With Overflow", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xfe, (byte)0x00, (byte)0x00 }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xff } + ); + } + + @Test public void longDivideWithCorrection() throws Exception { + final long res = 0x7fff800000000000L / 0x800000000001L; + assertExec("Division With Correction", + Numbers.class, "divL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x7f, (byte)0xff, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01 } + ); + } + + @Test public void longModuloSmallPositiveNumbers() throws Exception { + final long res = 0xabcdef % 0x123; + assertExec("Modulo Small Positive Numbers", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x23 } + ); + } + + @Test public void longModuloSmallNegativeNumbers() throws Exception { + final long res = -0xabcdef % -0x123; + assertExec("Modulo Small Negative Numbers", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x11 }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd } + ); + } + + @Test public void longModuloSmallMixedNumbers() throws Exception { + final long res = 0xabcdef % -0x123; + assertExec("Modulo Small Mixed Numbers", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xfe, (byte)0xdd } + ); + } + + @Test public void longModuloPositiveNumbersOneDigitDenom() + throws Exception { + final long res = 0xabcdef0102ffffL % 0x654; + assertExec("Modulo Positive Numbers One Digit Denom", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0xab, (byte)0xcd, (byte)0xef, (byte)0x01, (byte)0x02, (byte)0xff, (byte)0xff }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 } + ); + } + + @Test public void longModuloNegativeNumbersOneDigitDenom() + throws Exception { + final long res = -0xabcdef0102ffffL % -0x654; + assertExec("Modulo Negative Numbers One Digit Denom", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xf9, (byte)0xac } + ); + } + + @Test public void longModuloMixedNumbersOneDigitDenom() + throws Exception { + final long res = -0xabcdef0102ffffL % 0x654; + assertExec("Modulo Mixed Numbers One Digit Denom", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0xff, (byte)0x54, (byte)0x32, (byte)0x10, (byte)0xfe, (byte)0xfd, (byte)0x00, (byte)0x01 }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x06, (byte)0x54 } + ); + } + + @Test public void longModuloPositiveNumbersMultiDigitDenom() + throws Exception { + final long res = 0x7ffefc003322aabbL % 0x89ab1000L; + assertExec("Modulo Positive Numbers Multi Digit Denom", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x89, (byte)0xab, (byte)0x10, (byte)0x00 } + ); + } + + @Test public void longModuloNegativeNumbersMultiDigitDenom() + throws Exception { + final long res = -0x7ffefc003322aabbL % -0x123489ab1001L; + assertExec("Modulo Negative Numbers Multi Digit Denom", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x80, (byte)0x01, (byte)0x03, (byte)0xff, (byte)0xcc, (byte)0xdd, (byte)0x55, (byte)0x45 }, + new byte[] { (byte)0xff, (byte)0xff, (byte)0xed, (byte)0xcb, (byte)0x76, (byte)0x54, (byte)0xef, (byte)0xff } + ); + } + + @Test public void longModuloMixedNumbersMultiDigitDenom() + throws Exception { + final long res = 0x7ffefc003322aabbL % -0x38f49b0b7574e36L; + assertExec("Modulo Mixed Numbers Multi Digit Denom", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x7f, (byte)0xfe, (byte)0xfc, (byte)0x00, (byte)0x33, (byte)0x22, (byte)0xaa, (byte)0xbb }, + new byte[] { (byte)0xfc, (byte)0x70, (byte)0xb6, (byte)0x4f, (byte)0x48, (byte)0xa8, (byte)0xb1, (byte)0xca } + ); + } + + @Test public void longModuloWithOverflow() throws Exception { + final long res = 0x8000fffe0000L % 0x8000ffffL; + assertExec("Modulo With Overflow", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xfe, (byte)0x00, (byte)0x00 }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0xff, (byte)0xff } + ); + } + + @Test public void longModuloWithCorrection() throws Exception { + final long res = 0x7fff800000000000L % 0x800000000001L; + assertExec("Modulo With Correction", + Numbers.class, "modL__J_3B_3B", + Double.valueOf(res), + new byte[] { (byte)0x7f, (byte)0xff, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 }, + new byte[] { (byte)0x00, (byte)0x00, (byte)0x80, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01 } + ); + } + @Test public void longShiftL1() throws Exception { final long res = 0x00fa37d7763e0ca1l << 5; assertExec("Long << 5",