prog8/sim65/test/TestDisassembler.kt

30 lines
839 B
Kotlin
Raw Normal View History

2019-09-04 00:41:09 +00:00
import org.junit.jupiter.api.Test
import sim65.components.*
import java.io.File
import kotlin.test.*
class TestDisassembler {
@Test
fun testDisassembleAllOpcodes() {
2019-09-08 14:42:15 +00:00
val cpu = Cpu6502(true)
2019-09-04 00:41:09 +00:00
val memory = Ram(0, 0xffff)
2019-09-04 20:23:31 +00:00
memory.load("test/testfiles/disassem_instr_test.prg", 0x1000 - 2)
2019-09-04 00:41:09 +00:00
val result = cpu.disassemble(memory, 0x1000, 0x1221)
assertEquals(256, result.size)
assertEquals("\$1000 69 01 adc #\$01", result[0])
val reference = File("test/testfiles/disassem_ref_output.txt").readLines()
assertEquals(256, reference.size)
2019-09-04 20:23:31 +00:00
for (line in result.zip(reference)) {
if (line.first != line.second) {
2019-09-04 00:41:09 +00:00
fail("disassembled instruction mismatch: '${line.first}', expected '${line.second}'")
}
}
}
}