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

Comparing jsr166/src/test/loops/DequeBash.java (file contents):
Revision 1.3 by jsr166, Thu Oct 29 23:09:07 2009 UTC vs.
Revision 1.4 by jsr166, Mon Nov 2 23:42:46 2009 UTC

# Line 26 | Line 26 | public class DequeBash {
26      static int random(int bound) {
27          int x = seed;
28          int t = (x % 127773) * 16807 - (x / 127773) * 2836;
29 <        seed = (t > 0)? t : t + 0x7fffffff;
29 >        seed = (t > 0) ? t : t + 0x7fffffff;
30          return (t & 0x7fffffff) % bound;
31      }
32  
33      static int random() {
34          int x = seed;
35          int t = (x % 127773) * 16807 - (x / 127773) * 2836;
36 <        seed = (t > 0)? t : t + 0x7fffffff;
36 >        seed = (t > 0) ? t : t + 0x7fffffff;
37          return (t & 0x7fffffff);
38      }
39  
# Line 178 | Line 178 | public class DequeBash {
178                      case 2: result = deque.pop();         break;
179                      default: throw new Exception("How'd we get here");
180                      }
181 <                } catch(NoSuchElementException e) {
181 >                } catch (NoSuchElementException e) {
182                      threw = true;
183                  }
184                  if (!threw)
# Line 212 | Line 212 | public class DequeBash {
212                  boolean threw = false;
213                  try {
214                      result = deque.removeLast();
215 <                } catch(NoSuchElementException e) {
215 >                } catch (NoSuchElementException e) {
216                      threw = true;
217                  }
218                  if (!threw)
219                      throw new Exception("Remove-no exception: " + result);
220              } else { // deque nonempty
221 <                int result = ((random() & 1) == 0?
221 >                int result = ((random() & 1) == 0 ?
222                                deque.removeLast() : deque.pollLast());
223                  if (result != --nextTail)
224                      throw new Exception(
225 <                                        "Removed "+ result + " expecting "+(nextTail + 1));
225 >                        "Removed "+ result + " expecting "+(nextTail + 1));
226              }
227              break;
228          default:
# Line 237 | Line 237 | public class DequeBash {
237          if (d1.size() != d2.size())
238              throw new Exception("Size " + d1.size() + " != " + d2.size());
239          Iterator<Integer> it = d2.iterator();
240 <        for(int i : d1) {
240 >        for (int i : d1) {
241              int j = it.next();
242              if (j != i)
243                  throw new Exception("Element " + j + " != " + i);
244          }
245  
246 <        for(int i : d1)
246 >        for (int i : d1)
247              if (!d2.contains(i))
248                  throw new Exception("d2 doesn't contain " + i);
249 <        for(int i : d2)
249 >        for (int i : d2)
250              if (!d1.contains(i))
251                  throw new Exception("d2 doesn't contain " + i);
252  
# Line 280 | Line 280 | public class DequeBash {
280                  bos.toByteArray());
281              ObjectInputStream ois = new ObjectInputStream(bin);
282              return (T) ois.readObject();
283 <        } catch(Exception e) {
283 >        } catch (Exception e) {
284              throw new IllegalArgumentException(e);
285          }
286      }
# Line 368 | Line 368 | public class DequeBash {
368              boolean threw = false;
369              int result = 666;
370              try {
371 <                result = ((random() & 1) == 0?
371 >                result = ((random() & 1) == 0 ?
372                            deque.getFirst() : deque.element());
373 <            } catch(NoSuchElementException e) {
373 >            } catch (NoSuchElementException e) {
374                  threw = true;
375              }
376              if (!threw)
# Line 378 | Line 378 | public class DequeBash {
378              threw = false;
379              try {
380                  result = deque.getLast();
381 <            } catch(NoSuchElementException e) {
381 >            } catch (NoSuchElementException e) {
382                  threw = true;
383              }
384              if (!threw)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines