diff test/testir.py @ 307:e609d5296ee9

Massive rewrite of codegenerator
author Windel Bouwman
date Thu, 12 Dec 2013 20:42:56 +0100
parents 6753763d3bec
children 68b01c8abf8a
line wrap: on
line diff
--- a/test/testir.py	Mon Dec 09 19:00:21 2013 +0100
+++ b/test/testir.py	Thu Dec 12 20:42:56 2013 +0100
@@ -3,12 +3,18 @@
 import sys
 import ppci
 from ppci import ir
+from ppci import irutils
 from ppci.transform import ConstantFolder
 
 
 class IrCodeTestCase(unittest.TestCase):
+    def testAdd(self):
+        v = ir.Add(ir.Const(1), ir.Const(2))
+
+
+class IrBuilderTestCase(unittest.TestCase):
     def setUp(self):
-        self.b = ir.Builder()
+        self.b = irutils.Builder()
         self.m = ir.Module('test')
         self.b.setModule(self.m)
 
@@ -51,7 +57,7 @@
 
 class ConstantFolderTestCase(unittest.TestCase):
     def setUp(self):
-        self.b = ir.Builder()
+        self.b = irutils.Builder()
         self.cf = ConstantFolder()
         self.m = ir.Module('test')
         self.b.setModule(self.m)
@@ -77,56 +83,7 @@
         v3 = ir.Add(v1, v2)
 
 
-testsrc = """
-package test2;
 
-function void tesssst(int henkie)
-{
-   var int a, b, cee;
-   a = 2 * 33 - 12;
-   b = a * 2 + 13;
-   a = b + a;
-   cee = a;
-   cee = cee * 2 + a + cee * 2;
-   if (cee + a > b and b *3 - a+8*b== 3*6-b)
-   {
-      var int x = a;
-      x = b * 2 - a;
-      a = x * x * (x + 22 - a);
-   }
-   else
-   {
-      a = b + a + (a + b);
-   }
-   var int y;
-   y = a - b * 53;
-}
-"""
-
-testsrc2 = """
-function int add2(int x, int y)
-{
-   var int res;
-   res = x + y + 2 -  7 + 2;
-   //if (y < 2)
-   //{
-   //   return y - 33;
-   //}
-
-   res = res + (x + 2 * y) + (x + 2 * y) + (2*8) + (2*8);
-
-   if (x > 13)
-   {
-      while (y > 1337)
-      {
-         res = res + 2;
-         y = y - 12;
-      }
-   }
-   return res;
-}
-
-"""
 
 if __name__ == '__main__':
     unittest.main()