comparison test/testcg.py @ 284:05184b95fa16

Moved tests to seperate folder
author Windel Bouwman
date Fri, 15 Nov 2013 13:43:22 +0100
parents python/testcg.py@e64bae57cda8
children 7b38782ed496
comparison
equal deleted inserted replaced
283:c9781c73e7e2 284:05184b95fa16
1 import unittest
2 import ppci, codegen, ir
3 import cortexm3 as arm
4 import codegenarm
5 import outstream
6
7 def genTestFunction():
8 m = ir.Module('tst')
9 f = ir.Function('tst')
10 m.addFunction(f)
11 return m, f, f.entry
12
13
14 class testCodeGeneration(unittest.TestCase):
15 def setUp(self):
16 self.cg = codegen.CodeGenerator(arm.armtarget)
17
18 def testFunction(self):
19 m, f, bb = genTestFunction()
20 bb.addInstruction(ir.Const(123))
21 bb.addInstruction(ir.Jump(f.epiloog))
22 m.check()
23 obj = self.cg.generate(m)
24 self.assertTrue(obj)
25
26
27 class testArmCodeGeneration(unittest.TestCase):
28 def testStack(self):
29 s = outstream.OutputStream()
30 cg = codegenarm.ArmCodeGenerator(s)
31 m, f, bb = genTestFunction()
32 bb.addInstruction(ir.Move(ir.Mem(ir.Const(1)), ir.Const(22)))
33 bb.addInstruction(ir.Jump(f.epiloog))
34 m.check()
35 cg.generate(m)
36 #s.dump()
37
38
39 if __name__ == '__main__':
40 unittest.main()
41