Mercurial > lcfOS
comparison test/testasm.py @ 335:582a1aaa3983
Added long branch format
author | Windel Bouwman |
---|---|
date | Mon, 17 Feb 2014 20:41:30 +0100 |
parents | 6f4753202b9a |
children | b00219172a42 |
comparison
equal
deleted
inserted
replaced
334:6f4753202b9a | 335:582a1aaa3983 |
---|---|
2 | 2 |
3 import unittest, cProfile | 3 import unittest, cProfile |
4 from ppci import CompilerError | 4 from ppci import CompilerError |
5 from ppci.asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber | 5 from ppci.asmnodes import AInstruction, ABinop, AUnop, ASymbol, ALabel, ANumber |
6 from ppci.assembler import tokenize, Assembler | 6 from ppci.assembler import tokenize, Assembler |
7 from ppci.objectfile import ObjectFile | |
8 from ppci.linker import Linker | |
7 import outstream | 9 import outstream |
8 from target import Label | 10 from target import Label |
9 | 11 |
10 | 12 |
11 class AssemblerLexingCase(unittest.TestCase): | 13 class AssemblerLexingCase(unittest.TestCase): |
90 a.assemble_line('') | 92 a.assemble_line('') |
91 | 93 |
92 | 94 |
93 class OustreamTestCase(unittest.TestCase): | 95 class OustreamTestCase(unittest.TestCase): |
94 def test1(self): | 96 def test1(self): |
95 o = outstream.BinOutputStream() | 97 obj = ObjectFile() |
98 o = outstream.BinaryOutputStream(obj) | |
96 o.selectSection('.text') | 99 o.selectSection('.text') |
97 o.emit(Label('a')) | 100 o.emit(Label('a')) |
98 self.assertSequenceEqual(bytes(), o.Data) | 101 self.assertSequenceEqual(bytes(), obj.get_section('.text').data) |
99 | 102 |
100 | 103 |
101 class AsmTestCaseBase(unittest.TestCase): | 104 class AsmTestCaseBase(unittest.TestCase): |
102 """ Base testcase for assembly """ | 105 """ Base testcase for assembly """ |
103 def feed(self, line): | 106 def feed(self, line): |
104 self.a.assemble(line) | 107 self.a.assemble(line) |
105 | 108 |
106 def check(self, hexstr): | 109 def check(self, hexstr): |
107 self.assertSequenceEqual(bytes.fromhex(hexstr), self.o.Data) | 110 l = Linker() |
111 self.obj = l.link([self.obj]) | |
112 data = bytes(self.obj.get_section('.text').data) | |
113 self.assertSequenceEqual(bytes.fromhex(hexstr), data) | |
108 | 114 |
109 | 115 |
110 if __name__ == '__main__': | 116 if __name__ == '__main__': |
111 unittest.main() | 117 unittest.main() |