1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Fri Sep 28 14:58:21 2012 +0200
1.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/StaticMethodTest.java Mon Oct 08 17:10:27 2012 -0700
1.3 @@ -143,6 +143,47 @@
1.4 );
1.5 }
1.6
1.7 + @Test public void shiftLeftInJava() throws Exception {
1.8 + int res = StaticMethod.shiftLeft(1, 8);
1.9 + assertEquals(res, 256);
1.10 + }
1.11 +
1.12 + @Test public void shiftLeftInJS() throws Exception {
1.13 + assertExec(
1.14 + "Setting 9th bit",
1.15 + "org_apidesign_vm4brwsr_StaticMethod_shiftLeftIII",
1.16 + Double.valueOf(256),
1.17 + 1, 8
1.18 + );
1.19 + }
1.20 +
1.21 + @Test public void shiftRightInJava() throws Exception {
1.22 + int res = StaticMethod.shiftArithmRight(-8, 3, true);
1.23 + assertEquals(res, -1);
1.24 + }
1.25 +
1.26 + @Test public void shiftRightInJS() throws Exception {
1.27 + assertExec(
1.28 + "Get -1",
1.29 + "org_apidesign_vm4brwsr_StaticMethod_shiftArithmRightIIIZ",
1.30 + Double.valueOf(-1),
1.31 + -8, 3, true
1.32 + );
1.33 + }
1.34 + @Test public void unsignedShiftRightInJava() throws Exception {
1.35 + int res = StaticMethod.shiftArithmRight(8, 3, false);
1.36 + assertEquals(res, 1);
1.37 + }
1.38 +
1.39 + @Test public void unsignedShiftRightInJS() throws Exception {
1.40 + assertExec(
1.41 + "Get -1",
1.42 + "org_apidesign_vm4brwsr_StaticMethod_shiftArithmRightIIIZ",
1.43 + Double.valueOf(1),
1.44 + 8, 3, false
1.45 + );
1.46 + }
1.47 +
1.48 private static void assertExec(String msg, String methodName, Object expRes, Object... args) throws Exception {
1.49 StringBuilder sb = new StringBuilder();
1.50 Invocable i = compileClass(sb, "org/apidesign/vm4brwsr/StaticMethod");