test: improve PatcherTest

This commit is contained in:
Lucaskyy
2022-03-20 16:28:23 +01:00
parent 0e72a6e85f
commit ec8115f3ac
3 changed files with 91 additions and 17 deletions

View File

@@ -7,4 +7,14 @@ object ASMWriter {
fun InsnList.setAt(index: Int, node: AbstractInsnNode) {
this[this.get(index)] = node
}
fun InsnList.insertAt(index: Int, vararg nodes: AbstractInsnNode) {
this.insert(this.get(index), nodes.toInsnList())
}
// TODO(Sculas): Should this be public?
private fun Array<out AbstractInsnNode>.toInsnList(): InsnList {
val list = InsnList()
this.forEach { list.add(it) }
return list
}
}