Ejemplo n.º 1
0
 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'))
Ejemplo n.º 2
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])
Ejemplo n.º 3
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'))
Ejemplo n.º 4
0
 def test_number_label(self):
     parser = AddressParser()
     parser.labels = {'foo': 0xC000}
     self.assertEqual(0xC000, parser.number('foo'))
Ejemplo n.º 5
0
 def test_number_constrains_address_at_maxwidth_24(self):
     parser = AddressParser()
     parser.maxwidth = 24
     parser.labels = {'foo': 0xFFFFFF}
     self.assertRaises(OverflowError, parser.number, 'foo+5')