Commit c2d59677 authored by Eric Bruneton's avatar Eric Bruneton

Merge branch 'retronymm/asm-inslist-add'

parents c4a9e49c dc8acb48
Pipeline #1996 passed with stage
in 7 minutes and 39 seconds
...@@ -230,6 +230,7 @@ public class InsnList { ...@@ -230,6 +230,7 @@ public class InsnList {
lastInsn.nextInsn = insnNode; lastInsn.nextInsn = insnNode;
insnNode.previousInsn = lastInsn; insnNode.previousInsn = lastInsn;
} }
insnNode.nextInsn = null;
lastInsn = insnNode; lastInsn = insnNode;
cache = null; cache = null;
insnNode.index = 0; // insnNode now belongs to an InsnList. insnNode.index = 0; // insnNode now belongs to an InsnList.
......
...@@ -54,6 +54,8 @@ public class InsnListTest { ...@@ -54,6 +54,8 @@ public class InsnListTest {
private InsnList list2; private InsnList list2;
private InsnList list3Unchecked;
private InsnNode insn1; private InsnNode insn1;
private InsnNode insn2; private InsnNode insn2;
...@@ -62,6 +64,7 @@ public class InsnListTest { ...@@ -62,6 +64,7 @@ public class InsnListTest {
public void setUp() throws Exception { public void setUp() throws Exception {
list1 = new CheckedInsnList(); list1 = new CheckedInsnList();
list2 = new CheckedInsnList(); list2 = new CheckedInsnList();
list3Unchecked = new InsnList();
insn1 = new InsnNode(0); insn1 = new InsnNode(0);
insn2 = new InsnNode(0); insn2 = new InsnNode(0);
list2.add(insn1); list2.add(insn1);
...@@ -322,6 +325,16 @@ public class InsnListTest { ...@@ -322,6 +325,16 @@ public class InsnListTest {
assertEquals(insn, list1.get(1)); assertEquals(insn, list1.get(1));
} }
@Test
public void testSetNodeAssociatedWithAnotherList() {
InsnNode insnNode = new InsnNode(0);
list3Unchecked.add(insnNode);
list3Unchecked.set(insnNode, insn1);
ListIterator<AbstractInsnNode> iterator = list3Unchecked.iterator();
iterator.next();
assertFalse(iterator.hasNext());
}
@Test @Test
public void testInvalidAdd() { public void testInvalidAdd() {
assertThrows(IllegalArgumentException.class, () -> list1.add(insn1)); assertThrows(IllegalArgumentException.class, () -> list1.add(insn1));
...@@ -354,6 +367,14 @@ public class InsnListTest { ...@@ -354,6 +367,14 @@ public class InsnListTest {
assertEquals(true, list1.contains(insn)); assertEquals(true, list1.contains(insn));
} }
@Test
public void testAddNodeAssociatedWithAnotherList() {
list3Unchecked.add(insn1);
ListIterator<AbstractInsnNode> iterator = list3Unchecked.iterator();
iterator.next();
assertFalse(iterator.hasNext());
}
@Test @Test
public void testAddEmptyList() { public void testAddEmptyList() {
list1.add(new InsnList()); list1.add(new InsnList());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment