Mercurial > lcfOS
view python/testasm.py @ 191:6b2bec5653f1
Added assembler testset
author | Windel Bouwman |
---|---|
date | Sun, 26 May 2013 15:28:07 +0200 |
parents | |
children | f091e7d70996 |
line wrap: on
line source
#!/usr/bin/python import unittest import libasm import ppci class AssemblerTestCase(unittest.TestCase): """ Tests the assembler parts """ def setUp(self): pass def testLex0(self): """ Check if the lexer is OK """ asmline, toks = 'mov rax, rbx ', ['ID', 'ID', ',', 'ID'] self.assertSequenceEqual([tok.typ for tok in libasm.tokenize(asmline)], toks) def testLex1(self): asmline, toks = 'lab1: mov rax, rbx ', ['ID', ':', 'ID', 'ID', ',', 'ID'] self.assertSequenceEqual([tok.typ for tok in libasm.tokenize(asmline)], toks) def testLex2(self): asmline = '0z4: mov rax, rbx $ ' with self.assertRaises(ppci.CompilerError): list(libasm.tokenize(asmline)) def testParse(self): asmline = 'lab1: mov rax, rbx' a = libasm.Assembler() a.assembleLine(asmline) if __name__ == '__main__': unittest.main()