1
0
mirror of https://github.com/mnaberez/py65.git synced 2025-01-07 20:31:47 +00:00

Reindent at 4 spaces for PEP8

This commit is contained in:
Mike Naberezny 2012-01-14 13:34:15 -08:00
parent ef17a438d4
commit 3d616630eb
3 changed files with 5312 additions and 5312 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,122 +3,122 @@ import sys
from py65.utils.addressing import AddressParser from py65.utils.addressing import AddressParser
class AddressParserTests(unittest.TestCase): class AddressParserTests(unittest.TestCase):
def test_maxwidth_can_be_set_in_constructor(self): def test_maxwidth_can_be_set_in_constructor(self):
parser = AddressParser(maxwidth=24) parser = AddressParser(maxwidth=24)
self.assertEqual(24, parser.maxwidth) self.assertEqual(24, parser.maxwidth)
self.assertEqual(0xFFFFFF, parser._maxaddr) self.assertEqual(0xFFFFFF, parser._maxaddr)
def test_maxwidth_defaults_to_16_bits(self): def test_maxwidth_defaults_to_16_bits(self):
parser = AddressParser() parser = AddressParser()
self.assertEqual(16, parser.maxwidth) self.assertEqual(16, parser.maxwidth)
self.assertEqual(0xFFFF, parser._maxaddr) self.assertEqual(0xFFFF, parser._maxaddr)
def test_maxwidth_setter(self): def test_maxwidth_setter(self):
parser = AddressParser() parser = AddressParser()
parser.maxwidth = 24 parser.maxwidth = 24
self.assertEqual(24, parser.maxwidth) self.assertEqual(24, parser.maxwidth)
self.assertEqual(0xFFFFFF, parser._maxaddr) self.assertEqual(0xFFFFFF, parser._maxaddr)
def test_number_hex_literal(self): def test_number_hex_literal(self):
parser = AddressParser() parser = AddressParser()
self.assertEqual(49152, parser.number('$c000')) self.assertEqual(49152, parser.number('$c000'))
def test_number_dec_literal(self): def test_number_dec_literal(self):
parser = AddressParser() parser = AddressParser()
self.assertEqual(49152, parser.number('+49152')) self.assertEqual(49152, parser.number('+49152'))
def test_number_bin_literal(self): def test_number_bin_literal(self):
parser = AddressParser() parser = AddressParser()
self.assertEqual(129, parser.number('%10000001')) self.assertEqual(129, parser.number('%10000001'))
def test_number_default_radix(self): def test_number_default_radix(self):
parser = AddressParser() parser = AddressParser()
parser.radix = 10 parser.radix = 10
self.assertEqual(10, parser.number('10')) self.assertEqual(10, parser.number('10'))
parser.radix = 16 parser.radix = 16
self.assertEqual(16, parser.number('10')) self.assertEqual(16, parser.number('10'))
def test_number_label(self):
parser = AddressParser()
parser.labels = {'foo': 0xC000}
self.assertEqual(0xC000, parser.number('foo'))
def test_number_bad_label(self):
parser = AddressParser()
try:
parser.number('bad_label')
self.fail()
except KeyError, why:
self.assertEqual('Label not found: bad_label', why[0])
def test_number_label_hex_offset(self): def test_number_label(self):
parser = AddressParser() parser = AddressParser()
parser.labels = {'foo': 0xC000} parser.labels = {'foo': 0xC000}
self.assertEqual(0xC003, parser.number('foo+$3')) self.assertEqual(0xC000, parser.number('foo'))
self.assertEqual(0xBFFD, parser.number('foo-$3'))
self.assertEqual(0xC003, parser.number('foo + $3'))
self.assertEqual(0xBFFD, parser.number('foo - $3'))
def test_number_label_dec_offset(self): def test_number_bad_label(self):
parser = AddressParser() parser = AddressParser()
parser.labels = {'foo': 0xC000} try:
self.assertEqual(0xC003, parser.number('foo++3')) parser.number('bad_label')
self.assertEqual(0xBFFD, parser.number('foo-+3')) self.fail()
self.assertEqual(0xC003, parser.number('foo + +3')) except KeyError, why:
self.assertEqual(0xBFFD, parser.number('foo - +3')) self.assertEqual('Label not found: bad_label', why[0])
def test_number_label_bin_offset(self): def test_number_label_hex_offset(self):
parser = AddressParser() parser = AddressParser()
parser.labels = {'foo': 0xC000} parser.labels = {'foo': 0xC000}
self.assertEqual(0xC003, parser.number('foo+%00000011')) self.assertEqual(0xC003, parser.number('foo+$3'))
self.assertEqual(0xBFFD, parser.number('foo-%00000011')) self.assertEqual(0xBFFD, parser.number('foo-$3'))
self.assertEqual(0xC003, parser.number('foo + %00000011')) self.assertEqual(0xC003, parser.number('foo + $3'))
self.assertEqual(0xBFFD, parser.number('foo - %00000011')) self.assertEqual(0xBFFD, parser.number('foo - $3'))
def test_number_label_offset_default_radix(self): def test_number_label_dec_offset(self):
parser = AddressParser() parser = AddressParser()
parser.labels = {'foo': 0xC000} parser.labels = {'foo': 0xC000}
parser.radix = 16 self.assertEqual(0xC003, parser.number('foo++3'))
self.assertEqual(0xC010, parser.number('foo+10')) self.assertEqual(0xBFFD, parser.number('foo-+3'))
self.assertEqual(0xBFF0, parser.number('foo-10')) self.assertEqual(0xC003, parser.number('foo + +3'))
self.assertEqual(0xC010, parser.number('foo + 10')) self.assertEqual(0xBFFD, parser.number('foo - +3'))
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_bad_label_with_offset(self):
parser = AddressParser()
try:
parser.number('bad_label+3')
self.fail()
except KeyError, why:
self.assertEqual('Label not found: bad_label', why[0])
def test_number_truncates_address_at_maxwidth_16(self): def test_number_label_bin_offset(self):
parser = AddressParser() parser = AddressParser()
parser.labels = {'foo': 0xFFFF} parser.labels = {'foo': 0xC000}
self.assertEqual(0xFFFF, parser.number('foo+5')) 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_truncates_address_at_maxwidth_24(self): def test_number_label_offset_default_radix(self):
parser = AddressParser() parser = AddressParser()
parser.maxwidth = 24 parser.labels = {'foo': 0xC000}
parser.labels = {'foo': 0xFFFFFF} parser.radix = 16
self.assertEqual(0xFFFFFF, parser.number('foo+5')) 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_label_for_returns_label(self): def test_number_bad_label_with_offset(self):
parser = AddressParser(labels={'chrout':0xFFD2}) parser = AddressParser()
self.assertEqual('chrout', parser.label_for(0xFFD2)) try:
parser.number('bad_label+3')
def test_label_for_returns_none_by_default(self): self.fail()
parser = AddressParser(labels={}) except KeyError, why:
self.assertEqual(None, parser.label_for(0xFFD2)) self.assertEqual('Label not found: bad_label', why[0])
def test_label_for_returns_alternate_default(self): def test_number_truncates_address_at_maxwidth_16(self):
parser = AddressParser(labels={}) parser = AddressParser()
self.assertEqual('foo', parser.label_for(0xFFD2, 'foo')) parser.labels = {'foo': 0xFFFF}
self.assertEqual(0xFFFF, parser.number('foo+5'))
def test_number_truncates_address_at_maxwidth_24(self):
parser = AddressParser()
parser.maxwidth = 24
parser.labels = {'foo': 0xFFFFFF}
self.assertEqual(0xFFFFFF, parser.number('foo+5'))
def test_label_for_returns_label(self):
parser = AddressParser(labels={'chrout':0xFFD2})
self.assertEqual('chrout', parser.label_for(0xFFD2))
def test_label_for_returns_none_by_default(self):
parser = AddressParser(labels={})
self.assertEqual(None, parser.label_for(0xFFD2))
def test_label_for_returns_alternate_default(self):
parser = AddressParser(labels={})
self.assertEqual('foo', parser.label_for(0xFFD2, 'foo'))
def test_suite(): def test_suite():

View File

@ -3,14 +3,14 @@ import unittest
from py65.utils.conversions import itoa from py65.utils.conversions import itoa
class ConversionsTopLevelTests(unittest.TestCase): class ConversionsTopLevelTests(unittest.TestCase):
def test_itoa_decimal_output(self): def test_itoa_decimal_output(self):
self.assertEqual('10', itoa(10, base=10)) self.assertEqual('10', itoa(10, base=10))
def test_itoa_hex_output(self): def test_itoa_hex_output(self):
self.assertEqual('a', itoa(10, base=16)) self.assertEqual('a', itoa(10, base=16))
def test_itoa_bin_output(self): def test_itoa_bin_output(self):
self.assertEqual('1010', itoa(10, base=2)) self.assertEqual('1010', itoa(10, base=2))
def test_suite(): def test_suite():