mirror of
https://github.com/ReVanced/revanced-patcher.git
synced 2026-01-20 09:53:55 +00:00
feat: Add findParentMethod utility method (#4)
* feat: Add `findParentMethod` utitly method * refactor: add `resolveMethod` to `MethodResolver` added some assertions and some tests Co-authored-by: Lucaskyy <contact@sculas.xyz>
This commit is contained in:
@@ -9,11 +9,13 @@ import net.revanced.patcher.util.ExtraTypes
|
||||
import net.revanced.patcher.util.TestUtil
|
||||
import net.revanced.patcher.writer.ASMWriter.insertAt
|
||||
import net.revanced.patcher.writer.ASMWriter.setAt
|
||||
import org.junit.jupiter.api.assertThrows
|
||||
import org.objectweb.asm.Opcodes.*
|
||||
import org.objectweb.asm.Type
|
||||
import org.objectweb.asm.tree.*
|
||||
import java.io.PrintStream
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
internal class PatcherTest {
|
||||
companion object {
|
||||
@@ -145,4 +147,27 @@ internal class PatcherTest {
|
||||
// out.close()
|
||||
// testData.close()
|
||||
//}
|
||||
|
||||
@Test()
|
||||
fun `should raise an exception because opcodes is empty`() {
|
||||
val sigName = "testMethod"
|
||||
val e = assertThrows<IllegalArgumentException>("Should raise an exception because opcodes is empty") {
|
||||
Patcher(
|
||||
PatcherTest::class.java.getResourceAsStream("/test1.jar")!!,
|
||||
arrayOf(
|
||||
Signature(
|
||||
sigName,
|
||||
Type.VOID_TYPE,
|
||||
ACC_PUBLIC or ACC_STATIC,
|
||||
arrayOf(ExtraTypes.ArrayAny),
|
||||
emptyArray() // this is not allowed for non-search signatures!
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
assertEquals(
|
||||
"Opcode list for signature $sigName is empty. This is not allowed for non-search signatures.",
|
||||
e.message
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user