def test_number_label_bin_offset(self): parser = AddressParser() parser.labels = {'foo': 0xC000} self.assertEqual(0xC003, parser.number('foo+%00000011')) self.assertEqual(0xBFFD, parser.number('foo-%00000011')) self.assertEqual(0xC003, parser.number('foo + %00000011')) self.assertEqual(0xBFFD, parser.number('foo - %00000011'))
def test_number_bad_label_with_offset(self): parser = AddressParser() try: parser.number('bad_label+3') self.fail() except KeyError as exc: self.assertEqual('Label not found: bad_label', exc.args[0])
def test_number_bad_label_syntax(self): parser = AddressParser() parser.labels = {'foo': 0xFFFF} try: parser.number('#$foo') self.fail() except KeyError as exc: self.assertEqual('Label not found: #$foo', exc.args[0])
def test_number_label_offset_default_radix(self): parser = AddressParser() parser.labels = {'foo': 0xC000} parser.radix = 16 self.assertEqual(0xC010, parser.number('foo+10')) self.assertEqual(0xBFF0, parser.number('foo-10')) self.assertEqual(0xC010, parser.number('foo + 10')) self.assertEqual(0xBFF0, parser.number('foo - 10')) parser.radix = 10 self.assertEqual(0xC00A, parser.number('foo+10')) self.assertEqual(0xBFF6, parser.number('foo-10')) self.assertEqual(0xC00A, parser.number('foo + 10')) self.assertEqual(0xBFF6, parser.number('foo - 10'))
def test_number_label(self): parser = AddressParser() parser.labels = {'foo': 0xC000} self.assertEqual(0xC000, parser.number('foo'))
def test_number_default_radix(self): parser = AddressParser() parser.radix = 10 self.assertEqual(10, parser.number('10')) parser.radix = 16 self.assertEqual(16, parser.number('10'))
def test_number_bin_literal(self): parser = AddressParser() self.assertEqual(129, parser.number('%10000001'))
def test_number_dec_literal(self): parser = AddressParser() self.assertEqual(49152, parser.number('+49152'))
def test_number_hex_literal(self): parser = AddressParser() self.assertEqual(49152, parser.number('$c000'))