diff python/testir.py @ 237:81752b0f85a5

Added burn led test program
author Windel Bouwman
date Wed, 17 Jul 2013 22:31:54 +0200
parents de3a68f677a5
children ef683881c64e
line wrap: on
line diff
--- a/python/testir.py	Mon Jul 15 20:15:31 2013 +0200
+++ b/python/testir.py	Wed Jul 17 22:31:54 2013 +0200
@@ -5,10 +5,10 @@
     def setUp(self):
         self.b = ir.Builder()
         self.cf = transform.ConstantFolder()
+        self.m = ir.Module('test')
+        self.b.setModule(self.m)
 
     def testBuilder(self):
-        m = ir.Module('test')
-        self.b.setModule(m)
         f = self.b.newFunction('test')
         self.b.setFunction(f)
         bb = self.b.newBB()
@@ -19,11 +19,22 @@
         self.b.addIns(ir.ImmLoad(v1, 5))
         self.b.addIns(ir.ImmLoad(v2, 7))
         self.b.addIns(ir.BinaryOperator(v3, '+', v1, v2))
-        self.assertEqual(3, len(m.Instructions))
-        self.cf.run(m)
-        self.assertEqual(3, len(m.Instructions))
-        self.assertIsInstance(m.Instructions[-1], ir.ImmLoad)
-        self.assertEqual(12, m.Instructions[-1].value)
+        self.assertEqual(3, len(self.m.Instructions))
+        self.cf.run(self.m)
+        self.assertEqual(3, len(self.m.Instructions))
+        self.assertIsInstance(self.m.Instructions[-1], ir.ImmLoad)
+        self.assertEqual(12, self.m.Instructions[-1].value)
+
+    def testAdd0(self):
+        f = self.b.newFunction('test')
+        self.b.setFunction(f)
+        bb = self.b.newBB()
+        self.b.setBB(bb)
+        v1 = self.b.newTmp('t')
+        v2 = self.b.newTmp('t')
+        v3 = self.b.newTmp('t')
+        self.b.addIns(ir.ImmLoad(v2, 0))
+        self.b.addIns(ir.BinaryOperator(v3, '+', v1, v2))
 
 
 testsrc = """
@@ -75,8 +86,8 @@
 """
 
 if __name__ == '__main__':
-   unittest.main()
-   sys.exit()
+   #unittest.main()
+   #sys.exit()
    diag = ppci.DiagnosticsManager()
    builder = c3.Builder(diag)
    cgenx86 = x86.X86CodeGenSimple(diag)