jdk/test/java/lang/Double/ParseDouble.java
author jwilhelm
Thu, 30 Oct 2014 01:01:37 +0100
changeset 27445 a8354c76ae20
parent 26722 eb30ed2a0bfe
permissions -rw-r--r--
Merge
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
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 18537
diff changeset
     2
 * Copyright (c) 2001, 2013, 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: 1826
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1826
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1826
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
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    26
 * @bug 4160406 4705734 4707389 4826774 4895911 4421494 6358355 7021568 7039369 4396272
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    27
 * @summary Test for Double.parseDouble method and acceptance regex
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    28
 */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    29
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    30
import java.math.BigDecimal;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    31
import java.math.BigInteger;
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    32
import java.util.regex.*;
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 ParseDouble {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
    35
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    36
    private static final BigDecimal HALF = BigDecimal.valueOf(0.5);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    37
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    38
    private static void fail(String val, double n) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    39
        throw new RuntimeException("Double.parseDouble failed. String:" +
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    40
                                                val + " Result:" + n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    41
    }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    42
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    43
    private static void check(String val) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    44
        double n = Double.parseDouble(val);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    45
        boolean isNegativeN = n < 0 || n == 0 && 1/n < 0;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    46
        double na = Math.abs(n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    47
        String s = val.trim().toLowerCase();
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    48
        switch (s.charAt(s.length() - 1)) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    49
            case 'd':
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    50
            case 'f':
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    51
                s = s.substring(0, s.length() - 1);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    52
                break;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    53
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    54
        boolean isNegative = false;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    55
        if (s.charAt(0) == '+') {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    56
            s = s.substring(1);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    57
        } else if (s.charAt(0) == '-') {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    58
            s = s.substring(1);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    59
            isNegative = true;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    60
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    61
        if (s.equals("nan")) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    62
            if (!Double.isNaN(n)) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    63
                fail(val, n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    64
            }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    65
            return;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    66
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    67
        if (Double.isNaN(n)) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    68
            fail(val, n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    69
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    70
        if (isNegativeN != isNegative)
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    71
            fail(val, n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    72
        if (s.equals("infinity")) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    73
            if (na != Double.POSITIVE_INFINITY) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    74
                fail(val, n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    75
            }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    76
            return;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    77
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    78
        BigDecimal bd;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    79
        if (s.startsWith("0x")) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    80
            s = s.substring(2);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    81
            int indP = s.indexOf('p');
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    82
            long exp = Long.parseLong(s.substring(indP + 1));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    83
            int indD = s.indexOf('.');
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    84
            String significand;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    85
            if (indD >= 0) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    86
                significand = s.substring(0, indD) + s.substring(indD + 1, indP);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    87
                exp -= 4*(indP - indD - 1);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    88
            } else {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    89
                significand = s.substring(0, indP);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    90
            }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    91
            bd = new BigDecimal(new BigInteger(significand, 16));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    92
            if (exp >= 0) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    93
                bd = bd.multiply(BigDecimal.valueOf(2).pow((int)exp));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    94
            } else {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    95
                bd = bd.divide(BigDecimal.valueOf(2).pow((int)-exp));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    96
            }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    97
        } else {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    98
            bd = new BigDecimal(s);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
    99
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   100
        BigDecimal l, u;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   101
        if (Double.isInfinite(na)) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   102
            l = new BigDecimal(Double.MAX_VALUE).add(new BigDecimal(Math.ulp(Double.MAX_VALUE)).multiply(HALF));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   103
            u = null;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   104
        } else {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   105
            l = new BigDecimal(na).subtract(new BigDecimal(Math.ulp(Math.nextUp(-na))).multiply(HALF));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   106
            u = new BigDecimal(na).add(new BigDecimal(Math.ulp(n)).multiply(HALF));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   107
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   108
        int cmpL = bd.compareTo(l);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   109
        int cmpU = u != null ? bd.compareTo(u) : -1;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   110
        if ((Double.doubleToLongBits(n) & 1) != 0) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   111
            if (cmpL <= 0 || cmpU >= 0) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   112
                fail(val, n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   113
            }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   114
        } else {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   115
            if (cmpL < 0 || cmpU > 0) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   116
                fail(val, n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   117
            }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   118
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   119
    }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   120
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   121
    private static void check(String val, double expected) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   122
        double n = Double.parseDouble(val);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   123
        if (n != expected)
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   124
            fail(val, n);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   125
        check(val);
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   126
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   127
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   128
    private static void rudimentaryTest() {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   129
        check(new String(""+Double.MIN_VALUE), Double.MIN_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   130
        check(new String(""+Double.MAX_VALUE), Double.MAX_VALUE);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   131
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   132
        check("10",     (double)  10.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   133
        check("10.0",   (double)  10.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   134
        check("10.01",  (double)  10.01);
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
        check("-10",    (double) -10.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   137
        check("-10.00", (double) -10.0);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   138
        check("-10.01", (double) -10.01);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   139
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   140
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   141
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   142
    static  String badStrings[] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   143
        "",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   144
        "+",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   145
        "-",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   146
        "+e",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   147
        "-e",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   148
        "+e170",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   149
        "-e170",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   150
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   151
        // Make sure intermediate white space is not deleted.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   152
        "1234   e10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   153
        "-1234   e10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   154
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   155
        // Control characters in the interior of a string are not legal
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   156
        "1\u0007e1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   157
        "1e\u00071",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   158
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   159
        // NaN and infinity can't have trailing type suffices or exponents
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   160
        "NaNf",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   161
        "NaNF",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   162
        "NaNd",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   163
        "NaND",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   164
        "-NaNf",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   165
        "-NaNF",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   166
        "-NaNd",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   167
        "-NaND",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   168
        "+NaNf",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   169
        "+NaNF",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   170
        "+NaNd",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   171
        "+NaND",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   172
        "Infinityf",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   173
        "InfinityF",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   174
        "Infinityd",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   175
        "InfinityD",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   176
        "-Infinityf",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   177
        "-InfinityF",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   178
        "-Infinityd",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   179
        "-InfinityD",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   180
        "+Infinityf",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   181
        "+InfinityF",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   182
        "+Infinityd",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   183
        "+InfinityD",
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
        "NaNe10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   186
        "-NaNe10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   187
        "+NaNe10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   188
        "Infinitye10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   189
        "-Infinitye10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   190
        "+Infinitye10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   191
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   192
        // Non-ASCII digits are not recognized
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   193
        "\u0661e\u0661", // 1e1 in Arabic-Indic digits
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   194
        "\u06F1e\u06F1", // 1e1 in Extended Arabic-Indic digits
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   195
        "\u0967e\u0967", // 1e1 in Devanagari digits
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   196
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   197
        // JCK test lex03592m3
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   198
        ".",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   199
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   200
        // JCK test lex03592m4
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   201
        "e42",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   202
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   203
        // JCK test lex03592m5
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   204
        ".e42",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   205
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   206
        // JCK test lex03592m6
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   207
        "d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   208
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   209
        // JCK test lex03592m7
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   210
        ".d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   211
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   212
        // JCK test lex03592m8
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   213
        "e42d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   214
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   215
        // JCK test lex03592m9
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   216
        ".e42d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   217
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   218
        // JCK test lex03593m10
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   219
        "1A01.01125e-10d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   220
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   221
        // JCK test lex03593m11
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   222
        "2;3.01125e-10d",
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
        // JCK test lex03593m12
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   225
        "1_34.01125e-10d",
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
        // JCK test lex03593m14
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   228
        "202..01125e-10d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   229
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   230
        // JCK test lex03593m15
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   231
        "202,01125e-10d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   232
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   233
        // JCK test lex03593m16
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   234
        "202.03b4e-10d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   235
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   236
        // JCK test lex03593m18
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   237
        "202.06_3e-10d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   238
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   239
        // JCK test lex03593m20
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   240
        "202.01125e-f0d",
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
        // JCK test lex03593m21
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   243
        "202.01125e_3d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   244
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   245
        // JCK test lex03593m22
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   246
        "202.01125e -5d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   247
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   248
        // JCK test lex03593m24
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   249
        "202.01125e-10r",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   250
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   251
        // JCK test lex03593m25
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   252
        "202.01125e-10ff",
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
        // JCK test lex03593m26
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   255
        "1234L.01",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   256
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   257
        // JCK test lex03593m27
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   258
        "12ee-2",
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
        // JCK test lex03593m28
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   261
        "12e-2.2.2",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   262
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   263
        // JCK test lex03593m29
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   264
        "12.01e+",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   265
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   266
        // JCK test lex03593m30
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   267
        "12.01E",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   268
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   269
        // Bad hexadecimal-style strings
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   270
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   271
        // Two leading zeros
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   272
        "00x1.0p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   273
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   274
        // Must have hex specifier
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   275
        "1.0p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   276
        "00010p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   277
        "deadbeefp1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   278
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   279
        // Need an explicit fully-formed exponent
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   280
        "0x1.0p",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   281
        "0x1.0",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   282
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   283
        // Exponent must be in decimal
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   284
        "0x1.0pa",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   285
        "0x1.0pf",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   286
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   287
        // Exponent separated by "p"
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   288
        "0x1.0e22",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   289
        "0x1.0e22",
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
        // Need a signifcand
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   292
        "0xp22"
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
    static String goodStrings[] = {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   296
        "NaN",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   297
        "+NaN",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   298
        "-NaN",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   299
        "Infinity",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   300
        "+Infinity",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   301
        "-Infinity",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   302
        "1.1e-23f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   303
        ".1e-23f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   304
        "1e-23",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   305
        "1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   306
        "0",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   307
        "-0",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   308
        "+0",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   309
        "00",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   310
        "00",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   311
        "-00",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   312
        "+00",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   313
        "0000000000",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   314
        "-0000000000",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   315
        "+0000000000",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   316
        "1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   317
        "2",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   318
        "1234",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   319
        "-1234",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   320
        "+1234",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   321
        "2147483647",   // Integer.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   322
        "2147483648",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   323
        "-2147483648",  // Integer.MIN_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   324
        "-2147483649",
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
        "16777215",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   327
        "16777216",     // 2^24
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   328
        "16777217",
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
        "-16777215",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   331
        "-16777216",    // -2^24
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   332
        "-16777217",
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
        "9007199254740991",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   335
        "9007199254740992",     // 2^53
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   336
        "9007199254740993",
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
        "-9007199254740991",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   339
        "-9007199254740992",    // -2^53
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   340
        "-9007199254740993",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   341
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   342
        "9223372036854775807",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   343
        "9223372036854775808",  // Long.MAX_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   344
        "9223372036854775809",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   345
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   346
        "-9223372036854775808",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   347
        "-9223372036854775809", // Long.MIN_VALUE
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   348
        "-9223372036854775810",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   349
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   350
        // Culled from JCK test lex03591m1
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   351
        "54.07140d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   352
        "7.01e-324d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   353
        "2147483647.01d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   354
        "1.2147483647f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   355
        "000000000000000000000000001.F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   356
        "1.00000000000000000000000000e-2F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   357
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   358
        // Culled from JCK test lex03592m2
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   359
        "2.",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   360
        ".0909",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   361
        "122112217090.0",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   362
        "7090e-5",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   363
        "2.E-20",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   364
        ".0909e42",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   365
        "122112217090.0E+100",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   366
        "7090f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   367
        "2.F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   368
        ".0909d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   369
        "122112217090.0D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   370
        "7090e-5f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   371
        "2.E-20F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   372
        ".0909e42d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   373
        "122112217090.0E+100D",
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
        // Culled from JCK test lex03594m31 -- unicode escapes
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   376
        "\u0035\u0031\u0034\u0039\u0032\u0033\u0036\u0037\u0038\u0030.1102E-209D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   377
        "1290873\u002E12301e100",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   378
        "1.1E-10\u0066",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   379
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   380
        // Culled from JCK test lex03595m1
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   381
        "0.0E-10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   382
        "1E10",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   383
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   384
        // Culled from JCK test lex03691m1
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   385
        "0.f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   386
        "1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   387
        "0.F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   388
        "1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   389
        "0.12d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   390
        "1e-0d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   391
        "12.e+1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   392
        "0e-0D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   393
        "12.e+01",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   394
        "1e-01",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   395
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   396
        // Good hex strings
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   397
        // Vary capitalization of separators.
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
        "0x1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   400
        "0X1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   401
        "0x1P1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   402
        "0X1P1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   403
        "0x1p1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   404
        "0X1p1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   405
        "0x1P1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   406
        "0X1P1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   407
        "0x1p1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   408
        "0X1p1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   409
        "0x1P1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   410
        "0X1P1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   411
        "0x1p1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   412
        "0X1p1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   413
        "0x1P1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   414
        "0X1P1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   415
        "0x1p1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   416
        "0X1p1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   417
        "0x1P1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   418
        "0X1P1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   419
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   420
        "-0x1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   421
        "-0X1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   422
        "-0x1P1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   423
        "-0X1P1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   424
        "-0x1p1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   425
        "-0X1p1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   426
        "-0x1P1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   427
        "-0X1P1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   428
        "-0x1p1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   429
        "-0X1p1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   430
        "-0x1P1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   431
        "-0X1P1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   432
        "-0x1p1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   433
        "-0X1p1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   434
        "-0x1P1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   435
        "-0X1P1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   436
        "-0x1p1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   437
        "-0X1p1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   438
        "-0x1P1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   439
        "-0X1P1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   440
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   441
        "0x1p-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   442
        "0X1p-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   443
        "0x1P-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   444
        "0X1P-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   445
        "0x1p-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   446
        "0X1p-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   447
        "0x1P-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   448
        "0X1P-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   449
        "0x1p-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   450
        "0X1p-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   451
        "0x1P-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   452
        "0X1P-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   453
        "0x1p-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   454
        "0X1p-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   455
        "0x1P-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   456
        "0X1P-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   457
        "0x1p-1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   458
        "0X1p-1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   459
        "0x1P-1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   460
        "0X1P-1D",
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
        "-0x1p-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   463
        "-0X1p-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   464
        "-0x1P-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   465
        "-0X1P-1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   466
        "-0x1p-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   467
        "-0X1p-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   468
        "-0x1P-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   469
        "-0X1P-1f",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   470
        "-0x1p-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   471
        "-0X1p-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   472
        "-0x1P-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   473
        "-0X1P-1F",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   474
        "-0x1p-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   475
        "-0X1p-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   476
        "-0x1P-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   477
        "-0X1P-1d",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   478
        "-0x1p-1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   479
        "-0X1p-1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   480
        "-0x1P-1D",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   481
        "-0X1P-1D",
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
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   484
        // Try different significand combinations
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   485
        "0xap1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   486
        "0xbp1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   487
        "0xcp1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   488
        "0xdp1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   489
        "0xep1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   490
        "0xfp1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   491
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   492
        "0x1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   493
        "0x.1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   494
        "0x1.1p1",
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
        "0x001p23",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   497
        "0x00.1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   498
        "0x001.1p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   499
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   500
        "0x100p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   501
        "0x.100p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   502
        "0x1.100p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   503
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   504
        "0x00100p1",
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   505
        "0x00.100p1",
8189
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   506
        "0x001.100p1",
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   507
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   508
        // Limits
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   509
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   510
        "1.7976931348623157E308",     // Double.MAX_VALUE
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   511
        "4.9e-324",                   // Double.MIN_VALUE
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   512
        "2.2250738585072014e-308",    // Double.MIN_NORMAL
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   513
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   514
        "2.2250738585072012e-308",    // near Double.MIN_NORMAL
26722
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   515
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   516
        "1.7976931348623158e+308",    // near MAX_VALUE + ulp(MAX_VALUE)/2
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   517
        "1.7976931348623159e+308",    // near MAX_VALUE + ulp(MAX_VALUE)
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   518
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   519
        "2.4703282292062329e-324",    // above MIN_VALUE/2
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   520
        "2.4703282292062327e-324",    // MIN_VALUE/2
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   521
        "2.4703282292062325e-324",    // below MIN_VALUE/2
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   522
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   523
        // 1e308 with leading zeros
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   524
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   525
        "0.0000000000001e321",
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   526
        "00.000000000000000001e326",
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   527
        "00000.000000000000000001e326",
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   528
        "000.0000000000000000001e327",
eb30ed2a0bfe 8043740: Doubles with large exponents overflow to Infinity incorrectly
bpb
parents: 23010
diff changeset
   529
        "0.00000000000000000001e328",
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   530
    };
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   531
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   532
    static String paddedBadStrings[];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   533
    static String paddedGoodStrings[];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   534
    static {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   535
        String pad = " \t\n\r\f\u0001\u000b\u001f";
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   536
        paddedBadStrings = new String[badStrings.length];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   537
        for(int i = 0 ; i <  badStrings.length; i++)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   538
            paddedBadStrings[i] = pad + badStrings[i] + pad;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   539
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   540
        paddedGoodStrings = new String[goodStrings.length];
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   541
        for(int i = 0 ; i <  goodStrings.length; i++)
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   542
            paddedGoodStrings[i] = pad + goodStrings[i] + pad;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   543
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
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   547
    /*
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   548
     * Throws an exception if <code>Input</code> is
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   549
     * <code>exceptionalInput</code> and {@link Double.parseDouble
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   550
     * parseDouble} does <em>not</em> throw an exception or if
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   551
     * <code>Input</code> is not <code>exceptionalInput</code> and
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   552
     * <code>parseDouble</code> throws an exception.  This method does
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   553
     * not attempt to test whether the string is converted to the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   554
     * proper value; just whether the input is accepted appropriately
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   555
     * or not.
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
    private static void testParsing(String [] input,
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   558
                                    boolean exceptionalInput) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   559
        for(int i = 0; i < input.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   560
            double d;
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
            try {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   563
                d = Double.parseDouble(input[i]);
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   564
                check(input[i]);
1826
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
            catch (NumberFormatException e) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   567
                if (! exceptionalInput) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   568
                    throw new RuntimeException("Double.parseDouble rejected " +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   569
                                               "good string `" + input[i] +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   570
                                               "'.");
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   571
                }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   572
                break;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   573
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   574
            if (exceptionalInput) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   575
                throw new RuntimeException("Double.parseDouble accepted " +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   576
                                           "bad string `" + input[i] +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   577
                                           "'.");
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   578
            }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   579
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   580
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   581
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
     * Throws an exception if <code>Input</code> is
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   584
     * <code>exceptionalInput</code> and the regular expression
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   585
     * matches one of the strings or if <code>Input</code> is not
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   586
     * <code>exceptionalInput</code> and the regular expression fails
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   587
     * to match an input string.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   588
     */
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   589
    private static void testRegex(String [] input, boolean exceptionalInput) {
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
         * The regex below is taken from the JavaDoc for
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   592
         * Double.valueOf.
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
        final String Digits     = "(\\p{Digit}+)";
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   596
        final String HexDigits  = "(\\p{XDigit}+)";
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   597
        // an exponent is 'e' or 'E' followed by an optionally
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   598
        // signed decimal integer.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   599
        final String Exp        = "[eE][+-]?"+Digits;
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   600
        final String fpRegex    =
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   601
            ("[\\x00-\\x20]*"+  // Optional leading "whitespace"
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   602
             "[+-]?(" + // Optional sign character
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   603
             "NaN|" +           // "NaN" string
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   604
             "Infinity|" +      // "Infinity" string
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   605
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   606
             // A floating-point string representing a finite positive
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   607
             // number without a leading sign has at most five basic pieces:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   608
             // Digits . Digits ExponentPart FloatTypeSuffix
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   609
             //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   610
             // Since this method allows integer-only strings as input
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   611
             // in addition to strings of floating-point literals, the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   612
             // two sub-patterns below are simplifications of the grammar
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   613
             // productions from the Java Language Specification, 2nd
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   614
             // edition, section 3.10.2.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   615
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   616
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   617
             // A decimal floating-point string representing a finite positive
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   618
             // number without a leading sign has at most five basic pieces:
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   619
             // Digits . Digits ExponentPart FloatTypeSuffix
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   620
             //
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   621
             // Since this method allows integer-only strings as input
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   622
             // in addition to strings of floating-point literals, the
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   623
             // two sub-patterns below are simplifications of the grammar
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   624
             // productions from the Java Language Specification, 2nd
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   625
             // edition, section 3.10.2.
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   626
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   627
             // Digits ._opt Digits_opt ExponentPart_opt FloatTypeSuffix_opt
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   628
             "(((("+Digits+"(\\.)?("+Digits+"?)("+Exp+")?)|"+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   629
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   630
             // . Digits ExponentPart_opt FloatTypeSuffix_opt
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   631
             "(\\.("+Digits+")("+Exp+")?))|"+
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   632
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   633
            // Hexadecimal strings
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
             // 0[xX] HexDigits ._opt BinaryExponent FloatTypeSuffix_opt
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   636
             "(0[xX]" + HexDigits + "(\\.)?)|" +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   637
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   638
             // 0[xX] HexDigits_opt . HexDigits BinaryExponent FloatTypeSuffix_opt
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   639
             "(0[xX]" + HexDigits + "?(\\.)" + HexDigits + ")" +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   640
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   641
             ")[pP][+-]?" + Digits + "))" +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   642
             "[fFdD]?))" +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   643
             "[\\x00-\\x20]*");// Optional trailing "whitespace"
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   644
        Pattern fpPattern = Pattern.compile(fpRegex);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   645
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   646
        for(int i = 0; i < input.length; i++) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   647
             Matcher m = fpPattern.matcher(input[i]);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   648
             if (m.matches() != ! exceptionalInput) {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   649
                 throw new RuntimeException("Regular expression " +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   650
                                            (exceptionalInput?
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   651
                                             "accepted bad":
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   652
                                             "rejected good") +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   653
                                            " string `" +
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   654
                                            input[i] + "'.");
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   655
             }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   656
        }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   657
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   658
    }
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   659
8189
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   660
    /**
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   661
     * For each subnormal power of two, test at boundaries of
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   662
     * region that should convert to that value.
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   663
     */
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   664
    private static void testSubnormalPowers() {
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   665
        boolean failed = false;
8189
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   666
        BigDecimal TWO = BigDecimal.valueOf(2);
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   667
        // An ulp is the same for all subnormal values
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   668
        BigDecimal ulp_BD = new BigDecimal(Double.MIN_VALUE);
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   669
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   670
        // Test subnormal powers of two (except Double.MIN_VALUE)
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   671
        for(int i = -1073; i <= -1022; i++) {
8189
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   672
            double d = Math.scalb(1.0, i);
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   673
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   674
            /*
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   675
             * The region [d - ulp/2, d + ulp/2] should round to d.
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   676
             */
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   677
            BigDecimal d_BD = new BigDecimal(d);
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   678
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   679
            BigDecimal lowerBound = d_BD.subtract(ulp_BD.divide(TWO));
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   680
            BigDecimal upperBound = d_BD.add(ulp_BD.divide(TWO));
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   681
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   682
            double convertedLowerBound = Double.parseDouble(lowerBound.toString());
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   683
            double convertedUpperBound = Double.parseDouble(upperBound.toString());
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   684
            if (convertedLowerBound != d) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   685
                failed = true;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   686
                System.out.printf("2^%d lowerBound converts as %a %s%n",
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   687
                                  i, convertedLowerBound, lowerBound);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   688
            }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   689
            if (convertedUpperBound != d) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   690
                failed = true;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   691
                System.out.printf("2^%d upperBound converts as %a %s%n",
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   692
                                  i, convertedUpperBound, upperBound);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   693
            }
8189
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   694
        }
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   695
        /*
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   696
         * Double.MIN_VALUE
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   697
         * The region ]0.5*Double.MIN_VALUE, 1.5*Double.MIN_VALUE[ should round to Double.MIN_VALUE .
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   698
         */
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   699
        BigDecimal minValue = new BigDecimal(Double.MIN_VALUE);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   700
        if (Double.parseDouble(minValue.multiply(new BigDecimal(0.5)).toString()) != 0.0) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   701
            failed = true;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   702
            System.out.printf("0.5*MIN_VALUE doesn't convert 0%n");
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   703
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   704
        if (Double.parseDouble(minValue.multiply(new BigDecimal(0.50000000001)).toString()) != Double.MIN_VALUE) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   705
            failed = true;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   706
            System.out.printf("0.50000000001*MIN_VALUE doesn't convert to MIN_VALUE%n");
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   707
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   708
        if (Double.parseDouble(minValue.multiply(new BigDecimal(1.49999999999)).toString()) != Double.MIN_VALUE) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   709
            failed = true;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   710
            System.out.printf("1.49999999999*MIN_VALUE doesn't convert to MIN_VALUE%n");
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   711
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   712
        if (Double.parseDouble(minValue.multiply(new BigDecimal(1.5)).toString()) != 2*Double.MIN_VALUE) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   713
            failed = true;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   714
            System.out.printf("1.5*MIN_VALUE doesn't convert to 2*MIN_VALUE%n");
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   715
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   716
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   717
        if (failed)
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   718
            throw new RuntimeException("Inconsistent conversion");
8189
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   719
    }
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   720
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   721
    /**
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   722
     * For each power of two, test at boundaries of
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   723
     * region that should convert to that value.
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   724
     */
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   725
    private static void testPowers() {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   726
        for(int i = -1074; i <= +1023; i++) {
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   727
            double d = Math.scalb(1.0, i);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   728
            BigDecimal d_BD = new BigDecimal(d);
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   729
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   730
            BigDecimal lowerBound = d_BD.subtract(new BigDecimal(Math.ulp(Math.nextUp(-d))).multiply(HALF));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   731
            BigDecimal upperBound = d_BD.add(new BigDecimal(Math.ulp(d)).multiply(HALF));
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   732
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   733
            check(lowerBound.toString());
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   734
            check(upperBound.toString());
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   735
        }
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   736
        check(new BigDecimal(Double.MAX_VALUE).add(new BigDecimal(Math.ulp(Double.MAX_VALUE)).multiply(HALF)).toString());
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   737
    }
9276
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   738
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   739
    private static void testStrictness() {
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   740
        final double expected = 0x0.0000008000000p-1022;
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   741
//        final double expected = 0x0.0000008000001p-1022;
9276
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   742
        boolean failed = false;
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   743
        double conversion = 0.0;
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   744
        double sum = 0.0; // Prevent conversion from being optimized away
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   745
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   746
        //2^-1047 + 2^-1075 rounds to 2^-1047
9276
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   747
        String decimal = "6.631236871469758276785396630275967243399099947355303144249971758736286630139265439618068200788048744105960420552601852889715006376325666595539603330361800519107591783233358492337208057849499360899425128640718856616503093444922854759159988160304439909868291973931426625698663157749836252274523485312442358651207051292453083278116143932569727918709786004497872322193856150225415211997283078496319412124640111777216148110752815101775295719811974338451936095907419622417538473679495148632480391435931767981122396703443803335529756003353209830071832230689201383015598792184172909927924176339315507402234836120730914783168400715462440053817592702766213559042115986763819482654128770595766806872783349146967171293949598850675682115696218943412532098591327667236328125E-316";
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   748
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   749
        for(int i = 0; i <= 12_000; i++) {
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   750
            conversion = Double.parseDouble(decimal);
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   751
            sum += conversion;
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   752
            if (conversion != expected) {
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   753
                failed = true;
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   754
                System.out.printf("Iteration %d converts as %a%n",
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   755
                                  i, conversion);
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   756
            }
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   757
        }
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   758
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   759
        System.out.println("Sum = "  + sum);
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   760
        if (failed)
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   761
            throw new RuntimeException("Inconsistent conversion");
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   762
    }
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   763
1826
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   764
    public static void main(String[] args) throws Exception {
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   765
        rudimentaryTest();
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
        testParsing(goodStrings, false);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   768
        testParsing(paddedGoodStrings, false);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   769
        testParsing(badStrings, true);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   770
        testParsing(paddedBadStrings, true);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   771
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   772
        testRegex(goodStrings, false);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   773
        testRegex(paddedGoodStrings, false);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   774
        testRegex(badStrings, true);
39d505a353e8 6601457: Move wrapper class tests from closed to open
darcy
parents:
diff changeset
   775
        testRegex(paddedBadStrings, true);
8189
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   776
5fd29d2cbc4b 4421494: infinite loop while parsing double literal
alanb
parents: 5506
diff changeset
   777
        testSubnormalPowers();
18537
2ae90e54f001 7192954: Fix Float.parseFloat to round correctly and preserve monotonicity.
bpb
parents: 9521
diff changeset
   778
        testPowers();
9276
645e1a5c72f6 7021568: Double.parseDouble() returns architecture dependent results
darcy
parents: 9035
diff changeset
   779
        testStrictness();
1826
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
}