### Question:
InsnList implements Iterable<AbstractInsnNode> { public AbstractInsnNode[] toArray() { int currentInsnIndex = 0; AbstractInsnNode currentInsn = firstInsn; AbstractInsnNode[] insnNodeArray = new AbstractInsnNode[size]; while (currentInsn != null) { insnNodeArray[currentInsnIndex] = currentInsn; currentInsn.index = currentInsnIndex++; currentInsn = currentInsn.nextInsn; } return insnNodeArray; }  int size(); AbstractInsnNode getFirst(); AbstractInsnNode getLast(); AbstractInsnNode get(final int index); boolean contains(final AbstractInsnNode insnNode); int indexOf(final AbstractInsnNode insnNode); void accept(final MethodVisitor methodVisitor); @Override ListIterator<AbstractInsnNode> iterator(); @SuppressWarnings("unchecked") ListIterator<AbstractInsnNode> iterator(final int index); AbstractInsnNode[] toArray(); void set(final AbstractInsnNode oldInsnNode, final AbstractInsnNode newInsnNode); void add(final AbstractInsnNode insnNode); void add(final InsnList insnList); void insert(final AbstractInsnNode insnNode); void insert(final InsnList insnList); void insert(final AbstractInsnNode previousInsn, final AbstractInsnNode insnNode); void insert(final AbstractInsnNode previousInsn, final InsnList insnList); void insertBefore(final AbstractInsnNode nextInsn, final AbstractInsnNode insnNode); void insertBefore(final AbstractInsnNode nextInsn, final InsnList insnList); void remove(final AbstractInsnNode insnNode); void clear(); void resetLabels();  }### Answer:
@Test public void testToArray_emptyList() { assertEquals(0, newInsnList().toArray().length); }
@Test public void testToArray_nonEmptyList() { InsnList insnList = newInsnList(insn1, insn2); AbstractInsnNode[] insnArray = insnList.toArray(); assertArrayEquals(new AbstractInsnNode[] {insn1, insn2}, insnArray); }