--- jsr166/src/test/loops/ListBash.java 2005/09/25 13:10:45 1.4 +++ jsr166/src/test/loops/ListBash.java 2009/11/02 23:55:36 1.9 @@ -21,7 +21,7 @@ public class ListBash { try { cl = Class.forName(args[0]); - } catch(ClassNotFoundException e) { + } catch (ClassNotFoundException e) { fail("Class " + args[0] + " not found."); } @@ -29,8 +29,6 @@ public class ListBash { oneRun(); oneRun(); oneRun(); - oneRun(); - oneRun(); } static void oneRun() { @@ -96,7 +94,7 @@ public class ListBash { sum -= (s2.get(k)).intValue(); } if (sum == 0) System.out.print(" "); - } + } static void sets(List s1, List s2) { List intersection = clone(s1, cl,synch);intersection.retainAll(s2); @@ -154,19 +152,19 @@ public class ListBash { all = clone(s, cl, synch); else { it = even.iterator(); - while(it.hasNext()) - if((it.next()).intValue() % 2 == 1) + while (it.hasNext()) + if ((it.next()).intValue() % 2 == 1) it.remove(); it = even.iterator(); - while(it.hasNext()) - if((it.next()).intValue() % 2 == 1) + while (it.hasNext()) + if ((it.next()).intValue() % 2 == 1) fail("Failed to remove all odd nubmers."); - + for (int i=0; i<(listSize/2); i++) odd.remove(i); for (int i=0; i<(listSize/2); i++) { int ii = (odd.get(i)).intValue(); - if(ii % 2 != 1) + if (ii % 2 != 1) fail("Failed to remove all even nubmers. " + ii); } @@ -175,7 +173,7 @@ public class ListBash { all.add(2*i, even.get(i)); if (!all.equals(s)) fail("Failed to reconstruct ints from odds and evens."); - + all = clone(odd, cl, synch); ListIterator itAll = all.listIterator(all.size()); ListIterator itEven = even.listIterator(even.size()); @@ -191,8 +189,8 @@ public class ListBash { } itAll = all.listIterator(); it = s.iterator(); - while(it.hasNext()) - if(it.next()==itAll.next()) + while (it.hasNext()) + if (it.next()==itAll.next()) fail("Iterator.set failed to change value."); } if (!all.equals(s)) @@ -226,16 +224,16 @@ public class ListBash { static void arrays() { List l = newList(cl, synch); AddRandoms(l, listSize); - Integer[] ia = (Integer[]) l.toArray(new Integer[0]); + Integer[] ia = l.toArray(new Integer[0]); if (!l.equals(Arrays.asList(ia))) fail("toArray(Object[]) is hosed (1)"); ia = new Integer[listSize]; - Integer[] ib = (Integer[]) l.toArray(ia); + Integer[] ib = l.toArray(ia); if (ia != ib || !l.equals(Arrays.asList(ia))) fail("toArray(Object[]) is hosed (2)"); ia = new Integer[listSize+1]; ia[listSize] = new Integer(69); - ib = (Integer[]) l.toArray(ia); + ib = l.toArray(ia); if (ia != ib || ia[listSize] != null || !l.equals(Arrays.asList(ia).subList(0, listSize))) fail("toArray(Object[]) is hosed (3)"); @@ -256,18 +254,18 @@ public class ListBash { if (!clone.containsAll(s)) fail("Copy does not contain list."); - return (List)clone; + return (List) clone; } static List newList(Class cl, boolean synch) { try { - List s = (List)cl.newInstance(); + List s = (List) cl.newInstance(); if (synch) s = Collections.synchronizedList(s); if (!s.isEmpty()) fail("New instance non empty."); return s; - } catch(Throwable t) { + } catch (Throwable t) { fail("Can't instantiate " + cl + ": " + t); } return null; //Shut up compiler.