Commit c2d59677 authored by Eric Bruneton's avatar Eric Bruneton

Merge branch 'retronymm/asm-inslist-add'

parents c4a9e49c dc8acb48
......@@ -230,6 +230,7 @@ public class InsnList {
lastInsn.nextInsn = insnNode;
insnNode.previousInsn = lastInsn;
}
insnNode.nextInsn = null;
lastInsn = insnNode;
cache = null;
insnNode.index = 0; // insnNode now belongs to an InsnList.
......
......@@ -54,6 +54,8 @@ public class InsnListTest {
private InsnList list2;
private InsnList list3Unchecked;
private InsnNode insn1;
private InsnNode insn2;
......@@ -62,6 +64,7 @@ public class InsnListTest {
public void setUp() throws Exception {
list1 = new CheckedInsnList();
list2 = new CheckedInsnList();
list3Unchecked = new InsnList();
insn1 = new InsnNode(0);
insn2 = new InsnNode(0);
list2.add(insn1);
......@@ -322,6 +325,16 @@ public class InsnListTest {
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
public void testInvalidAdd() {
assertThrows(IllegalArgumentException.class, () -> list1.add(insn1));
......@@ -354,6 +367,14 @@ public class InsnListTest {
assertEquals(true, list1.contains(insn));
}
@Test
public void testAddNodeAssociatedWithAnotherList() {
list3Unchecked.add(insn1);
ListIterator<AbstractInsnNode> iterator = list3Unchecked.iterator();
iterator.next();
assertFalse(iterator.hasNext());
}
@Test
public void testAddEmptyList() {
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