From 1900852cd843f4aded68382193cf925b1c470b55 Mon Sep 17 00:00:00 2001 From: Ivan Hetman Date: Mon, 16 Oct 2023 14:41:15 +0300 Subject: [PATCH] classlib: fix for positioned addAll in sequential lists (#824) --- .../teavm/classlib/java/util/TAbstractSequentialList.java | 1 - .../java/org/teavm/classlib/java/util/LinkedListTest.java | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractSequentialList.java b/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractSequentialList.java index 8483efbe5..77250f636 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractSequentialList.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TAbstractSequentialList.java @@ -72,7 +72,6 @@ public abstract class TAbstractSequentialList extends TAbstractList { boolean added = false; for (TIterator srcIter = c.iterator(); srcIter.hasNext();) { iter.add(srcIter.next()); - iter.next(); added = true; } return added; 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 83dbbbf3f..ec1a07aa0 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 @@ -317,4 +317,11 @@ public class LinkedListTest { assertEquals("1", list.getFirst()); assertEquals("2", list.getLast()); } + + @Test + public void testAddAllPositioned() { + LinkedList ll = new LinkedList<>(Arrays.asList("a", "b", "c", "d")); + ll.addAll(2, new LinkedList<>(ll)); + assertArrayEquals(new String[] {"a", "b", "a", "b", "c", "d", "c", "d"}, ll.toArray()); + } }