1
0
mirror of https://github.com/mnaberez/py65.git synced 2024-11-18 15:06:35 +00:00

Add tests for branch calculation fixes

This commit is contained in:
Mike Naberezny 2011-08-21 11:43:39 -07:00
parent 4b96bdee65
commit 3bed1d2247
2 changed files with 14 additions and 5 deletions

View File

@ -867,10 +867,14 @@ class AssemblerTests(unittest.TestCase):
def dont_test_assembles_ef(self):
pass
def test_assembles_f0(self):
def test_assembles_f0_forward(self):
self.assertEqual([0xf0, 0x44],
self.assemble('BEQ $0046'))
def test_assembles_f0_backward(self):
self.assertEqual([0xf0, 0xfc],
self.assemble('BEQ $BFFE', pc=0xc000))
def test_assembles_f1(self):
self.assertEqual([0xf1, 0x44],
self.assemble('SBC ($44),Y'))

View File

@ -1205,10 +1205,15 @@ class DisassemblerTests(unittest.TestCase):
self.assertEqual(1, length)
self.assertEqual('???', disasm)
def test_disassembles_f0(self):
def test_disassembles_f0_forward(self):
length, disasm = self.disassemble([0xf0, 0x44])
self.assertEqual(2, length)
self.assertEqual('BEQ $0046', disasm)
def test_disassembled_f0_backward(self):
length, disasm = self.disassemble([0xf0, 0xfc], pc=0xc000)
self.assertEqual(2, length)
self.assertEqual('BEQ $bffe', disasm)
def test_disassembles_f1(self):
length, disasm = self.disassemble([0xf1, 0x44])
@ -1287,12 +1292,12 @@ class DisassemblerTests(unittest.TestCase):
# Test Helpers
def disassemble(self, bytes):
def disassemble(self, bytes, pc=0):
mpu = MPU()
address_parser = AddressParser()
disasm = Disassembler(mpu, address_parser)
mpu.memory[0:len(bytes)-1] = bytes
return disasm.instruction_at(0)
mpu.memory[pc:len(bytes)-1] = bytes
return disasm.instruction_at(pc)
def test_suite():
return unittest.findTestCases(sys.modules[__name__])