test/java/lang/Long/BitTwiddle.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) 2003, 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) 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,32 **** * questions. */ /* * @test ! * @bug 4495754 ! * @summary Basic test for long bit twiddling * @author Josh Bloch * @key randomness */ import java.util.Random; --- 21,35 ---- * questions. */ /* * @test ! * @library /lib/testlibrary/ ! * @build jdk.testlibrary.* ! * @run main BitTwiddle ! * @bug 4495754 8078672 ! * @summary Basic test for long bit twiddling (use -Dseed=X to set PRNG seed) * @author Josh Bloch * @key randomness */ import java.util.Random;
*** 34,44 **** public class BitTwiddle { private static final int N = 1000; // # of repetitions per test public static void main(String args[]) { ! Random rnd = new Random(); if (highestOneBit(0) != 0) throw new RuntimeException("a"); if (highestOneBit(-1) != MIN_VALUE) throw new RuntimeException("b"); --- 37,47 ---- public class BitTwiddle { private static final int N = 1000; // # of repetitions per test public static void main(String args[]) { ! Random rnd = RandomFactory.getRandom(); if (highestOneBit(0) != 0) throw new RuntimeException("a"); if (highestOneBit(-1) != MIN_VALUE) throw new RuntimeException("b");