ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ThreadLocalRandomTest.java
(Generate patch)

Comparing jsr166/src/test/tck/ThreadLocalRandomTest.java (file contents):
Revision 1.1 by dl, Fri Jul 31 23:02:50 2009 UTC vs.
Revision 1.2 by jsr166, Fri Jul 31 23:37:31 2009 UTC

# Line 11 | Line 11 | import java.util.*;
11   public class ThreadLocalRandomTest extends JSR166TestCase {
12  
13      public static void main(String[] args) {
14 <        junit.textui.TestRunner.run (suite());  
14 >        junit.textui.TestRunner.run (suite());
15      }
16      public static Test suite() {
17          return new TestSuite(ThreadLocalRandomTest.class);
# Line 19 | Line 19 | public class ThreadLocalRandomTest exten
19  
20      /**
21       * Testing coverage notes:
22 <     *
22 >     *
23       * We don't test randomness properties, but only that repeated
24       * calls, up to NCALLS tries, produce at least one different
25       * result.  For bounded versions, we sample various intervals
26       * across multiples of primes.
27       */
28  
29 <    //
29 >    //
30      static final int NCALLS = 10000;
31  
32      // max sampled int bound
# Line 41 | Line 41 | public class ThreadLocalRandomTest exten
41      public void testSetSeed() {
42          try {
43              ThreadLocalRandom.current().setSeed(17);
44 <        } catch(UnsupportedOperationException success) {
44 >        } catch (UnsupportedOperationException success) {
45          }
46      }
47  
# Line 119 | Line 119 | public class ThreadLocalRandomTest exten
119      public void testNextIntBoundedNeg() {
120          try {
121              int  f = ThreadLocalRandom.current().nextInt(-17);
122 <        } catch(IllegalArgumentException success) {
122 >        } catch (IllegalArgumentException success) {
123          }
124      }
125  
# Line 129 | Line 129 | public class ThreadLocalRandomTest exten
129      public void testNextIntBadBounds() {
130          try {
131              int  f = ThreadLocalRandom.current().nextInt(17, 2);
132 <        } catch(IllegalArgumentException success) {
132 >        } catch (IllegalArgumentException success) {
133          }
134      }
135  
# Line 145 | Line 145 | public class ThreadLocalRandomTest exten
145              assertTrue(0 <= f && f < bound);
146              int i = 0;
147              int j;
148 <            while (i < NCALLS &&
148 >            while (i < NCALLS &&
149                     (j = ThreadLocalRandom.current().nextInt(bound)) == f) {
150                  assertTrue(0 <= j && j < bound);
151                  ++i;
# Line 166 | Line 166 | public class ThreadLocalRandomTest exten
166                  assertTrue(least <= f && f < bound);
167                  int i = 0;
168                  int j;
169 <                while (i < NCALLS &&
169 >                while (i < NCALLS &&
170                         (j = ThreadLocalRandom.current().nextInt(least, bound)) == f) {
171                      assertTrue(least <= j && j < bound);
172                      ++i;
# Line 182 | Line 182 | public class ThreadLocalRandomTest exten
182      public void testNextLongBoundedNeg() {
183          try {
184              long  f = ThreadLocalRandom.current().nextLong(-17);
185 <        } catch(IllegalArgumentException success) {
185 >        } catch (IllegalArgumentException success) {
186          }
187      }
188  
# Line 192 | Line 192 | public class ThreadLocalRandomTest exten
192      public void testNextLongBadBounds() {
193          try {
194              long  f = ThreadLocalRandom.current().nextLong(17, 2);
195 <        } catch(IllegalArgumentException success) {
195 >        } catch (IllegalArgumentException success) {
196          }
197      }
198  
# Line 206 | Line 206 | public class ThreadLocalRandomTest exten
206              assertTrue(0 <= f && f < bound);
207              int i = 0;
208              long j;
209 <            while (i < NCALLS &&
209 >            while (i < NCALLS &&
210                     (j = ThreadLocalRandom.current().nextLong(bound)) == f) {
211                  assertTrue(0 <= j && j < bound);
212                  ++i;
# Line 226 | Line 226 | public class ThreadLocalRandomTest exten
226                  assertTrue(least <= f && f < bound);
227                  int i = 0;
228                  long j;
229 <                while (i < NCALLS &&
229 >                while (i < NCALLS &&
230                         (j = ThreadLocalRandom.current().nextLong(least, bound)) == f) {
231                      assertTrue(least <= j && j < bound);
232                      ++i;
# Line 248 | Line 248 | public class ThreadLocalRandomTest exten
248                  assertTrue(least <= f && f < bound);
249                  int i = 0;
250                  double j;
251 <                while (i < NCALLS &&
251 >                while (i < NCALLS &&
252                         (j = ThreadLocalRandom.current().nextDouble(least, bound)) == f) {
253                      assertTrue(least <= j && j < bound);
254                      ++i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines