rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java
changeset 1761 d2a5a7a0e167
parent 1723 3a1f262311cf
child 1779 9d757281c666
     1.1 --- a/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Wed Nov 19 19:32:00 2014 +0100
     1.2 +++ b/rt/emul/compacttest/src/test/java/org/apidesign/bck2brwsr/tck/LongArithmeticTest.java	Wed Jan 07 14:17:22 2015 +0100
     1.3 @@ -38,7 +38,7 @@
     1.4      private static long mul(long x, long y) {
     1.5          return (x * y);
     1.6      }
     1.7 -
     1.8 +    
     1.9      private static long div(long x, long y) {
    1.10          return (x / y);
    1.11      }
    1.12 @@ -82,6 +82,14 @@
    1.13      private static double dadd(double x, double y) {
    1.14          return x + y;
    1.15      }
    1.16 +    
    1.17 +    private static long mul64shr64(long base, int mul, int shr) {
    1.18 +        long tmp = base * mul;
    1.19 +        if (shr == -1) {
    1.20 +            return tmp;
    1.21 +        }
    1.22 +        return tmp >> shr;
    1.23 +    }
    1.24  
    1.25      public static int compare(long x, long y, int zero) {
    1.26          final int xyResult = compareL(x, y, zero);
    1.27 @@ -411,6 +419,21 @@
    1.28          return compare(0x8000000000000000l, 0x7fffffffffffffffl, 0);
    1.29      }
    1.30      
    1.31 +    @Compare public int intConversionProblemInRandom() {
    1.32 +        long res = mul64shr64(16, 1561751147, 31);
    1.33 +        return (int) res;
    1.34 +    }
    1.35 +
    1.36 +    @Compare public long shiftProblemInRandom() {
    1.37 +        long res = mul64shr64(16, 1561751147, 31);
    1.38 +        return res;
    1.39 +    }
    1.40 +
    1.41 +    @Compare public long multiplyProblemInRandom() {
    1.42 +        long res = mul64shr64(16, 1561751147, -1);
    1.43 +        return res;
    1.44 +    }
    1.45 +    
    1.46      @Factory
    1.47      public static Object[] create() {
    1.48          return VMTest.create(LongArithmeticTest.class);