--- jsr166/src/test/tck/SplittableRandomTest.java 2013/09/24 15:29:18 1.10 +++ jsr166/src/test/tck/SplittableRandomTest.java 2015/04/25 04:55:31 1.18 @@ -3,17 +3,18 @@ * Expert Group and released to the public domain, as explained at * http://creativecommons.org/publicdomain/zero/1.0/ */ -import junit.framework.*; -import java.util.*; + import java.util.SplittableRandom; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.LongAdder; +import junit.framework.Test; +import junit.framework.TestSuite; + public class SplittableRandomTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { return new TestSuite(SplittableRandomTest.class); @@ -39,10 +40,10 @@ public class SplittableRandomTest extend static final int NCALLS = 10000; // max sampled int bound - static final int MAX_INT_BOUND = (1 << 28); + static final int MAX_INT_BOUND = (1 << 26); // max sampled long bound - static final long MAX_LONG_BOUND = (1L << 42); + static final long MAX_LONG_BOUND = (1L << 40); // Number of replications for other checks static final int REPS = @@ -89,7 +90,7 @@ public class SplittableRandomTest extend * same values for nextLong. */ public void testSeedConstructor() { - for (long seed = 2; seed < MAX_LONG_BOUND; seed += 15485863) { + for (long seed = 2; seed < MAX_LONG_BOUND; seed += 15485863) { SplittableRandom sr1 = new SplittableRandom(seed); SplittableRandom sr2 = new SplittableRandom(seed); for (int i = 0; i < REPS; ++i) @@ -130,7 +131,7 @@ public class SplittableRandomTest extend /** * nextInt(non-positive) throws IllegalArgumentException */ - public void testNextIntNonPositive() { + public void testNextIntBoundNonPositive() { SplittableRandom sr = new SplittableRandom(); Runnable[] throwingActions = { () -> sr.nextInt(-17), @@ -199,7 +200,7 @@ public class SplittableRandomTest extend /** * nextLong(non-positive) throws IllegalArgumentException */ - public void testNextLongNonPositive() { + public void testNextLongBoundNonPositive() { SplittableRandom sr = new SplittableRandom(); Runnable[] throwingActions = { () -> sr.nextLong(-17L), @@ -267,7 +268,7 @@ public class SplittableRandomTest extend /** * nextDouble(non-positive) throws IllegalArgumentException */ - public void testNextDoubleNonPositive() { + public void testNextDoubleBoundNonPositive() { SplittableRandom sr = new SplittableRandom(); Runnable[] throwingActions = { () -> sr.nextDouble(-17.0d), @@ -409,9 +410,10 @@ public class SplittableRandomTest extend for (int least = -15485867; least < MAX_INT_BOUND; least += 524959) { for (int bound = least + 2; bound > least && bound < MAX_INT_BOUND; bound += 67867967) { final int lo = least, hi = bound; - r.ints(size, lo, hi).parallel(). - forEach(x -> {if (x < lo || x >= hi) - fails.getAndIncrement(); }); + r.ints(size, lo, hi).parallel().forEach( + x -> { + if (x < lo || x >= hi) + fails.getAndIncrement(); }); } } assertEquals(0, fails.get()); @@ -427,9 +429,10 @@ public class SplittableRandomTest extend for (long least = -86028121; least < MAX_LONG_BOUND; least += 1982451653L) { for (long bound = least + 2; bound > least && bound < MAX_LONG_BOUND; bound += Math.abs(bound * 7919)) { final long lo = least, hi = bound; - r.longs(size, lo, hi).parallel(). - forEach(x -> {if (x < lo || x >= hi) - fails.getAndIncrement(); }); + r.longs(size, lo, hi).parallel().forEach( + x -> { + if (x < lo || x >= hi) + fails.getAndIncrement(); }); } } assertEquals(0, fails.get()); @@ -445,9 +448,10 @@ public class SplittableRandomTest extend for (double least = 0.00011; least < 1.0e20; least *= 9) { for (double bound = least * 1.0011; bound < 1.0e20; bound *= 17) { final double lo = least, hi = bound; - r.doubles(size, lo, hi).parallel(). - forEach(x -> {if (x < lo || x >= hi) - fails.getAndIncrement(); }); + r.doubles(size, lo, hi).parallel().forEach( + x -> { + if (x < lo || x >= hi) + fails.getAndIncrement(); }); } } assertEquals(0, fails.get());