--- a/jdk/test/java/math/BigInteger/ExtremeShiftingTests.java Wed Oct 30 17:27:25 2013 -0700
+++ b/jdk/test/java/math/BigInteger/ExtremeShiftingTests.java Wed Oct 30 17:45:12 2013 -0700
@@ -27,22 +27,41 @@
* @summary Tests of shiftLeft and shiftRight on Integer.MIN_VALUE
* @author Joseph D. Darcy
*/
+import java.math.BigInteger;
import static java.math.BigInteger.*;
public class ExtremeShiftingTests {
public static void main(String... args) {
+ BigInteger bi = ONE.shiftLeft(Integer.MIN_VALUE);
+ if (!bi.equals(ZERO))
+ throw new RuntimeException("1 << " + Integer.MIN_VALUE);
+
+ bi = ZERO.shiftLeft(Integer.MIN_VALUE);
+ if (!bi.equals(ZERO))
+ throw new RuntimeException("0 << " + Integer.MIN_VALUE);
+
+ bi = BigInteger.valueOf(-1);
+ bi = bi.shiftLeft(Integer.MIN_VALUE);
+ if (!bi.equals(BigInteger.valueOf(-1)))
+ throw new RuntimeException("-1 << " + Integer.MIN_VALUE);
+
try {
- ONE.shiftLeft(Integer.MIN_VALUE);
- throw new RuntimeException("Should not reach here.");
+ ONE.shiftRight(Integer.MIN_VALUE);
+ throw new RuntimeException("1 >> " + Integer.MIN_VALUE);
} catch (ArithmeticException ae) {
; // Expected
}
+ bi = ZERO.shiftRight(Integer.MIN_VALUE);
+ if (!bi.equals(ZERO))
+ throw new RuntimeException("0 >> " + Integer.MIN_VALUE);
+
try {
- ONE.shiftRight(Integer.MIN_VALUE);
- throw new RuntimeException("Should not reach here.");
+ BigInteger.valueOf(-1).shiftRight(Integer.MIN_VALUE);
+ throw new RuntimeException("-1 >> " + Integer.MIN_VALUE);
} catch (ArithmeticException ae) {
; // Expected
}
+
}
}