view python/testcg.py @ 220:3f6c30a5d234

Major change in expression parsing to enable pointers and structs
author Windel Bouwman
date Sat, 06 Jul 2013 21:32:20 +0200
parents 494828a7adf1
children 6259856841a0
line wrap: on
line source

import unittest
import ppci, codegen, ir
import cortexm3 as arm

class testCodeGeneration(unittest.TestCase):
    def setUp(self):
        self.cg = codegen.CodeGenerator(arm.armtarget)

    def testFunction(self):
        m = ir.Module('tst')
        f = ir.Function('tst')
        m.addFunction(f)
        bb = ir.BasicBlock('entry')
        f.addBasicBlock(bb)
        v = ir.Value('tst')
        bb.addInstruction(ir.ImmLoad(v, 123))
        m.check()
        obj = self.cg.generate(m)
        self.assertTrue(obj)

if __name__ == '__main__':
   unittest.main()