diff python/testc3.py @ 268:5ec7580976d9

Op naar tree-IR
author Windel Bouwman
date Wed, 14 Aug 2013 20:12:40 +0200
parents c4370696ccc7
children e64bae57cda8
line wrap: on
line diff
--- a/python/testc3.py	Mon Aug 12 20:14:47 2013 +0200
+++ b/python/testc3.py	Wed Aug 14 20:12:40 2013 +0200
@@ -126,11 +126,11 @@
         p1 = """package p1;
         type int A;
         """
+        self.assertTrue(self.builder.build(p1))
         p2 = """package p2;
         import p1;
         var A b;
         """
-        self.assertTrue(self.builder.build(p1))
         self.expectOK(p2)
 
     def testFunctArgs(self):
@@ -171,27 +171,7 @@
             c = b * a - 3;
          }
       """
-      block_code = """ a0 = alloc
-        b1 = alloc
-        c2 = alloc
-        const3 = 1
-        [a0] = const3
-        t4 = [a0]
-        const5 = 2
-        mul6 = t4 * const5
-        t7 = [a0]
-        t8 = [a0]
-        mul9 = t7 * t8
-        add10 = mul6 + mul9
-        [b1] = add10
-        t11 = [b1]
-        t12 = [a0]
-        mul13 = t11 * t12
-        const14 = 3
-        sub15 = mul13 - const14
-        [c2] = sub15
-      ret """
-      self.expectIR(snippet, block_code)
+      self.expectOK(snippet)
 
     def testEmpty(self):
       snippet = """
@@ -284,16 +264,7 @@
             b = a + 2;
          }
         """
-        block_code = """a0 = alloc
-         b1 = alloc
-         const2 = 2
-         [a0] = const2
-         t3 = [a0]
-         const4 = 2
-         add5 = t3 + const4
-         [b1] = add5
-         ret  """
-        self.expectIR(snippet, block_code)
+        self.expectOK(snippet)
 
     def testUnknownType(self):
         snippet = """package testlocalvar;
@@ -314,21 +285,7 @@
             a.y = a.x + 2;
          }
         """
-        block_code = """a0 = alloc
-         const1 = 2
-         off_x2 = 0
-         adr_x3 = a0 + off_x2
-         [adr_x3] = const1
-         off_x4 = 0
-         adr_x5 = a0 + off_x4
-         t6 = [adr_x5]
-         const7 = 2
-         add8 = t6 + const7
-         off_y9 = 4
-         adr_y10 = a0 + off_y9
-         [adr_y10] = add8
-         ret  """
-        self.expectIR(snippet, block_code)
+        self.expectOK(snippet)
 
     def testPointerType1(self):
         snippet = """
@@ -381,14 +338,7 @@
             *a = 2;
          }
         """
-        block_code = """a0 = alloc
-         const1 = 40
-         [a0] = const1
-         const2 = 2
-         deref3 = [a0]
-         [deref3] = const2
-         ret  """
-        self.expectIR(snippet, block_code)
+        self.expectOK(snippet)
 
     def testPointerTypeIr2(self):
         snippet = """
@@ -402,26 +352,7 @@
             a->y = a->x - 14;
          }
         """
-        block_code = """a0 = alloc
-         const1 = 40
-         [a0] = const1
-         const2 = 2
-         deref3 = [a0]
-         off_x4 = 0
-         adr_x5 = deref3 + off_x4
-         [adr_x5] = const2
-         deref6 = [a0]
-         off_x7 = 0
-         adr_x8 = deref6 + off_x7
-         t9 = [adr_x8]
-         const10 = 14
-         sub11 = t9 - const10
-         deref12 = [a0]
-         off_y13 = 4
-         adr_y14 = deref12 + off_y13
-         [adr_y14] = sub11
-         ret  """
-        self.expectIR(snippet, block_code)
+        self.expectOK(snippet)
 
     def testWrongCast(self):
         snippet = """