changeset 8452:bfa882164c34

ensure remove and previous work as expected after forEachRemaining returns
author akhil
date Wed, 01 May 2013 14:59:49 -0700
parents d66b8b94c279
children 7c1d6b2c41ea
files test/java/util/Iterator/IteratorDefaults.java
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/util/Iterator/IteratorDefaults.java	Wed May 01 10:18:20 2013 -0700
+++ b/test/java/util/Iterator/IteratorDefaults.java	Wed May 01 14:59:49 2013 -0700
@@ -242,7 +242,13 @@
 
             // CopyOnWriteArrayList.listIterator().remove() is unsupported
             if (!"java.util.concurrent.CopyOnWriteArrayList".equals(listClass)) {
-                iterator.remove(); // should delete the last element, not throw
+                for (int i = data.length - 1; i >= 0; i--) {
+                    iterator.remove(); // must not throw
+                    if (i > 0) {
+                        iterator.previous();
+                    }
+                }
+                assertTrue(list.isEmpty());
             }
 
             try {