Esempio n. 1
0
    def test_several_lists_with_labels(self):
        code = '''
            .org $E000

            palette:
              .db $0F,$01,$02,$03,$04,$05,$06,$07,$08,$09,$0A,$0B,$0C,$0D,$0E,$0F
              .db $0F,$30,$31,$32,$33,$35,$36,$37,$38,$39,$3A,$3B,$3C,$3D,$3E,$0F

            sprites:
              .db $80, $00, $03, $80; Y pos, tile id, attributes, X pos
              '''

        tokens = lexical(code)
        ast = syntax(tokens)
        self.assertEquals(4, len(ast))
        self.assertEquals('S_DIRECTIVE', ast[0]['type'])
        self.assertEquals('.org', ast[0]['children'][0]['value'])
        self.assertEquals('S_DIRECTIVE', ast[1]['type'])
        self.assertEquals('.db', ast[1]['children'][0]['value'])
        self.assertEquals(['palette'], ast[1]['labels'])

        self.assertEquals('S_DIRECTIVE', ast[2]['type'])
        self.assertEquals('.db', ast[2]['children'][0]['value'])

        self.assertEquals('S_DIRECTIVE', ast[3]['type'])
        self.assertEquals('.db', ast[3]['children'][0]['value'])
        self.assertEquals(['sprites'], ast[3]['labels'])

        labels = get_labels(ast)
        expected = {'palette': 0xE000, 'sprites': 0xE000 + 32}

        self.assertEquals(expected, labels)
Esempio n. 2
0
 def test_get_labels(self):
     expected = {}
     expected['WAITVBLANK'] = 0xC000
     expected['palette'] = 0xE000
     expected['sprites'] = 0xE000 + 32
     actual = get_labels(self.ast)
     self.assertEquals(expected['WAITVBLANK'], actual['WAITVBLANK'])
     self.assertEquals(expected['palette'], actual['palette'])
     self.assertEquals(expected['sprites'], actual['sprites'])
Esempio n. 3
0
 def test_get_labels(self):
     expected = {}
     expected['WAITVBLANK'] = 0xC000
     expected['palette'] = 0xE000
     expected['sprites'] = 0xE000 + 32
     actual = get_labels(self.ast)
     self.assertEquals(expected['WAITVBLANK'], actual['WAITVBLANK'])
     self.assertEquals(expected['palette'], actual['palette'])
     self.assertEquals(expected['sprites'], actual['sprites'])
Esempio n. 4
0
    def test_instructions_with_labels(self):
        code = '''
              .org $C000

            WAITVBLANK:
              BIT $2002
              BPL WAITVBLANK
              RTS'''

        tokens = lexical(code)
        ast = syntax(tokens)
        self.assertEquals(4, len(ast))
        self.assertEquals('S_DIRECTIVE', ast[0]['type'])
        self.assertEquals('S_ABSOLUTE', ast[1]['type'])
        self.assertEquals(['WAITVBLANK'], ast[1]['labels'])

        labels = get_labels(ast)
        expected = {'WAITVBLANK': 0xc000}

        self.assertEquals(expected, labels)