jdk/test/java/lang/Math/IeeeRecommendedTests.java
author darcy
Mon, 03 Feb 2014 09:52:36 -0800
changeset 22634 9c18aebe9229
parent 10608 7cfca36fc79b
child 26197 1bb6b68b87cd
permissions -rw-r--r--
8033416: Remove sun.misc.FpUtils Reviewed-by: alanb, bpb, psandoz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     1
/*
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
     2
 * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     4
 *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     7
 * published by the Free Software Foundation.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     8
 *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    13
 * accompanied this code).
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    14
 *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4347
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4347
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4347
diff changeset
    21
 * questions.
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    22
 */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    23
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    24
/*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    25
 * @test
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    26
 * @bug 4860891 4826732 4780454 4939441 4826652
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    27
 * @summary Tests for IEEE 754[R] recommended functions and similar methods
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    28
 * @author Joseph D. Darcy
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    29
 */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    30
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    31
import sun.misc.DoubleConsts;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    32
import sun.misc.FloatConsts;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    33
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    34
public class IeeeRecommendedTests {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    35
    private IeeeRecommendedTests(){}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    36
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    37
    static final float  NaNf = Float.NaN;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    38
    static final double NaNd = Double.NaN;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    39
    static final float  infinityF = Float.POSITIVE_INFINITY;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    40
    static final double infinityD = Double.POSITIVE_INFINITY;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    41
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    42
    static final float  Float_MAX_VALUEmm       = 0x1.fffffcP+127f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    43
    static final float  Float_MAX_SUBNORMAL     = 0x0.fffffeP-126f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    44
    static final float  Float_MAX_SUBNORMALmm   = 0x0.fffffcP-126f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    45
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    46
    static final double Double_MAX_VALUEmm      = 0x1.ffffffffffffeP+1023;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    47
    static final double Double_MAX_SUBNORMAL    = 0x0.fffffffffffffP-1022;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    48
    static final double Double_MAX_SUBNORMALmm  = 0x0.ffffffffffffeP-1022;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    49
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    50
    // Initialize shared random number generator
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    51
    static java.util.Random rand = new java.util.Random();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    52
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    53
    /**
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    54
     * Returns a floating-point power of two in the normal range.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    55
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    56
    static double powerOfTwoD(int n) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    57
        return Double.longBitsToDouble((((long)n + (long)DoubleConsts.MAX_EXPONENT) <<
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    58
                                        (DoubleConsts.SIGNIFICAND_WIDTH-1))
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    59
                                       & DoubleConsts.EXP_BIT_MASK);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    60
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    61
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    62
    /**
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    63
     * Returns a floating-point power of two in the normal range.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    64
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    65
    static float powerOfTwoF(int n) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    66
        return Float.intBitsToFloat(((n + FloatConsts.MAX_EXPONENT) <<
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    67
                                     (FloatConsts.SIGNIFICAND_WIDTH-1))
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    68
                                    & FloatConsts.EXP_BIT_MASK);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    69
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    70
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    71
    /* ******************** getExponent tests ****************************** */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    72
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    73
    /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    74
     * The tests for getExponent should test the special values (NaN, +/-
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    75
     * infinity, etc.), test the endpoints of each binade (set of
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    76
     * floating-point values with the same exponent), and for good
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    77
     * measure, test some random values within each binade.  Testing
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    78
     * the endpoints of each binade includes testing both positive and
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    79
     * negative numbers.  Subnormal values with different normalized
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    80
     * exponents should be tested too.  Both Math and StrictMath
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    81
     * methods should return the same results.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    82
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    83
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    84
    /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    85
     * Test Math.getExponent and StrictMath.getExponent with +d and -d.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    86
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    87
    static int testGetExponentCase(float f, int expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    88
        float minus_f = -f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    89
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    90
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    91
        failures+=Tests.test("Math.getExponent(float)", f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    92
                             Math.getExponent(f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    93
        failures+=Tests.test("Math.getExponent(float)", minus_f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    94
                             Math.getExponent(minus_f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    95
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    96
        failures+=Tests.test("StrictMath.getExponent(float)", f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    97
                             StrictMath.getExponent(f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    98
        failures+=Tests.test("StrictMath.getExponent(float)", minus_f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    99
                             StrictMath.getExponent(minus_f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   100
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   101
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   102
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   103
    /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   104
     * Test Math.getExponent and StrictMath.getExponent with +d and -d.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   105
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   106
    static int testGetExponentCase(double d, int expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   107
        double minus_d = -d;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   108
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   109
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   110
        failures+=Tests.test("Math.getExponent(double)", d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   111
                             Math.getExponent(d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   112
        failures+=Tests.test("Math.getExponent(double)", minus_d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   113
                             Math.getExponent(minus_d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   114
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   115
        failures+=Tests.test("StrictMath.getExponent(double)", d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   116
                             StrictMath.getExponent(d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   117
        failures+=Tests.test("StrictMath.getExponent(double)", minus_d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   118
                             StrictMath.getExponent(minus_d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   119
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   120
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   121
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   122
    public static int testFloatGetExponent() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   123
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   124
        float [] specialValues = {NaNf,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   125
                                   Float.POSITIVE_INFINITY,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   126
                                   +0.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   127
                                  +1.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   128
                                  +2.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   129
                                  +16.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   130
                                  +Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   131
                                  +Float_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   132
                                  +FloatConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   133
                                  +Float.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   134
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   135
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   136
        int [] specialResults = {Float.MAX_EXPONENT + 1, // NaN results
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   137
                                 Float.MAX_EXPONENT + 1, // Infinite results
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   138
                                 Float.MIN_EXPONENT - 1, // Zero results
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   139
                                 0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   140
                                 1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   141
                                 4,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   142
                                 FloatConsts.MIN_EXPONENT - 1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   143
                                 -FloatConsts.MAX_EXPONENT,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   144
                                 FloatConsts.MIN_EXPONENT,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   145
                                 FloatConsts.MAX_EXPONENT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   146
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   147
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   148
        // Special value tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   149
        for(int i = 0; i < specialValues.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   150
            failures += testGetExponentCase(specialValues[i], specialResults[i]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   151
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   152
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   153
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   154
        // Normal exponent tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   155
        for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   156
            int result;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   157
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   158
            // Create power of two
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   159
            float po2 = powerOfTwoF(i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   160
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   161
            failures += testGetExponentCase(po2, i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   162
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   163
            // Generate some random bit patterns for the significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   164
            for(int j = 0; j < 10; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   165
                int randSignif = rand.nextInt();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   166
                float randFloat;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   167
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   168
                randFloat = Float.intBitsToFloat( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   169
                                                 (Float.floatToIntBits(po2)&
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   170
                                                  (~FloatConsts.SIGNIF_BIT_MASK)) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   171
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   172
                                                 (randSignif &
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   173
                                                  FloatConsts.SIGNIF_BIT_MASK) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   174
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   175
                failures += testGetExponentCase(randFloat, i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   176
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   177
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   178
            if (i > FloatConsts.MIN_EXPONENT) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   179
                float po2minus = Math.nextAfter(po2,
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   180
                                                 Float.NEGATIVE_INFINITY);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   181
                failures += testGetExponentCase(po2minus, i-1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   182
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   183
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   184
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   185
        // Subnormal exponent tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   186
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   187
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   188
         * Start with MIN_VALUE, left shift, test high value, low
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   189
         * values, and random in between.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   190
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   191
         * Use nextAfter to calculate, high value of previous binade,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   192
         * loop count i will indicate how many random bits, if any are
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   193
         * needed.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   194
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   195
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   196
        float top=Float.MIN_VALUE;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   197
        for( int i = 1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   198
            i < FloatConsts.SIGNIFICAND_WIDTH;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   199
            i++, top *= 2.0f) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   200
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   201
            failures += testGetExponentCase(top,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   202
                                            FloatConsts.MIN_EXPONENT - 1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   203
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   204
            // Test largest value in next smaller binade
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   205
            if (i >= 3) {// (i == 1) would test 0.0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   206
                         // (i == 2) would just retest MIN_VALUE
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   207
                testGetExponentCase(Math.nextAfter(top, 0.0f),
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   208
                                    FloatConsts.MIN_EXPONENT - 1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   209
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   210
                if( i >= 10) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   211
                    // create a bit mask with (i-1) 1's in the low order
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   212
                    // bits
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   213
                    int mask = ~((~0)<<(i-1));
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   214
                    float randFloat = Float.intBitsToFloat( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   215
                                                 Float.floatToIntBits(top) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   216
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   217
                                                 (rand.nextInt() & mask ) ) ;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   218
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   219
                    failures += testGetExponentCase(randFloat,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   220
                                                    FloatConsts.MIN_EXPONENT - 1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   221
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   222
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   223
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   224
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   225
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   226
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   227
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   228
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   229
    public static int testDoubleGetExponent() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   230
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   231
        double [] specialValues = {NaNd,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   232
                                   infinityD,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   233
                                   +0.0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   234
                                   +1.0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   235
                                   +2.0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   236
                                   +16.0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   237
                                   +Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   238
                                   +Double_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   239
                                   +DoubleConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   240
                                   +Double.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   241
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   242
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   243
        int [] specialResults = {Double.MAX_EXPONENT + 1, // NaN results
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   244
                                 Double.MAX_EXPONENT + 1, // Infinite results
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   245
                                 Double.MIN_EXPONENT - 1, // Zero results
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   246
                                 0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   247
                                 1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   248
                                 4,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   249
                                 DoubleConsts.MIN_EXPONENT - 1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   250
                                 -DoubleConsts.MAX_EXPONENT,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   251
                                 DoubleConsts.MIN_EXPONENT,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   252
                                 DoubleConsts.MAX_EXPONENT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   253
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   254
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   255
        // Special value tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   256
        for(int i = 0; i < specialValues.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   257
            failures += testGetExponentCase(specialValues[i], specialResults[i]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   258
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   259
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   260
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   261
        // Normal exponent tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   262
        for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   263
            int result;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   264
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   265
            // Create power of two
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   266
            double po2 = powerOfTwoD(i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   267
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   268
            failures += testGetExponentCase(po2, i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   269
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   270
            // Generate some random bit patterns for the significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   271
            for(int j = 0; j < 10; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   272
                long randSignif = rand.nextLong();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   273
                double randFloat;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   274
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   275
                randFloat = Double.longBitsToDouble( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   276
                                                 (Double.doubleToLongBits(po2)&
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   277
                                                  (~DoubleConsts.SIGNIF_BIT_MASK)) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   278
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   279
                                                 (randSignif &
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   280
                                                  DoubleConsts.SIGNIF_BIT_MASK) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   281
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   282
                failures += testGetExponentCase(randFloat, i);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   283
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   284
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   285
            if (i > DoubleConsts.MIN_EXPONENT) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   286
                double po2minus = Math.nextAfter(po2,
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   287
                                                    Double.NEGATIVE_INFINITY);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   288
                failures += testGetExponentCase(po2minus, i-1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   289
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   290
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   291
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   292
        // Subnormal exponent tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   293
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   294
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   295
         * Start with MIN_VALUE, left shift, test high value, low
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   296
         * values, and random in between.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   297
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   298
         * Use nextAfter to calculate, high value of previous binade;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   299
         * loop count i will indicate how many random bits, if any are
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   300
         * needed.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   301
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   302
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   303
        double top=Double.MIN_VALUE;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   304
        for( int i = 1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   305
            i < DoubleConsts.SIGNIFICAND_WIDTH;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   306
            i++, top *= 2.0f) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   307
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   308
            failures += testGetExponentCase(top,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   309
                                            DoubleConsts.MIN_EXPONENT - 1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   310
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   311
            // Test largest value in next smaller binade
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   312
            if (i >= 3) {// (i == 1) would test 0.0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   313
                         // (i == 2) would just retest MIN_VALUE
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
   314
                testGetExponentCase(Math.nextAfter(top, 0.0),
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   315
                                    DoubleConsts.MIN_EXPONENT - 1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   316
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   317
                if( i >= 10) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   318
                    // create a bit mask with (i-1) 1's in the low order
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   319
                    // bits
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   320
                    long mask = ~((~0L)<<(i-1));
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   321
                    double randFloat = Double.longBitsToDouble( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   322
                                                 Double.doubleToLongBits(top) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   323
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   324
                                                 (rand.nextLong() & mask ) ) ;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   325
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   326
                    failures += testGetExponentCase(randFloat,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   327
                                                    DoubleConsts.MIN_EXPONENT - 1);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   328
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   329
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   330
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   331
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   332
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   333
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   334
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   335
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   336
    /* ******************** nextAfter tests ****************************** */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   337
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   338
    static int testNextAfterCase(float start, double direction, float expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   339
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   340
        float minus_start = -start;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   341
        double minus_direction = -direction;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   342
        float minus_expected = -expected;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   343
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   344
        failures+=Tests.test("Math.nextAfter(float,double)", start, direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   345
                             Math.nextAfter(start, direction), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   346
        failures+=Tests.test("Math.nextAfter(float,double)", minus_start, minus_direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   347
                             Math.nextAfter(minus_start, minus_direction), minus_expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   348
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   349
        failures+=Tests.test("StrictMath.nextAfter(float,double)", start, direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   350
                             StrictMath.nextAfter(start, direction), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   351
        failures+=Tests.test("StrictMath.nextAfter(float,double)", minus_start, minus_direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   352
                             StrictMath.nextAfter(minus_start, minus_direction), minus_expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   353
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   354
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   355
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   356
    static int testNextAfterCase(double start, double direction, double expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   357
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   358
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   359
        double minus_start = -start;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   360
        double minus_direction = -direction;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   361
        double minus_expected = -expected;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   362
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   363
        failures+=Tests.test("Math.nextAfter(double,double)", start, direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   364
                             Math.nextAfter(start, direction), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   365
        failures+=Tests.test("Math.nextAfter(double,double)", minus_start, minus_direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   366
                             Math.nextAfter(minus_start, minus_direction), minus_expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   367
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   368
        failures+=Tests.test("StrictMath.nextAfter(double,double)", start, direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   369
                             StrictMath.nextAfter(start, direction), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   370
        failures+=Tests.test("StrictMath.nextAfter(double,double)", minus_start, minus_direction,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   371
                             StrictMath.nextAfter(minus_start, minus_direction), minus_expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   372
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   373
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   374
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   375
    public static int testFloatNextAfter() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   376
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   377
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   378
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   379
         * Each row of the testCases matrix represents one test case
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   380
         * for nexAfter; given the input of the first two columns, the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   381
         * result in the last column is expected.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   382
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   383
        float [][] testCases  = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   384
            {NaNf,              NaNf,                   NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   385
            {NaNf,              0.0f,                   NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   386
            {0.0f,              NaNf,                   NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   387
            {NaNf,              infinityF,              NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   388
            {infinityF,         NaNf,                   NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   389
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   390
            {infinityF,         infinityF,              infinityF},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   391
            {infinityF,         -infinityF,             Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   392
            {infinityF,         0.0f,                   Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   393
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   394
            {Float.MAX_VALUE,   infinityF,              infinityF},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   395
            {Float.MAX_VALUE,   -infinityF,             Float_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   396
            {Float.MAX_VALUE,   Float.MAX_VALUE,        Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   397
            {Float.MAX_VALUE,   0.0f,                   Float_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   398
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   399
            {Float_MAX_VALUEmm, Float.MAX_VALUE,        Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   400
            {Float_MAX_VALUEmm, infinityF,              Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   401
            {Float_MAX_VALUEmm, Float_MAX_VALUEmm,      Float_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   402
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   403
            {FloatConsts.MIN_NORMAL,    infinityF,              FloatConsts.MIN_NORMAL+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   404
                                                                Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   405
            {FloatConsts.MIN_NORMAL,    -infinityF,             Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   406
            {FloatConsts.MIN_NORMAL,    1.0f,                   FloatConsts.MIN_NORMAL+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   407
                                                                Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   408
            {FloatConsts.MIN_NORMAL,    -1.0f,                  Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   409
            {FloatConsts.MIN_NORMAL,    FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   410
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   411
            {Float_MAX_SUBNORMAL,       FloatConsts.MIN_NORMAL, FloatConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   412
            {Float_MAX_SUBNORMAL,       Float_MAX_SUBNORMAL,    Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   413
            {Float_MAX_SUBNORMAL,       0.0f,                   Float_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   414
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   415
            {Float_MAX_SUBNORMALmm,     Float_MAX_SUBNORMAL,    Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   416
            {Float_MAX_SUBNORMALmm,     0.0f,                   Float_MAX_SUBNORMALmm-Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   417
            {Float_MAX_SUBNORMALmm,     Float_MAX_SUBNORMALmm,  Float_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   418
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   419
            {Float.MIN_VALUE,   0.0f,                   0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   420
            {-Float.MIN_VALUE,  0.0f,                   -0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   421
            {Float.MIN_VALUE,   Float.MIN_VALUE,        Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   422
            {Float.MIN_VALUE,   1.0f,                   2*Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   423
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   424
            // Make sure zero behavior is tested
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   425
            {0.0f,              0.0f,                   0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   426
            {0.0f,              -0.0f,                  -0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   427
            {-0.0f,             0.0f,                   0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   428
            {-0.0f,             -0.0f,                  -0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   429
            {0.0f,              infinityF,              Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   430
            {0.0f,              -infinityF,             -Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   431
            {-0.0f,             infinityF,              Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   432
            {-0.0f,             -infinityF,             -Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   433
            {0.0f,              Float.MIN_VALUE,        Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   434
            {0.0f,              -Float.MIN_VALUE,       -Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   435
            {-0.0f,             Float.MIN_VALUE,        Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   436
            {-0.0f,             -Float.MIN_VALUE,       -Float.MIN_VALUE}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   437
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   438
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   439
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   440
            failures += testNextAfterCase(testCases[i][0], testCases[i][1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   441
                                          testCases[i][2]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   442
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   443
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   444
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   445
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   446
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   447
    public static int testDoubleNextAfter() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   448
        int failures =0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   449
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   450
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   451
         * Each row of the testCases matrix represents one test case
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   452
         * for nexAfter; given the input of the first two columns, the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   453
         * result in the last column is expected.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   454
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   455
        double [][] testCases  = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   456
            {NaNd,              NaNd,                   NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   457
            {NaNd,              0.0d,                   NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   458
            {0.0d,              NaNd,                   NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   459
            {NaNd,              infinityD,              NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   460
            {infinityD,         NaNd,                   NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   461
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   462
            {infinityD,         infinityD,              infinityD},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   463
            {infinityD,         -infinityD,             Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   464
            {infinityD,         0.0d,                   Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   465
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   466
            {Double.MAX_VALUE,  infinityD,              infinityD},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   467
            {Double.MAX_VALUE,  -infinityD,             Double_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   468
            {Double.MAX_VALUE,  Double.MAX_VALUE,       Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   469
            {Double.MAX_VALUE,  0.0d,                   Double_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   470
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   471
            {Double_MAX_VALUEmm,        Double.MAX_VALUE,       Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   472
            {Double_MAX_VALUEmm,        infinityD,              Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   473
            {Double_MAX_VALUEmm,        Double_MAX_VALUEmm,     Double_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   474
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   475
            {DoubleConsts.MIN_NORMAL,   infinityD,              DoubleConsts.MIN_NORMAL+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   476
                                                                Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   477
            {DoubleConsts.MIN_NORMAL,   -infinityD,             Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   478
            {DoubleConsts.MIN_NORMAL,   1.0f,                   DoubleConsts.MIN_NORMAL+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   479
                                                                Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   480
            {DoubleConsts.MIN_NORMAL,   -1.0f,                  Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   481
            {DoubleConsts.MIN_NORMAL,   DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   482
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   483
            {Double_MAX_SUBNORMAL,      DoubleConsts.MIN_NORMAL,DoubleConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   484
            {Double_MAX_SUBNORMAL,      Double_MAX_SUBNORMAL,   Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   485
            {Double_MAX_SUBNORMAL,      0.0d,                   Double_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   486
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   487
            {Double_MAX_SUBNORMALmm,    Double_MAX_SUBNORMAL,   Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   488
            {Double_MAX_SUBNORMALmm,    0.0d,                   Double_MAX_SUBNORMALmm-Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   489
            {Double_MAX_SUBNORMALmm,    Double_MAX_SUBNORMALmm, Double_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   490
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   491
            {Double.MIN_VALUE,  0.0d,                   0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   492
            {-Double.MIN_VALUE, 0.0d,                   -0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   493
            {Double.MIN_VALUE,  Double.MIN_VALUE,       Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   494
            {Double.MIN_VALUE,  1.0f,                   2*Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   495
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   496
            // Make sure zero behavior is tested
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   497
            {0.0d,              0.0d,                   0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   498
            {0.0d,              -0.0d,                  -0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   499
            {-0.0d,             0.0d,                   0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   500
            {-0.0d,             -0.0d,                  -0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   501
            {0.0d,              infinityD,              Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   502
            {0.0d,              -infinityD,             -Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   503
            {-0.0d,             infinityD,              Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   504
            {-0.0d,             -infinityD,             -Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   505
            {0.0d,              Double.MIN_VALUE,       Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   506
            {0.0d,              -Double.MIN_VALUE,      -Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   507
            {-0.0d,             Double.MIN_VALUE,       Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   508
            {-0.0d,             -Double.MIN_VALUE,      -Double.MIN_VALUE}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   509
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   510
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   511
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   512
            failures += testNextAfterCase(testCases[i][0], testCases[i][1],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   513
                                          testCases[i][2]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   514
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   515
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   516
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   517
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   518
    /* ******************** nextUp tests ********************************* */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   519
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   520
    public static int testFloatNextUp() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   521
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   522
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   523
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   524
         * Each row of testCases represents one test case for nextUp;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   525
         * the first column is the input and the second column is the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   526
         * expected result.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   527
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   528
        float testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   529
            {NaNf,                      NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   530
            {-infinityF,                -Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   531
            {-Float.MAX_VALUE,          -Float_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   532
            {-FloatConsts.MIN_NORMAL,   -Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   533
            {-Float_MAX_SUBNORMAL,      -Float_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   534
            {-Float.MIN_VALUE,          -0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   535
            {-0.0f,                     Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   536
            {+0.0f,                     Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   537
            {Float.MIN_VALUE,           Float.MIN_VALUE*2},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   538
            {Float_MAX_SUBNORMALmm,     Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   539
            {Float_MAX_SUBNORMAL,       FloatConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   540
            {FloatConsts.MIN_NORMAL,    FloatConsts.MIN_NORMAL+Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   541
            {Float_MAX_VALUEmm,         Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   542
            {Float.MAX_VALUE,           infinityF},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   543
            {infinityF,                 infinityF}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   544
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   545
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   546
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   547
            failures+=Tests.test("Math.nextUp(float)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   548
                                 testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   549
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   550
            failures+=Tests.test("StrictMath.nextUp(float)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   551
                                 testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   552
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   553
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   554
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   555
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   556
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   557
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   558
    public static int testDoubleNextUp() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   559
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   560
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   561
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   562
         * Each row of testCases represents one test case for nextUp;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   563
         * the first column is the input and the second column is the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   564
         * expected result.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   565
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   566
        double testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   567
            {NaNd,                      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   568
            {-infinityD,                -Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   569
            {-Double.MAX_VALUE,         -Double_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   570
            {-DoubleConsts.MIN_NORMAL,  -Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   571
            {-Double_MAX_SUBNORMAL,     -Double_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   572
            {-Double.MIN_VALUE,         -0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   573
            {-0.0d,                     Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   574
            {+0.0d,                     Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   575
            {Double.MIN_VALUE,          Double.MIN_VALUE*2},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   576
            {Double_MAX_SUBNORMALmm,    Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   577
            {Double_MAX_SUBNORMAL,      DoubleConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   578
            {DoubleConsts.MIN_NORMAL,   DoubleConsts.MIN_NORMAL+Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   579
            {Double_MAX_VALUEmm,        Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   580
            {Double.MAX_VALUE,          infinityD},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   581
            {infinityD,                 infinityD}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   582
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   583
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   584
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   585
            failures+=Tests.test("Math.nextUp(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   586
                                 testCases[i][0], Math.nextUp(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   587
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   588
            failures+=Tests.test("StrictMath.nextUp(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   589
                                 testCases[i][0], StrictMath.nextUp(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   590
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   591
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   592
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   593
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   594
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   595
    /* ******************** nextDown tests ********************************* */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   596
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   597
    public static int testFloatNextDown() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   598
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   599
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   600
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   601
         * Each row of testCases represents one test case for nextDown;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   602
         * the first column is the input and the second column is the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   603
         * expected result.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   604
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   605
        float testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   606
            {NaNf,                      NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   607
            {-infinityF,                -infinityF},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   608
            {-Float.MAX_VALUE,          -infinityF},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   609
            {-Float_MAX_VALUEmm,        -Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   610
            {-Float_MAX_SUBNORMAL,      -FloatConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   611
            {-Float_MAX_SUBNORMALmm,    -Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   612
            {-0.0f,                     -Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   613
            {+0.0f,                     -Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   614
            {Float.MIN_VALUE,           0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   615
            {Float.MIN_VALUE*2,         Float.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   616
            {Float_MAX_SUBNORMAL,       Float_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   617
            {FloatConsts.MIN_NORMAL,    Float_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   618
            {FloatConsts.MIN_NORMAL+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   619
             Float.MIN_VALUE,           FloatConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   620
            {Float.MAX_VALUE,           Float_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   621
            {infinityF,                 Float.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   622
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   623
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   624
        for(int i = 0; i < testCases.length; i++) {
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   625
            failures+=Tests.test("Math.nextDown(float)",
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   626
                                 testCases[i][0], Math.nextDown(testCases[i][0]), testCases[i][1]);
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   627
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   628
            failures+=Tests.test("StrictMath.nextDown(float)",
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   629
                                 testCases[i][0], StrictMath.nextDown(testCases[i][0]), testCases[i][1]);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   630
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   631
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   632
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   633
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   634
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   635
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   636
    public static int testDoubleNextDown() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   637
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   638
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   639
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   640
         * Each row of testCases represents one test case for nextDown;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   641
         * the first column is the input and the second column is the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   642
         * expected result.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   643
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   644
        double testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   645
            {NaNd,                      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   646
            {-infinityD,                -infinityD},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   647
            {-Double.MAX_VALUE,         -infinityD},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   648
            {-Double_MAX_VALUEmm,       -Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   649
            {-Double_MAX_SUBNORMAL,     -DoubleConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   650
            {-Double_MAX_SUBNORMALmm,   -Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   651
            {-0.0d,                     -Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   652
            {+0.0d,                     -Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   653
            {Double.MIN_VALUE,          0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   654
            {Double.MIN_VALUE*2,        Double.MIN_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   655
            {Double_MAX_SUBNORMAL,      Double_MAX_SUBNORMALmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   656
            {DoubleConsts.MIN_NORMAL,   Double_MAX_SUBNORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   657
            {DoubleConsts.MIN_NORMAL+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   658
             Double.MIN_VALUE,          DoubleConsts.MIN_NORMAL},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   659
            {Double.MAX_VALUE,          Double_MAX_VALUEmm},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   660
            {infinityD,                 Double.MAX_VALUE},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   661
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   662
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   663
        for(int i = 0; i < testCases.length; i++) {
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   664
            failures+=Tests.test("Math.nextDown(double)",
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   665
                                 testCases[i][0], Math.nextDown(testCases[i][0]), testCases[i][1]);
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   666
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   667
            failures+=Tests.test("StrictMath.nextDown(double)",
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   668
                                 testCases[i][0], StrictMath.nextDown(testCases[i][0]), testCases[i][1]);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   669
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   670
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   671
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   672
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   673
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   674
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   675
    /* ********************** boolean tests ****************************** */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   676
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   677
    /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   678
     * Combined tests for boolean functions, isFinite, isInfinite,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   679
     * isNaN, isUnordered.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   680
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   681
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   682
    public static int testFloatBooleanMethods() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   683
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   684
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   685
        float testCases [] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   686
            NaNf,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   687
            -infinityF,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   688
            infinityF,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   689
            -Float.MAX_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   690
            -3.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   691
            -1.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   692
            -FloatConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   693
            -Float_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   694
            -Float_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   695
            -Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   696
            -0.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   697
            +0.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   698
            Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   699
            Float_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   700
            Float_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   701
            FloatConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   702
            1.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   703
            3.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   704
            Float_MAX_VALUEmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   705
            Float.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   706
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   707
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   708
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   709
            // isNaN
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   710
            failures+=Tests.test("Float.isNaN(float)", testCases[i],
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   711
                                 Float.isNaN(testCases[i]), (i ==0));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   712
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   713
            // isFinite
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   714
            failures+=Tests.test("Float.isFinite(float)", testCases[i],
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   715
                                 Float.isFinite(testCases[i]), (i >= 3));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   716
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   717
            // isInfinite
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   718
            failures+=Tests.test("Float.isInfinite(float)", testCases[i],
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   719
                                 Float.isInfinite(testCases[i]), (i==1 || i==2));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   720
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   721
            // isUnorderd
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   722
            for(int j = 0; j < testCases.length; j++) {
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   723
                failures+=Tests.test("Tests.isUnordered(float, float)", testCases[i],testCases[j],
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   724
                                     Tests.isUnordered(testCases[i],testCases[j]), (i==0 || j==0));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   725
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   726
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   727
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   728
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   729
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   730
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   731
    public static int testDoubleBooleanMethods() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   732
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   733
        boolean result = false;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   734
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   735
        double testCases [] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   736
            NaNd,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   737
            -infinityD,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   738
            infinityD,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   739
            -Double.MAX_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   740
            -3.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   741
            -1.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   742
            -DoubleConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   743
            -Double_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   744
            -Double_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   745
            -Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   746
            -0.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   747
            +0.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   748
            Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   749
            Double_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   750
            Double_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   751
            DoubleConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   752
            1.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   753
            3.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   754
            Double_MAX_VALUEmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   755
            Double.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   756
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   757
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   758
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   759
            // isNaN
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   760
            failures+=Tests.test("Double.isNaN(double)", testCases[i],
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   761
                                 Double.isNaN(testCases[i]), (i ==0));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   762
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   763
            // isFinite
10608
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   764
            failures+=Tests.test("Double.isFinite(double)", testCases[i],
7cfca36fc79b 7092404: Add Math.nextDown and Double.isFinite
darcy
parents: 10598
diff changeset
   765
                                 Double.isFinite(testCases[i]), (i >= 3));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   766
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   767
            // isInfinite
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   768
            failures+=Tests.test("Double.isInfinite(double)", testCases[i],
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   769
                                 Double.isInfinite(testCases[i]), (i==1 || i==2));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   770
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   771
            // isUnorderd
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   772
            for(int j = 0; j < testCases.length; j++) {
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   773
                failures+=Tests.test("Tests.isUnordered(double, double)", testCases[i],testCases[j],
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
   774
                                     Tests.isUnordered(testCases[i],testCases[j]), (i==0 || j==0));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   775
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   776
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   777
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   778
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   779
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   780
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   781
    /* ******************** copySign tests******************************** */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   782
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   783
   public static int testFloatCopySign() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   784
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   785
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   786
        // testCases[0] are logically positive numbers;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   787
        // testCases[1] are negative numbers.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   788
        float testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   789
            {+0.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   790
             Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   791
             Float_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   792
             Float_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   793
             FloatConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   794
             1.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   795
             3.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   796
             Float_MAX_VALUEmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   797
             Float.MAX_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   798
             infinityF,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   799
            },
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   800
            {-infinityF,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   801
             -Float.MAX_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   802
             -3.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   803
             -1.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   804
             -FloatConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   805
             -Float_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   806
             -Float_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   807
             -Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   808
             -0.0f}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   809
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   810
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   811
        float NaNs[] = {Float.intBitsToFloat(0x7fc00000),       // "positive" NaN
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   812
                        Float.intBitsToFloat(0xFfc00000)};      // "negative" NaN
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   813
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   814
        // Tests shared between raw and non-raw versions
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   815
        for(int i = 0; i < 2; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   816
            for(int j = 0; j < 2; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   817
                for(int m = 0; m < testCases[i].length; m++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   818
                    for(int n = 0; n < testCases[j].length; n++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   819
                        // copySign(magnitude, sign)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   820
                        failures+=Tests.test("Math.copySign(float,float)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   821
                                             testCases[i][m],testCases[j][n],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   822
                                             Math.copySign(testCases[i][m], testCases[j][n]),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   823
                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   824
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   825
                        failures+=Tests.test("StrictMath.copySign(float,float)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   826
                                             testCases[i][m],testCases[j][n],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   827
                                             StrictMath.copySign(testCases[i][m], testCases[j][n]),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   828
                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   829
                    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   830
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   831
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   832
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   833
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   834
        // For rawCopySign, NaN may effectively have either sign bit
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   835
        // while for copySign NaNs are treated as if they always have
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   836
        // a zero sign bit (i.e. as positive numbers)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   837
        for(int i = 0; i < 2; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   838
            for(int j = 0; j < NaNs.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   839
                for(int m = 0; m < testCases[i].length; m++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   840
                    // copySign(magnitude, sign)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   841
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   842
                    failures += (Math.abs(Math.copySign(testCases[i][m], NaNs[j])) ==
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   843
                                 Math.abs(testCases[i][m])) ? 0:1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   844
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   845
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   846
                    failures+=Tests.test("StrictMath.copySign(float,float)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   847
                                         testCases[i][m], NaNs[j],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   848
                                         StrictMath.copySign(testCases[i][m], NaNs[j]),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   849
                                         Math.abs(testCases[i][m]) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   850
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   851
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   852
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   853
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   854
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   855
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   856
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   857
    public static int testDoubleCopySign() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   858
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   859
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   860
        // testCases[0] are logically positive numbers;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   861
        // testCases[1] are negative numbers.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   862
        double testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   863
            {+0.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   864
             Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   865
             Double_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   866
             Double_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   867
             DoubleConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   868
             1.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   869
             3.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   870
             Double_MAX_VALUEmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   871
             Double.MAX_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   872
             infinityD,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   873
            },
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   874
            {-infinityD,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   875
             -Double.MAX_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   876
             -3.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   877
             -1.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   878
             -DoubleConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   879
             -Double_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   880
             -Double_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   881
             -Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   882
             -0.0d}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   883
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   884
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   885
        double NaNs[] = {Double.longBitsToDouble(0x7ff8000000000000L),  // "positive" NaN
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   886
                         Double.longBitsToDouble(0xfff8000000000000L),  // "negative" NaN
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   887
                         Double.longBitsToDouble(0x7FF0000000000001L),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   888
                         Double.longBitsToDouble(0xFFF0000000000001L),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   889
                         Double.longBitsToDouble(0x7FF8555555555555L),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   890
                         Double.longBitsToDouble(0xFFF8555555555555L),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   891
                         Double.longBitsToDouble(0x7FFFFFFFFFFFFFFFL),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   892
                         Double.longBitsToDouble(0xFFFFFFFFFFFFFFFFL),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   893
                         Double.longBitsToDouble(0x7FFDeadBeef00000L),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   894
                         Double.longBitsToDouble(0xFFFDeadBeef00000L),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   895
                         Double.longBitsToDouble(0x7FFCafeBabe00000L),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   896
                         Double.longBitsToDouble(0xFFFCafeBabe00000L)};
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   897
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   898
        // Tests shared between Math and StrictMath versions
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   899
        for(int i = 0; i < 2; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   900
            for(int j = 0; j < 2; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   901
                for(int m = 0; m < testCases[i].length; m++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   902
                    for(int n = 0; n < testCases[j].length; n++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   903
                        // copySign(magnitude, sign)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   904
                        failures+=Tests.test("MathcopySign(double,double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   905
                                             testCases[i][m],testCases[j][n],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   906
                                             Math.copySign(testCases[i][m], testCases[j][n]),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   907
                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   908
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   909
                        failures+=Tests.test("StrictMath.copySign(double,double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   910
                                             testCases[i][m],testCases[j][n],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   911
                                             StrictMath.copySign(testCases[i][m], testCases[j][n]),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   912
                                             (j==0?1.0f:-1.0f)*Math.abs(testCases[i][m]) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   913
                    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   914
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   915
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   916
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   917
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   918
        // For Math.copySign, NaN may effectively have either sign bit
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   919
        // while for StrictMath.copySign NaNs are treated as if they
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   920
        // always have a zero sign bit (i.e. as positive numbers)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   921
        for(int i = 0; i < 2; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   922
            for(int j = 0; j < NaNs.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   923
                for(int m = 0; m < testCases[i].length; m++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   924
                    // copySign(magnitude, sign)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   925
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   926
                    failures += (Math.abs(Math.copySign(testCases[i][m], NaNs[j])) ==
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   927
                                 Math.abs(testCases[i][m])) ? 0:1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   928
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   929
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   930
                    failures+=Tests.test("StrictMath.copySign(double,double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   931
                                         testCases[i][m], NaNs[j],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   932
                                         StrictMath.copySign(testCases[i][m], NaNs[j]),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   933
                                         Math.abs(testCases[i][m]) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   934
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   935
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   936
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   937
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   938
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   939
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   940
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   941
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   942
    /* ************************ scalb tests ******************************* */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   943
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   944
    static int testScalbCase(float value, int scale_factor, float expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   945
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   946
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   947
        failures+=Tests.test("Math.scalb(float,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   948
                             value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   949
                             Math.scalb(value, scale_factor), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   950
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   951
        failures+=Tests.test("Math.scalb(float,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   952
                             -value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   953
                             Math.scalb(-value, scale_factor), -expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   954
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   955
        failures+=Tests.test("StrictMath.scalb(float,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   956
                             value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   957
                             StrictMath.scalb(value, scale_factor), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   958
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   959
        failures+=Tests.test("StrictMath.scalb(float,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   960
                             -value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   961
                             StrictMath.scalb(-value, scale_factor), -expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   962
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   963
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   964
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   965
    public static int testFloatScalb() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   966
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   967
        int MAX_SCALE = FloatConsts.MAX_EXPONENT + -FloatConsts.MIN_EXPONENT +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   968
                        FloatConsts.SIGNIFICAND_WIDTH + 1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   969
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   970
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   971
        // Arguments x, where scalb(x,n) is x for any n.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   972
        float [] identityTestCases = {NaNf,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   973
                                      -0.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   974
                                      +0.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   975
                                      infinityF,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   976
                                      -infinityF
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   977
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   978
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   979
        float [] subnormalTestCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   980
            Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   981
            3.0f*Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   982
            Float_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   983
            Float_MAX_SUBNORMAL
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   984
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   985
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   986
        float [] someTestCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   987
            Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   988
            3.0f*Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   989
            Float_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   990
            Float_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   991
            FloatConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   992
            1.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   993
            2.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   994
            3.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   995
            (float)Math.PI,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   996
            Float_MAX_VALUEmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   997
            Float.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   998
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   999
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1000
        int [] oneMultiplyScalingFactors = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1001
            FloatConsts.MIN_EXPONENT,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1002
            FloatConsts.MIN_EXPONENT+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1003
            -3,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1004
            -2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1005
            -1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1006
            0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1007
            1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1008
            2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1009
            3,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1010
            FloatConsts.MAX_EXPONENT-1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1011
            FloatConsts.MAX_EXPONENT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1012
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1013
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1014
        int [] manyScalingFactors = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1015
            Integer.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1016
            Integer.MIN_VALUE+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1017
            -MAX_SCALE -1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1018
            -MAX_SCALE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1019
            -MAX_SCALE+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1020
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1021
            2*FloatConsts.MIN_EXPONENT-1,       // -253
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1022
            2*FloatConsts.MIN_EXPONENT,         // -252
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1023
            2*FloatConsts.MIN_EXPONENT+1,       // -251
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1024
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
  1025
            FloatConsts.MIN_EXPONENT - FloatConsts.SIGNIFICAND_WIDTH,
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
  1026
            FloatConsts.MIN_SUB_EXPONENT,
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1027
            -FloatConsts.MAX_EXPONENT,          // -127
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1028
            FloatConsts.MIN_EXPONENT,           // -126
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1029
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1030
            -2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1031
            -1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1032
            0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1033
            1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1034
            2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1035
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1036
            FloatConsts.MAX_EXPONENT-1,         // 126
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1037
            FloatConsts.MAX_EXPONENT,           // 127
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1038
            FloatConsts.MAX_EXPONENT+1,         // 128
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1039
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1040
            2*FloatConsts.MAX_EXPONENT-1,       // 253
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1041
            2*FloatConsts.MAX_EXPONENT,         // 254
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1042
            2*FloatConsts.MAX_EXPONENT+1,       // 255
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1043
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1044
            MAX_SCALE-1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1045
            MAX_SCALE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1046
            MAX_SCALE+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1047
            Integer.MAX_VALUE-1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1048
            Integer.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1049
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1050
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1051
        // Test cases where scaling is always a no-op
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1052
        for(int i=0; i < identityTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1053
            for(int j=0; j < manyScalingFactors.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1054
                failures += testScalbCase(identityTestCases[i],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1055
                                          manyScalingFactors[j],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1056
                                          identityTestCases[i]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1057
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1058
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1059
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1060
        // Test cases where result is 0.0 or infinity due to magnitude
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1061
        // of the scaling factor
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1062
        for(int i=0; i < someTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1063
            for(int j=0; j < manyScalingFactors.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1064
                int scaleFactor = manyScalingFactors[j];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1065
                if (Math.abs(scaleFactor) >= MAX_SCALE) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1066
                    float value = someTestCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1067
                    failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1068
                                            scaleFactor,
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1069
                                            Math.copySign( (scaleFactor>0?infinityF:0.0f), value) );
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1070
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1071
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1072
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1073
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1074
        // Test cases that could be done with one floating-point
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1075
        // multiply.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1076
        for(int i=0; i < someTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1077
            for(int j=0; j < oneMultiplyScalingFactors.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1078
                int scaleFactor = oneMultiplyScalingFactors[j];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1079
                    float value = someTestCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1080
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1081
                    failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1082
                                            scaleFactor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1083
                                            value*powerOfTwoF(scaleFactor));
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1084
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1085
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1086
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1087
        // Create 2^MAX_EXPONENT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1088
        float twoToTheMaxExp = 1.0f; // 2^0
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1089
        for(int i = 0; i < FloatConsts.MAX_EXPONENT; i++)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1090
            twoToTheMaxExp *=2.0f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1091
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1092
        // Scale-up subnormal values until they all overflow
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1093
        for(int i=0; i < subnormalTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1094
            float scale = 1.0f; // 2^j
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1095
            float value = subnormalTestCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1096
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1097
            for(int j=FloatConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1098
                int scaleFactor = j;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1099
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1100
                failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1101
                                        scaleFactor,
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
  1102
                                        (Tests.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ?
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1103
                                        Math.copySign(infinityF, value) : // overflow
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1104
                                        // calculate right answer
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1105
                                        twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1106
                scale*=2.0f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1107
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1108
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1109
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1110
        // Scale down a large number until it underflows.  By scaling
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1111
        // down MAX_NORMALmm, the first subnormal result will be exact
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1112
        // but the next one will round -- all those results can be
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1113
        // checked by halving a separate value in the loop.  Actually,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1114
        // we can keep halving and checking until the product is zero
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1115
        // since:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1116
        //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1117
        // 1. If the scalb of MAX_VALUEmm is subnormal and *not* exact
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1118
        // it will round *up*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1119
        //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1120
        // 2. When rounding first occurs in the expected product, it
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1121
        // too rounds up, to 2^-MAX_EXPONENT.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1122
        //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1123
        // Halving expected after rounding happends to give the same
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1124
        // result as the scalb operation.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1125
        float expected = Float_MAX_VALUEmm *0.5f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1126
        for(int i = -1; i > -MAX_SCALE; i--) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1127
            failures+=testScalbCase(Float_MAX_VALUEmm, i, expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1128
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1129
            expected *= 0.5f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1130
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1131
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1132
        // Tricky rounding tests:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1133
        // Scale down a large number into subnormal range such that if
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1134
        // scalb is being implemented with multiple floating-point
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1135
        // multiplies, the value would round twice if the multiplies
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1136
        // were done in the wrong order.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1137
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1138
        float value = 0x8.0000bP-5f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1139
        expected = 0x1.00001p-129f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1140
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1141
        for(int i = 0; i < 129; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1142
            failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1143
                                    -127-i,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1144
                                    expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1145
            value *=2.0f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1146
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1147
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1148
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1149
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1150
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1151
    static int testScalbCase(double value, int scale_factor, double expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1152
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1153
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1154
        failures+=Tests.test("Math.scalb(double,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1155
                             value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1156
                             Math.scalb(value, scale_factor), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1157
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1158
        failures+=Tests.test("Math.scalb(double,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1159
                             -value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1160
                             Math.scalb(-value, scale_factor), -expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1161
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1162
        failures+=Tests.test("StrictMath.scalb(double,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1163
                             value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1164
                             StrictMath.scalb(value, scale_factor), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1165
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1166
        failures+=Tests.test("StrictMath.scalb(double,int)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1167
                             -value, scale_factor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1168
                             StrictMath.scalb(-value, scale_factor), -expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1169
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1170
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1171
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1172
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1173
    public static int testDoubleScalb() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1174
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1175
        int MAX_SCALE = DoubleConsts.MAX_EXPONENT + -DoubleConsts.MIN_EXPONENT +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1176
                        DoubleConsts.SIGNIFICAND_WIDTH + 1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1177
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1178
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1179
        // Arguments x, where scalb(x,n) is x for any n.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1180
        double [] identityTestCases = {NaNd,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1181
                                      -0.0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1182
                                      +0.0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1183
                                      infinityD,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1184
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1185
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1186
        double [] subnormalTestCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1187
            Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1188
            3.0d*Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1189
            Double_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1190
            Double_MAX_SUBNORMAL
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1191
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1192
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1193
        double [] someTestCases = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1194
            Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1195
            3.0d*Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1196
            Double_MAX_SUBNORMALmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1197
            Double_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1198
            DoubleConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1199
            1.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1200
            2.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1201
            3.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1202
            Math.PI,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1203
            Double_MAX_VALUEmm,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1204
            Double.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1205
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1206
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1207
        int [] oneMultiplyScalingFactors = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1208
            DoubleConsts.MIN_EXPONENT,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1209
            DoubleConsts.MIN_EXPONENT+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1210
            -3,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1211
            -2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1212
            -1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1213
            0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1214
            1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1215
            2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1216
            3,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1217
            DoubleConsts.MAX_EXPONENT-1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1218
            DoubleConsts.MAX_EXPONENT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1219
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1220
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1221
        int [] manyScalingFactors = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1222
            Integer.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1223
            Integer.MIN_VALUE+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1224
            -MAX_SCALE -1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1225
            -MAX_SCALE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1226
            -MAX_SCALE+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1227
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1228
            2*DoubleConsts.MIN_EXPONENT-1,      // -2045
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1229
            2*DoubleConsts.MIN_EXPONENT,        // -2044
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1230
            2*DoubleConsts.MIN_EXPONENT+1,      // -2043
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1231
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
  1232
            DoubleConsts.MIN_EXPONENT,          // -1022
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
  1233
            DoubleConsts.MIN_EXPONENT - DoubleConsts.SIGNIFICAND_WIDTH,
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
  1234
            DoubleConsts.MIN_SUB_EXPONENT,
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1235
            -DoubleConsts.MAX_EXPONENT,         // -1023
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1236
            DoubleConsts.MIN_EXPONENT,          // -1022
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1237
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1238
            -2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1239
            -1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1240
            0,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1241
            1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1242
            2,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1243
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1244
            DoubleConsts.MAX_EXPONENT-1,        // 1022
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1245
            DoubleConsts.MAX_EXPONENT,          // 1023
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1246
            DoubleConsts.MAX_EXPONENT+1,        // 1024
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1247
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1248
            2*DoubleConsts.MAX_EXPONENT-1,      // 2045
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1249
            2*DoubleConsts.MAX_EXPONENT,        // 2046
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1250
            2*DoubleConsts.MAX_EXPONENT+1,      // 2047
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1251
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1252
            MAX_SCALE-1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1253
            MAX_SCALE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1254
            MAX_SCALE+1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1255
            Integer.MAX_VALUE-1,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1256
            Integer.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1257
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1258
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1259
        // Test cases where scaling is always a no-op
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1260
        for(int i=0; i < identityTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1261
            for(int j=0; j < manyScalingFactors.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1262
                failures += testScalbCase(identityTestCases[i],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1263
                                          manyScalingFactors[j],
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1264
                                          identityTestCases[i]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1265
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1266
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1267
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1268
        // Test cases where result is 0.0 or infinity due to magnitude
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1269
        // of the scaling factor
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1270
        for(int i=0; i < someTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1271
            for(int j=0; j < manyScalingFactors.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1272
                int scaleFactor = manyScalingFactors[j];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1273
                if (Math.abs(scaleFactor) >= MAX_SCALE) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1274
                    double value = someTestCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1275
                    failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1276
                                            scaleFactor,
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1277
                                            Math.copySign( (scaleFactor>0?infinityD:0.0), value) );
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1278
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1279
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1280
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1281
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1282
        // Test cases that could be done with one floating-point
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1283
        // multiply.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1284
        for(int i=0; i < someTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1285
            for(int j=0; j < oneMultiplyScalingFactors.length; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1286
                int scaleFactor = oneMultiplyScalingFactors[j];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1287
                    double value = someTestCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1288
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1289
                    failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1290
                                            scaleFactor,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1291
                                            value*powerOfTwoD(scaleFactor));
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1292
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1293
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1294
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1295
        // Create 2^MAX_EXPONENT
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1296
        double twoToTheMaxExp = 1.0; // 2^0
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1297
        for(int i = 0; i < DoubleConsts.MAX_EXPONENT; i++)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1298
            twoToTheMaxExp *=2.0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1299
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1300
        // Scale-up subnormal values until they all overflow
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1301
        for(int i=0; i < subnormalTestCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1302
            double scale = 1.0; // 2^j
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1303
            double value = subnormalTestCases[i];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1304
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1305
            for(int j=DoubleConsts.MAX_EXPONENT*2; j < MAX_SCALE; j++) { // MAX_SCALE -1 should cause overflow
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1306
                int scaleFactor = j;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1307
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1308
                failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1309
                                        scaleFactor,
22634
9c18aebe9229 8033416: Remove sun.misc.FpUtils
darcy
parents: 10608
diff changeset
  1310
                                        (Tests.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ?
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1311
                                        Math.copySign(infinityD, value) : // overflow
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1312
                                        // calculate right answer
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1313
                                        twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1314
                scale*=2.0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1315
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1316
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1317
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1318
        // Scale down a large number until it underflows.  By scaling
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1319
        // down MAX_NORMALmm, the first subnormal result will be exact
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1320
        // but the next one will round -- all those results can be
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1321
        // checked by halving a separate value in the loop.  Actually,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1322
        // we can keep halving and checking until the product is zero
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1323
        // since:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1324
        //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1325
        // 1. If the scalb of MAX_VALUEmm is subnormal and *not* exact
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1326
        // it will round *up*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1327
        //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1328
        // 2. When rounding first occurs in the expected product, it
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1329
        // too rounds up, to 2^-MAX_EXPONENT.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1330
        //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1331
        // Halving expected after rounding happends to give the same
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1332
        // result as the scalb operation.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1333
        double expected = Double_MAX_VALUEmm *0.5f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1334
        for(int i = -1; i > -MAX_SCALE; i--) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1335
            failures+=testScalbCase(Double_MAX_VALUEmm, i, expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1336
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1337
            expected *= 0.5;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1338
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1339
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1340
        // Tricky rounding tests:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1341
        // Scale down a large number into subnormal range such that if
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1342
        // scalb is being implemented with multiple floating-point
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1343
        // multiplies, the value would round twice if the multiplies
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1344
        // were done in the wrong order.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1345
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1346
        double value = 0x1.000000000000bP-1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1347
        expected     = 0x0.2000000000001P-1022;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1348
        for(int i = 0; i < DoubleConsts.MAX_EXPONENT+2; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1349
            failures+=testScalbCase(value,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1350
                                    -1024-i,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1351
                                    expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1352
            value *=2.0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1353
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1354
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1355
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1356
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1357
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1358
    /* ************************* ulp tests ******************************* */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1359
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1360
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1361
    /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1362
     * Test Math.ulp and StrictMath.ulp with +d and -d.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1363
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1364
    static int testUlpCase(float f, float expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1365
        float minus_f = -f;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1366
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1367
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1368
        failures+=Tests.test("Math.ulp(float)", f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1369
                             Math.ulp(f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1370
        failures+=Tests.test("Math.ulp(float)", minus_f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1371
                             Math.ulp(minus_f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1372
        failures+=Tests.test("StrictMath.ulp(float)", f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1373
                             StrictMath.ulp(f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1374
        failures+=Tests.test("StrictMath.ulp(float)", minus_f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1375
                             StrictMath.ulp(minus_f), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1376
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1377
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1378
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1379
    static int testUlpCase(double d, double expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1380
        double minus_d = -d;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1381
        int failures=0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1382
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1383
        failures+=Tests.test("Math.ulp(double)", d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1384
                             Math.ulp(d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1385
        failures+=Tests.test("Math.ulp(double)", minus_d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1386
                             Math.ulp(minus_d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1387
        failures+=Tests.test("StrictMath.ulp(double)", d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1388
                             StrictMath.ulp(d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1389
        failures+=Tests.test("StrictMath.ulp(double)", minus_d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1390
                             StrictMath.ulp(minus_d), expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1391
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1392
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1393
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1394
    public static int testFloatUlp() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1395
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1396
        float [] specialValues = {NaNf,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1397
                                  Float.POSITIVE_INFINITY,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1398
                                  +0.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1399
                                  +1.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1400
                                  +2.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1401
                                  +16.0f,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1402
                                  +Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1403
                                  +Float_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1404
                                  +FloatConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1405
                                  +Float.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1406
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1407
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1408
        float [] specialResults = {NaNf,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1409
                                   Float.POSITIVE_INFINITY,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1410
                                   Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1411
                                   powerOfTwoF(-23),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1412
                                   powerOfTwoF(-22),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1413
                                   powerOfTwoF(-19),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1414
                                   Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1415
                                   Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1416
                                   Float.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1417
                                   powerOfTwoF(104)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1418
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1419
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1420
        // Special value tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1421
        for(int i = 0; i < specialValues.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1422
            failures += testUlpCase(specialValues[i], specialResults[i]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1423
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1424
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1425
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1426
        // Normal exponent tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1427
        for(int i = FloatConsts.MIN_EXPONENT; i <= FloatConsts.MAX_EXPONENT; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1428
            float expected;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1429
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1430
            // Create power of two
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1431
            float po2 = powerOfTwoF(i);
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1432
            expected = Math.scalb(1.0f, i - (FloatConsts.SIGNIFICAND_WIDTH-1));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1433
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1434
            failures += testUlpCase(po2, expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1435
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1436
            // Generate some random bit patterns for the significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1437
            for(int j = 0; j < 10; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1438
                int randSignif = rand.nextInt();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1439
                float randFloat;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1440
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1441
                randFloat = Float.intBitsToFloat( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1442
                                                 (Float.floatToIntBits(po2)&
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1443
                                                  (~FloatConsts.SIGNIF_BIT_MASK)) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1444
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1445
                                                 (randSignif &
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1446
                                                  FloatConsts.SIGNIF_BIT_MASK) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1447
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1448
                failures += testUlpCase(randFloat, expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1449
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1450
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1451
            if (i > FloatConsts.MIN_EXPONENT) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1452
                float po2minus = Math.nextAfter(po2,
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1453
                                                   Float.NEGATIVE_INFINITY);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1454
                failures += testUlpCase(po2minus, expected/2.0f);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1455
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1456
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1457
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1458
        // Subnormal tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1459
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1460
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1461
         * Start with MIN_VALUE, left shift, test high value, low
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1462
         * values, and random in between.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1463
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1464
         * Use nextAfter to calculate, high value of previous binade,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1465
         * loop count i will indicate how many random bits, if any are
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1466
         * needed.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1467
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1468
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1469
        float top=Float.MIN_VALUE;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1470
        for( int i = 1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1471
            i < FloatConsts.SIGNIFICAND_WIDTH;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1472
            i++, top *= 2.0f) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1473
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1474
            failures += testUlpCase(top, Float.MIN_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1475
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1476
            // Test largest value in next smaller binade
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1477
            if (i >= 3) {// (i == 1) would test 0.0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1478
                         // (i == 2) would just retest MIN_VALUE
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1479
                testUlpCase(Math.nextAfter(top, 0.0f),
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1480
                            Float.MIN_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1481
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1482
                if( i >= 10) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1483
                    // create a bit mask with (i-1) 1's in the low order
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1484
                    // bits
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1485
                    int mask = ~((~0)<<(i-1));
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1486
                    float randFloat = Float.intBitsToFloat( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1487
                                                 Float.floatToIntBits(top) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1488
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1489
                                                 (rand.nextInt() & mask ) ) ;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1490
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1491
                    failures += testUlpCase(randFloat, Float.MIN_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1492
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1493
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1494
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1495
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1496
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1497
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1498
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1499
    public static int testDoubleUlp() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1500
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1501
        double [] specialValues = {NaNd,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1502
                                  Double.POSITIVE_INFINITY,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1503
                                  +0.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1504
                                  +1.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1505
                                  +2.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1506
                                  +16.0d,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1507
                                  +Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1508
                                  +Double_MAX_SUBNORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1509
                                  +DoubleConsts.MIN_NORMAL,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1510
                                  +Double.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1511
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1512
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1513
        double [] specialResults = {NaNf,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1514
                                   Double.POSITIVE_INFINITY,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1515
                                   Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1516
                                   powerOfTwoD(-52),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1517
                                   powerOfTwoD(-51),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1518
                                   powerOfTwoD(-48),
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1519
                                   Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1520
                                   Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1521
                                   Double.MIN_VALUE,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1522
                                   powerOfTwoD(971)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1523
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1524
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1525
        // Special value tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1526
        for(int i = 0; i < specialValues.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1527
            failures += testUlpCase(specialValues[i], specialResults[i]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1528
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1529
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1530
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1531
        // Normal exponent tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1532
        for(int i = DoubleConsts.MIN_EXPONENT; i <= DoubleConsts.MAX_EXPONENT; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1533
            double expected;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1534
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1535
            // Create power of two
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1536
            double po2 = powerOfTwoD(i);
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1537
            expected = Math.scalb(1.0, i - (DoubleConsts.SIGNIFICAND_WIDTH-1));
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1538
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1539
            failures += testUlpCase(po2, expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1540
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1541
            // Generate some random bit patterns for the significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1542
            for(int j = 0; j < 10; j++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1543
                long randSignif = rand.nextLong();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1544
                double randDouble;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1545
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1546
                randDouble = Double.longBitsToDouble( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1547
                                                 (Double.doubleToLongBits(po2)&
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1548
                                                  (~DoubleConsts.SIGNIF_BIT_MASK)) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1549
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1550
                                                 (randSignif &
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1551
                                                  DoubleConsts.SIGNIF_BIT_MASK) );
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1552
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1553
                failures += testUlpCase(randDouble, expected);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1554
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1555
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1556
            if (i > DoubleConsts.MIN_EXPONENT) {
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1557
                double po2minus = Math.nextAfter(po2,
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1558
                                                    Double.NEGATIVE_INFINITY);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1559
                failures += testUlpCase(po2minus, expected/2.0f);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1560
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1561
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1562
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1563
        // Subnormal tests
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1564
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1565
        /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1566
         * Start with MIN_VALUE, left shift, test high value, low
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1567
         * values, and random in between.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1568
         *
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1569
         * Use nextAfter to calculate, high value of previous binade,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1570
         * loop count i will indicate how many random bits, if any are
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1571
         * needed.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1572
         */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1573
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1574
        double top=Double.MIN_VALUE;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1575
        for( int i = 1;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1576
            i < DoubleConsts.SIGNIFICAND_WIDTH;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1577
            i++, top *= 2.0f) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1578
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1579
            failures += testUlpCase(top, Double.MIN_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1580
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1581
            // Test largest value in next smaller binade
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1582
            if (i >= 3) {// (i == 1) would test 0.0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1583
                         // (i == 2) would just retest MIN_VALUE
10598
efd29b4b3e67 7091682: Move sun.misc.FpUtils code into java.lang.Math
darcy
parents: 5506
diff changeset
  1584
                testUlpCase(Math.nextAfter(top, 0.0f),
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1585
                            Double.MIN_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1586
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1587
                if( i >= 10) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1588
                    // create a bit mask with (i-1) 1's in the low order
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1589
                    // bits
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1590
                    int mask = ~((~0)<<(i-1));
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1591
                    double randDouble = Double.longBitsToDouble( // Exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1592
                                                 Double.doubleToLongBits(top) |
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1593
                                                 // Significand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1594
                                                 (rand.nextLong() & mask ) ) ;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1595
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1596
                    failures += testUlpCase(randDouble, Double.MIN_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1597
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1598
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1599
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1600
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1601
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1602
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1603
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1604
    public static int testFloatSignum() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1605
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1606
        float testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1607
            {NaNf,                      NaNf},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1608
            {-infinityF,                -1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1609
            {-Float.MAX_VALUE,          -1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1610
            {-FloatConsts.MIN_NORMAL,   -1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1611
            {-1.0f,                     -1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1612
            {-2.0f,                     -1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1613
            {-Float_MAX_SUBNORMAL,      -1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1614
            {-Float.MIN_VALUE,          -1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1615
            {-0.0f,                     -0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1616
            {+0.0f,                     +0.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1617
            {Float.MIN_VALUE,            1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1618
            {Float_MAX_SUBNORMALmm,      1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1619
            {Float_MAX_SUBNORMAL,        1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1620
            {FloatConsts.MIN_NORMAL,     1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1621
            {1.0f,                       1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1622
            {2.0f,                       1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1623
            {Float_MAX_VALUEmm,          1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1624
            {Float.MAX_VALUE,            1.0f},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1625
            {infinityF,                  1.0f}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1626
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1627
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1628
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1629
            failures+=Tests.test("Math.signum(float)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1630
                                 testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1631
            failures+=Tests.test("StrictMath.signum(float)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1632
                                 testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1633
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1634
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1635
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1636
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1637
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1638
    public static int testDoubleSignum() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1639
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1640
        double testCases [][] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1641
            {NaNd,                      NaNd},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1642
            {-infinityD,                -1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1643
            {-Double.MAX_VALUE,         -1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1644
            {-DoubleConsts.MIN_NORMAL,  -1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1645
            {-1.0,                      -1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1646
            {-2.0,                      -1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1647
            {-Double_MAX_SUBNORMAL,     -1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1648
            {-Double.MIN_VALUE,         -1.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1649
            {-0.0d,                     -0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1650
            {+0.0d,                     +0.0d},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1651
            {Double.MIN_VALUE,           1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1652
            {Double_MAX_SUBNORMALmm,     1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1653
            {Double_MAX_SUBNORMAL,       1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1654
            {DoubleConsts.MIN_NORMAL,    1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1655
            {1.0,                        1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1656
            {2.0,                        1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1657
            {Double_MAX_VALUEmm,         1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1658
            {Double.MAX_VALUE,           1.0},
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1659
            {infinityD,                  1.0}
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1660
        };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1661
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1662
        for(int i = 0; i < testCases.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1663
            failures+=Tests.test("Math.signum(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1664
                                 testCases[i][0], Math.signum(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1665
            failures+=Tests.test("StrictMath.signum(double)",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1666
                                 testCases[i][0], StrictMath.signum(testCases[i][0]), testCases[i][1]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1667
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1668
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1669
        return failures;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1670
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1671
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1672
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1673
    public static void main(String argv[]) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1674
        int failures = 0;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1675
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1676
        failures += testFloatGetExponent();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1677
        failures += testDoubleGetExponent();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1678
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1679
        failures += testFloatNextAfter();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1680
        failures += testDoubleNextAfter();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1681
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1682
        failures += testFloatNextUp();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1683
        failures += testDoubleNextUp();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1684
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1685
        failures += testFloatNextDown();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1686
        failures += testDoubleNextDown();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1687
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1688
        failures += testFloatBooleanMethods();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1689
        failures += testDoubleBooleanMethods();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1690
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1691
        failures += testFloatCopySign();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1692
        failures += testDoubleCopySign();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1693
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1694
        failures += testFloatScalb();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1695
        failures += testDoubleScalb();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1696
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1697
        failures += testFloatUlp();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1698
        failures += testDoubleUlp();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1699
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1700
        failures += testFloatSignum();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1701
        failures += testDoubleSignum();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1702
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1703
        if (failures > 0) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1704
            System.err.println("Testing the recommended functions incurred "
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1705
                               + failures + " failures.");
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1706
            throw new RuntimeException();
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1707
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1708
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
  1709
}