view python/testcg.py @ 222:c3f1ce8b638f

Fixup of parser
author Windel Bouwman
date Tue, 09 Jul 2013 17:36:31 +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()