--- jsr166/src/test/tck/ThreadLocalRandomTest.java 2009/07/31 23:02:50 1.1 +++ jsr166/src/test/tck/ThreadLocalRandomTest.java 2011/03/15 19:47:07 1.8 @@ -1,7 +1,7 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ */ import junit.framework.*; import java.util.concurrent.*; @@ -11,22 +11,22 @@ import java.util.*; public class ThreadLocalRandomTest extends JSR166TestCase { public static void main(String[] args) { - junit.textui.TestRunner.run (suite()); + junit.textui.TestRunner.run(suite()); } public static Test suite() { - return new TestSuite(ThreadLocalRandomTest.class); + return new TestSuite(ThreadLocalRandomTest.class); } /** * Testing coverage notes: - * + * * We don't test randomness properties, but only that repeated * calls, up to NCALLS tries, produce at least one different * result. For bounded versions, we sample various intervals * across multiples of primes. */ - // + // static final int NCALLS = 10000; // max sampled int bound @@ -41,8 +41,8 @@ public class ThreadLocalRandomTest exten public void testSetSeed() { try { ThreadLocalRandom.current().setSeed(17); - } catch(UnsupportedOperationException success) { - } + shouldThrow(); + } catch (UnsupportedOperationException success) {} } /** @@ -118,9 +118,9 @@ public class ThreadLocalRandomTest exten */ public void testNextIntBoundedNeg() { try { - int f = ThreadLocalRandom.current().nextInt(-17); - } catch(IllegalArgumentException success) { - } + int f = ThreadLocalRandom.current().nextInt(-17); + shouldThrow(); + } catch (IllegalArgumentException success) {} } /** @@ -128,9 +128,9 @@ public class ThreadLocalRandomTest exten */ public void testNextIntBadBounds() { try { - int f = ThreadLocalRandom.current().nextInt(17, 2); - } catch(IllegalArgumentException success) { - } + int f = ThreadLocalRandom.current().nextInt(17, 2); + shouldThrow(); + } catch (IllegalArgumentException success) {} } @@ -145,7 +145,7 @@ public class ThreadLocalRandomTest exten assertTrue(0 <= f && f < bound); int i = 0; int j; - while (i < NCALLS && + while (i < NCALLS && (j = ThreadLocalRandom.current().nextInt(bound)) == f) { assertTrue(0 <= j && j < bound); ++i; @@ -166,7 +166,7 @@ public class ThreadLocalRandomTest exten assertTrue(least <= f && f < bound); int i = 0; int j; - while (i < NCALLS && + while (i < NCALLS && (j = ThreadLocalRandom.current().nextInt(least, bound)) == f) { assertTrue(least <= j && j < bound); ++i; @@ -181,9 +181,9 @@ public class ThreadLocalRandomTest exten */ public void testNextLongBoundedNeg() { try { - long f = ThreadLocalRandom.current().nextLong(-17); - } catch(IllegalArgumentException success) { - } + long f = ThreadLocalRandom.current().nextLong(-17); + shouldThrow(); + } catch (IllegalArgumentException success) {} } /** @@ -191,9 +191,9 @@ public class ThreadLocalRandomTest exten */ public void testNextLongBadBounds() { try { - long f = ThreadLocalRandom.current().nextLong(17, 2); - } catch(IllegalArgumentException success) { - } + long f = ThreadLocalRandom.current().nextLong(17, 2); + shouldThrow(); + } catch (IllegalArgumentException success) {} } /** @@ -206,7 +206,7 @@ public class ThreadLocalRandomTest exten assertTrue(0 <= f && f < bound); int i = 0; long j; - while (i < NCALLS && + while (i < NCALLS && (j = ThreadLocalRandom.current().nextLong(bound)) == f) { assertTrue(0 <= j && j < bound); ++i; @@ -226,7 +226,7 @@ public class ThreadLocalRandomTest exten assertTrue(least <= f && f < bound); int i = 0; long j; - while (i < NCALLS && + while (i < NCALLS && (j = ThreadLocalRandom.current().nextLong(least, bound)) == f) { assertTrue(least <= j && j < bound); ++i; @@ -248,7 +248,7 @@ public class ThreadLocalRandomTest exten assertTrue(least <= f && f < bound); int i = 0; double j; - while (i < NCALLS && + while (i < NCALLS && (j = ThreadLocalRandom.current().nextDouble(least, bound)) == f) { assertTrue(least <= j && j < bound); ++i;