# HG changeset patch # User Martin Soch # Date 1359636912 -3600 # Node ID 960e219425e2926935d34ec74b78950be817ac44 # Parent 9cbf1f2ad7eeea4a605e834b3e9bdc9c682b0013 Added test for Long << diff -r 9cbf1f2ad7ee -r 960e219425e2 vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Thu Jan 31 13:42:14 2013 +0100 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/NumberTest.java Thu Jan 31 13:55:12 2013 +0100 @@ -171,6 +171,36 @@ ); } + @Test public void longShiftL1() throws Exception { + final long res = 0x00fa37d7763e0ca1l << 5; + assertExec("Long MAX", + Numbers.class, "shlL__J_3BI", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 }, + 5 + ); + } + + @Test public void longShiftL2() throws Exception { + final long res = 0x00fa37d7763e0ca1l << 32; + assertExec("Long MAX", + Numbers.class, "shlL__J_3BI", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 }, + 32 + ); + } + + @Test public void longShiftL3() throws Exception { + final long res = 0x00fa37d7763e0ca1l << 45; + assertExec("Long MAX", + Numbers.class, "shlL__J_3BI", + Double.valueOf(res), + new byte[] { (byte)0x00, (byte)0xfa, (byte)0x37, (byte)0xd7, (byte)0x76, (byte)0x3e, (byte)0x0c, (byte)0xa1 }, + 45 + ); + } + private static CharSequence codeSeq; private static Invocable code; diff -r 9cbf1f2ad7ee -r 960e219425e2 vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java --- a/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java Thu Jan 31 13:42:14 2013 +0100 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/Numbers.java Thu Jan 31 13:55:12 2013 +0100 @@ -95,4 +95,16 @@ public static long modL(long x, long y) { return (x % y); } + + public static long shlL(byte[] arrValue, int nBits) throws IOException { + ByteArrayInputStream isValue = new ByteArrayInputStream(arrValue); + DataInputStream disValue = new DataInputStream(isValue); + return (disValue.readLong() << nBits); + } + + public static long shrL(byte[] arrValue, int nBits) throws IOException { + ByteArrayInputStream isValue = new ByteArrayInputStream(arrValue); + DataInputStream disValue = new DataInputStream(isValue); + return (disValue.readLong() >> nBits); + } }