comparison python/testasm.py @ 191:6b2bec5653f1

Added assembler testset
author Windel Bouwman
date Sun, 26 May 2013 15:28:07 +0200
parents
children f091e7d70996
comparison
equal deleted inserted replaced
190:65dda7e7e8bd 191:6b2bec5653f1
1 #!/usr/bin/python
2
3 import unittest
4 import libasm
5 import ppci
6
7 class AssemblerTestCase(unittest.TestCase):
8 """
9 Tests the assembler parts
10 """
11 def setUp(self):
12 pass
13
14 def testLex0(self):
15 """ Check if the lexer is OK """
16 asmline, toks = 'mov rax, rbx ', ['ID', 'ID', ',', 'ID']
17 self.assertSequenceEqual([tok.typ for tok in libasm.tokenize(asmline)], toks)
18
19 def testLex1(self):
20 asmline, toks = 'lab1: mov rax, rbx ', ['ID', ':', 'ID', 'ID', ',', 'ID']
21 self.assertSequenceEqual([tok.typ for tok in libasm.tokenize(asmline)], toks)
22
23 def testLex2(self):
24 asmline = '0z4: mov rax, rbx $ '
25 with self.assertRaises(ppci.CompilerError):
26 list(libasm.tokenize(asmline))
27
28 def testParse(self):
29 asmline = 'lab1: mov rax, rbx'
30 a = libasm.Assembler()
31 a.assembleLine(asmline)
32
33 if __name__ == '__main__':
34 unittest.main()
35