test/java/lang/Math/HypotTests.java

Print this page
rev 11823 : 8078672: Print and allow setting by Java property seeds used to initialize Random instances in java.lang numerics tests
Summary: Add ability to initial the random number generator from the system property "seed" and print to STDOUT the seed value actually used.
Reviewed-by: XXX

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -21,12 +21,15 @@
  * questions.
  */
 
 /*
  * @test
- * @bug 4851638 4939441
- * @summary Tests for {Math, StrictMath}.hypot
+ * @library /lib/testlibrary/
+ * @build jdk.testlibrary.*
+ * @run main HypotTests
+ * @bug 4851638 4939441 8078672
+ * @summary Tests for {Math, StrictMath}.hypot (use -Dseed=X to set PRNG seed)
  * @author Joseph D. Darcy
  * @key randomness
  */
 
 public class HypotTests {

@@ -118,11 +121,11 @@
          * result of hypot(3*r, 4*r) should be approximately 5*r. (The
          * computation of 4*r is exact since it just changes the
          * exponent).  While the exponent of r is less than or equal
          * to (MAX_EXPONENT - 3), the computation should not overflow.
          */
-        java.util.Random rand = new java.util.Random();
+        java.util.Random rand = RandomFactory.getRandom();
         for(int i = 0; i < 1000; i++) {
             double d = rand.nextDouble();
             // Scale d to have an exponent equal to MAX_EXPONENT -15
             d = Math.scalb(d, Double.MAX_EXPONENT
                                  -15 - Tests.ilogb(d));