1.1 --- a/vm/src/test/java/org/apidesign/vm4brwsr/tck/IntegerArithmeticTest.java Tue Dec 18 11:41:09 2012 +0100
1.2 +++ b/vm/src/test/java/org/apidesign/vm4brwsr/tck/IntegerArithmeticTest.java Tue Dec 18 20:19:11 2012 +0100
1.3 @@ -17,7 +17,6 @@
1.4 */
1.5 package org.apidesign.vm4brwsr.tck;
1.6
1.7 -import org.apidesign.bck2brwsr.core.JavaScriptBody;
1.8 import org.apidesign.vm4brwsr.Compare;
1.9 import org.apidesign.vm4brwsr.CompareVMs;
1.10 import org.testng.annotations.Factory;
1.11 @@ -27,30 +26,53 @@
1.12 * @author Jaroslav Tulach <jtulach@netbeans.org>
1.13 */
1.14 public class IntegerArithmeticTest {
1.15 - //@JavaScriptBody(args="msg", body="java.lang.System.out.println(msg.toString());")
1.16 - //private static native void log(String msg);
1.17
1.18 - @Compare public int overflow() {
1.19 - int v = Integer.MAX_VALUE + 1;
1.20 - return v;
1.21 + private static int add(int x, int y) {
1.22 + return x + y;
1.23 }
1.24
1.25 - @Compare public int underflow() {
1.26 - int v = Integer.MIN_VALUE - 1;
1.27 - return v;
1.28 + private static int sub(int x, int y) {
1.29 + return x - y;
1.30 }
1.31
1.32 - /* @Compare public int convertToInt() {
1.33 - long v = Long.MAX_VALUE / 2;
1.34 - log("convert: " + v);
1.35 - return (int) v;
1.36 - } */
1.37 - @Compare public int addAndMaxInt() {
1.38 - return Integer.MAX_VALUE + Integer.MAX_VALUE;
1.39 + private static int mul(int x, int y) {
1.40 + return x * y;
1.41 + }
1.42 +
1.43 + @Compare public int addOverflow() {
1.44 + return add(Integer.MAX_VALUE, 1);
1.45 + }
1.46 +
1.47 + @Compare public int subUnderflow() {
1.48 + return sub(Integer.MIN_VALUE, 1);
1.49 + }
1.50 +
1.51 + @Compare public int addMaxIntAndMaxInt() {
1.52 + return add(Integer.MAX_VALUE, Integer.MAX_VALUE);
1.53 + }
1.54 +
1.55 + @Compare public int subMinIntAndMinInt() {
1.56 + return sub(Integer.MIN_VALUE, Integer.MIN_VALUE);
1.57 }
1.58
1.59 @Compare public int multiplyMaxInt() {
1.60 - return Integer.MAX_VALUE * Integer.MAX_VALUE;
1.61 + return mul(Integer.MAX_VALUE, 2);
1.62 + }
1.63 +
1.64 + @Compare public int multiplyMaxIntAndMaxInt() {
1.65 + return mul(Integer.MAX_VALUE, Integer.MAX_VALUE);
1.66 + }
1.67 +
1.68 + @Compare public int multiplyMinInt() {
1.69 + return mul(Integer.MIN_VALUE, 2);
1.70 + }
1.71 +
1.72 + @Compare public int multiplyMinIntAndMinInt() {
1.73 + return mul(Integer.MIN_VALUE, Integer.MIN_VALUE);
1.74 + }
1.75 +
1.76 + @Compare public int multiplyPrecision() {
1.77 + return mul(119106029, 1103515245);
1.78 }
1.79
1.80 @Factory