Test behavior of int shifts >= 32
Change-Id: I6e228418068b70447295f367ed56ff8cb86abd33
diff --git a/test/003-omnibus-opcodes/expected.txt b/test/003-omnibus-opcodes/expected.txt
index 33322eb..afb0c19 100644
--- a/test/003-omnibus-opcodes/expected.txt
+++ b/test/003-omnibus-opcodes/expected.txt
@@ -6,6 +6,7 @@
IntMath.shiftTest1
IntMath.shiftTest2
IntMath.unsignedShiftTest
+IntMath.shiftTest3
IntMath.convTest
IntMath.charSubTest
IntMath.intOperTest
diff --git a/test/003-omnibus-opcodes/src/IntMath.java b/test/003-omnibus-opcodes/src/IntMath.java
index be883b9..292fdd3 100644
--- a/test/003-omnibus-opcodes/src/IntMath.java
+++ b/test/003-omnibus-opcodes/src/IntMath.java
@@ -85,6 +85,39 @@
Main.assertTrue(i == 268435455);
}
+ static void shiftTest3(int thirtyTwo) {
+ System.out.println("IntMath.shiftTest3");
+
+ int one = thirtyTwo / 32;
+ int sixteen = thirtyTwo / 2;
+ int thirtyThree = thirtyTwo + 1;
+ int sixtyFour = thirtyTwo * 2;
+
+ Main.assertTrue(1 << thirtyTwo == 1);
+ Main.assertTrue((1 << sixteen) << sixteen == 0);
+ Main.assertTrue(1 << thirtyThree == 2);
+ Main.assertTrue(1 << -one == -2147483648);
+ Main.assertTrue(1 << -thirtyTwo == 1);
+ Main.assertTrue(1 << -thirtyThree == -2147483648);
+ Main.assertTrue(1 << thirtyThree == 2);
+
+ Main.assertTrue(1 >> thirtyTwo == 1);
+ Main.assertTrue((1 >> sixteen) >> sixteen == 0);
+ Main.assertTrue(1 >> thirtyThree == 0);
+ Main.assertTrue(1 >> -one == 0);
+ Main.assertTrue(1 >> -thirtyTwo == 1);
+ Main.assertTrue(1 >> -thirtyThree == 0);
+ Main.assertTrue(-4 >> thirtyThree == -2);
+
+ Main.assertTrue(1 >>> thirtyTwo == 1);
+ Main.assertTrue((1 >>> sixteen) >>> sixteen == 0);
+ Main.assertTrue(1 >>> thirtyThree == 0);
+ Main.assertTrue(1 >>> -one == 0);
+ Main.assertTrue(1 >>> -thirtyTwo == 1);
+ Main.assertTrue(1 >>> -thirtyThree == 0);
+ Main.assertTrue(-4 >>> thirtyThree == 2147483646);
+ }
+
static void convTest() {
System.out.println("IntMath.convTest");
@@ -469,6 +502,7 @@
shiftTest1();
shiftTest2();
unsignedShiftTest();
+ shiftTest3(32);
convTest();
charSubTest();