jdk/test/java/lang/Double/ParseHexFloatingPoint.java
changeset 30048 3424bede284d
parent 30046 cf2c86e1819e
child 30436 17827057ef5a
equal deleted inserted replaced
30047:63b6a16968d5 30048:3424bede284d
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    21  * questions.
    21  * questions.
    22  */
    22  */
    23 
    23 
    24 /*
    24 /*
    25  * @test
    25  * @test
    26  * @bug 4826774
    26  * @library /lib/testlibrary/
    27  * @summary Numerical tests for hexadecimal inputs to parseDouble, parseFloat
    27  * @build jdk.testlibrary.*
       
    28  * @run main ParseHexFloatingPoint
       
    29  * @bug 4826774 8078672
       
    30  * @summary Numerical tests for hexadecimal inputs to parse{Double, Float} (use -Dseed=X to set PRNG seed)
    28  * @author Joseph D. Darcy
    31  * @author Joseph D. Darcy
    29  * @key randomness
    32  * @key randomness
    30  */
    33  */
    31 
       
    32 
       
    33 import java.util.regex.*;
       
    34 
    34 
    35 public class ParseHexFloatingPoint {
    35 public class ParseHexFloatingPoint {
    36     private ParseHexFloatingPoint(){}
    36     private ParseHexFloatingPoint(){}
    37 
    37 
    38     public static final double infinityD = Double.POSITIVE_INFINITY;
    38     public static final double infinityD = Double.POSITIVE_INFINITY;
   254         }
   254         }
   255 
   255 
   256         failures += significandAlignmentTests();
   256         failures += significandAlignmentTests();
   257 
   257 
   258         {
   258         {
   259             java.util.Random rand = new java.util.Random();
   259             java.util.Random rand = RandomFactory.getRandom();
   260             // Consistency check; double => hexadecimal => double
   260             // Consistency check; double => hexadecimal => double
   261             // preserves the original value.
   261             // preserves the original value.
   262             for(int i = 0; i < 1000; i++) {
   262             for(int i = 0; i < 1000; i++) {
   263                 double d = rand.nextDouble();
   263                 double d = rand.nextDouble();
   264                 failures += testCase(Double.toHexString(d), d);
   264                 failures += testCase(Double.toHexString(d), d);