--- jsr166/src/test/tck/ThreadLocalRandomTest.java 2009/07/31 23:02:50 1.1 +++ jsr166/src/test/tck/ThreadLocalRandomTest.java 2009/11/21 02:07:27 1.4 @@ -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,7 +41,8 @@ public class ThreadLocalRandomTest exten public void testSetSeed() { try { ThreadLocalRandom.current().setSeed(17); - } catch(UnsupportedOperationException success) { + shouldThrow(); + } catch (UnsupportedOperationException success) { } } @@ -119,7 +120,8 @@ public class ThreadLocalRandomTest exten public void testNextIntBoundedNeg() { try { int f = ThreadLocalRandom.current().nextInt(-17); - } catch(IllegalArgumentException success) { + shouldThrow(); + } catch (IllegalArgumentException success) { } } @@ -129,7 +131,8 @@ public class ThreadLocalRandomTest exten public void testNextIntBadBounds() { try { int f = ThreadLocalRandom.current().nextInt(17, 2); - } catch(IllegalArgumentException success) { + shouldThrow(); + } catch (IllegalArgumentException success) { } } @@ -145,7 +148,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 +169,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; @@ -182,7 +185,8 @@ public class ThreadLocalRandomTest exten public void testNextLongBoundedNeg() { try { long f = ThreadLocalRandom.current().nextLong(-17); - } catch(IllegalArgumentException success) { + shouldThrow(); + } catch (IllegalArgumentException success) { } } @@ -192,7 +196,8 @@ public class ThreadLocalRandomTest exten public void testNextLongBadBounds() { try { long f = ThreadLocalRandom.current().nextLong(17, 2); - } catch(IllegalArgumentException success) { + shouldThrow(); + } catch (IllegalArgumentException success) { } } @@ -206,7 +211,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 +231,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 +253,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;