From 8c3f071f88f526aac3e58a00d1816a296f4c5ac2 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Fri, 4 Nov 2016 13:28:34 +0300 Subject: [PATCH] Fix updating size in LinkedList.remove (fix #226). --- .../main/java/org/teavm/classlib/java/util/TLinkedList.java | 1 - .../java/org/teavm/classlib/java/util/LinkedListTest.java | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java b/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java index d91237ac4..6ed9bc27d 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java @@ -348,7 +348,6 @@ public class TLinkedList extends TAbstractSequentialList implements TDeque } else if (currentEntry == nextEntry) { nextEntry = hasPrevious() ? prevEntry.next : null; } - --size; version = modCount; currentEntry = null; } diff --git a/tests/src/test/java/org/teavm/classlib/java/util/LinkedListTest.java b/tests/src/test/java/org/teavm/classlib/java/util/LinkedListTest.java index 5f6e4dcb0..1214a7558 100644 --- a/tests/src/test/java/org/teavm/classlib/java/util/LinkedListTest.java +++ b/tests/src/test/java/org/teavm/classlib/java/util/LinkedListTest.java @@ -106,6 +106,7 @@ public class LinkedListTest { assertEquals(2, iter.nextIndex()); assertEquals("a", iter.next()); assertArrayEquals(new String[] { "1", "2", "a", "b" }, list.toArray(new String[0])); + assertEquals(4, list.size()); } @Test @@ -138,6 +139,7 @@ public class LinkedListTest { iter.remove(); assertEquals(1, iter.nextIndex()); assertEquals("3", iter.next()); + assertEquals(4, list.size()); } @Test(expected = IllegalStateException.class) @@ -195,7 +197,7 @@ public class LinkedListTest { } @Test - public void removesFirstOccurence() { + public void removesFirstOccurrence() { LinkedList list = new LinkedList<>(); list.addAll(Arrays.asList("1", "2", "3", "1", "2")); assertFalse(list.removeFirstOccurrence("*")); @@ -205,7 +207,7 @@ public class LinkedListTest { } @Test - public void removesLastOccurence() { + public void removesLastOccurrence() { LinkedList list = new LinkedList<>(); list.addAll(Arrays.asList("1", "2", "3", "1", "2")); assertFalse(list.removeLastOccurrence("*"));