Open-source multiplayer game server compatible with the RuneScape client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
openrs2/deob/src/test/java/dev/openrs2/deob/test/BytecodeTest.kt

35 lines
881 B

package dev.openrs2.deob.test
import org.objectweb.asm.Opcodes
import org.objectweb.asm.commons.InstructionAdapter
import org.objectweb.asm.tree.MethodNode
@DslMarker
annotation class BytecodeDslMarker
enum class Expectation {
Removed,
Added,
Present
}
data class BytecodeTest(val code: MethodNode, val expectations: List<Expectation>)
@BytecodeDslMarker
class BytecodeTestBuilder : InstructionAdapter(Opcodes.ASM7, MethodNode()) {
val method = mv as MethodNode
val expectations = mutableListOf<Expectation>()
override fun visitInsn(opcode: Int) {
super.visitInsn(opcode)
expectations.add(Expectation.Present)
}
operator fun Unit.unaryMinus() {
expectations[expectations.size - 1] = Expectation.Removed
}
operator fun Unit.unaryPlus() {
expectations[expectations.size - 1] = Expectation.Added
}
}