diff python/testcg.py @ 209:07bfea4c1ed7

Added codegen test
author Windel Bouwman
date Sat, 29 Jun 2013 10:08:46 +0200
parents
children 494828a7adf1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/testcg.py	Sat Jun 29 10:08:46 2013 +0200
@@ -0,0 +1,22 @@
+import unittest
+import ppci, codegen, ir
+import arm_cm3
+
+class testCodeGeneration(unittest.TestCase):
+    def setUp(self):
+        self.cg = codegen.CodeGenerator(arm_cm3.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()