Mercurial > lcfOS
diff test/testasm.py @ 337:b00219172a42
Added cool lm3s811 qemu project
author | Windel Bouwman |
---|---|
date | Thu, 20 Feb 2014 20:04:52 +0100 |
parents | 582a1aaa3983 |
children | 4d204f6f7d4e |
line wrap: on
line diff
--- a/test/testasm.py Wed Feb 19 22:32:15 2014 +0100 +++ b/test/testasm.py Thu Feb 20 20:04:52 2014 +0100 @@ -3,7 +3,7 @@ import unittest, cProfile from ppci import CompilerError from ppci.asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber -from ppci.assembler import tokenize, Assembler +from ppci.assembler import tokenize, Assembler, asmParser, Lexer from ppci.objectfile import ObjectFile from ppci.linker import Linker import outstream @@ -40,15 +40,22 @@ Tests the assembler parts """ def setUp(self): - self.a = Assembler() + self.parser = asmParser + self.stack = [] + + def emit(self, x): + self.stack.append(x) + + def parse_line(self, line): + self.parser.parse(Lexer(line), self.emit) def testParse(self): asmline = 'lab1: mov rax, rbx' - self.a.parse_line(asmline) + self.parse_line(asmline) def expectTree(self, asmline, stack): - self.a.parse_line(asmline) - self.assertSequenceEqual(stack, self.a.stack) + self.parse_line(asmline) + self.assertSequenceEqual(stack, self.stack) def testParse2(self): asmline = 'a: mov rax, [rbx + 2]' @@ -82,14 +89,7 @@ def testParse6(self): # A line can be empty - self.a.parse_line('') - - -class AssemblerOtherTestCase(unittest.TestCase): - def testWithoutTarget(self): - a = Assembler() - with self.assertRaises(CompilerError): - a.assemble_line('') + self.parse_line('') class OustreamTestCase(unittest.TestCase):