test/java/math/BigInteger/SymmetricRangeTests.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 ****
/*
! * Copyright (c) 2013, 1025, 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.
--- 1,7 ----
/*
! * Copyright (c) 2013, 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.
*** 22,34 ****
*/
/*
* @test
* @ignore This test has huge memory requirements
! * @library ..
* @run main/timeout=180/othervm -Xmx8g SymmetricRangeTests
! * @bug 6910473 8021204 8021203 9005933 8074460
* @summary Test range of BigInteger values (use -Dseed=X to set PRNG seed)
* @author Dmitry Nadezhin
* @key randomness
*/
import java.io.ByteArrayInputStream;
--- 22,35 ----
*/
/*
* @test
* @ignore This test has huge memory requirements
! * @library /lib/testlibrary/
! * @build jdk.testlibrary.*
* @run main/timeout=180/othervm -Xmx8g SymmetricRangeTests
! * @bug 6910473 8021204 8021203 9005933 8074460 8078672
* @summary Test range of BigInteger values (use -Dseed=X to set PRNG seed)
* @author Dmitry Nadezhin
* @key randomness
*/
import java.io.ByteArrayInputStream;
*** 36,45 ****
--- 37,47 ----
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.math.BigInteger;
+ import java.util.Random;
public class SymmetricRangeTests {
private static final BigInteger MAX_VALUE = makeMaxValue();
private static final BigInteger MIN_VALUE = MAX_VALUE.negate();
*** 113,125 ****
private static void testOverflowInBitSieve() {
System.out.println("Testing overflow in BitSieve.sieveSingle");
int bitLength = (5 << 27) - 1;
try {
! RandomSeed rndSeed = new RandomSeed(false);
! System.out.println("Random number generator seed = " + rndSeed.getSeed());
! BigInteger actual = new BigInteger(bitLength, 0, rndSeed.getRandom());
throw new RuntimeException("new BigInteger(bitLength, 0, null).bitLength()=" + actual.bitLength());
} catch (ArithmeticException e) {
// expected
}
try {
--- 115,126 ----
private static void testOverflowInBitSieve() {
System.out.println("Testing overflow in BitSieve.sieveSingle");
int bitLength = (5 << 27) - 1;
try {
! Random random = RandomFactory.getRandom();
! BigInteger actual = new BigInteger(bitLength, 0, random);
throw new RuntimeException("new BigInteger(bitLength, 0, null).bitLength()=" + actual.bitLength());
} catch (ArithmeticException e) {
// expected
}
try {