diff python/testc3.py @ 169:ee0d30533dae

Added more tests and improved the diagnostic update
author Windel Bouwman
date Sat, 23 Mar 2013 18:34:41 +0100
parents 49f1ab80d040
children 4348da5ca307
line wrap: on
line diff
--- a/python/testc3.py	Fri Mar 22 19:09:38 2013 +0100
+++ b/python/testc3.py	Sat Mar 23 18:34:41 2013 +0100
@@ -81,6 +81,8 @@
    def setUp(self):
       self.diag = ppci.DiagnosticsManager()
       self.builder = c3.Builder(self.diag)
+   def testSrc(self):
+      self.builder.build(testsrc)
    def testFunctArgs(self):
       snippet = """
          package testargs;
@@ -117,6 +119,63 @@
       assert self.diag.diags[1].loc.row == 9
       assert self.diag.diags[2].loc.row == 10
       assert ir == None
+   def testEmpty(self):
+      snippet = """
+      package A
+      """
+      self.builder.build(snippet)
+   def testEmpty2(self):
+      snippet = ""
+      self.builder.build(snippet)
+   def testRedefine(self):
+      snippet = """
+      package test;
+      var int a;
+      var int b;
+      var int a;
+      """
+      self.diag.clear()
+      self.builder.build(snippet)
+      assert len(self.diag.diags) == 1
+      assert self.diag.diags[0].loc.row == 5
+   def testWhile(self):
+      snippet = """
+      package tstwhile;
+      var int a;
+      function void t()
+      {
+         var int i = 0;
+         while (i < 1054)
+         {
+            i = i + 3;
+            a = a + i
+         }
+      }
+      """
+      self.builder.build(snippet)
+   def testIf(self):
+      snippet = """
+      package tstIFF;
+      var int a;
+      function void t(int b)
+      {
+         a = 2;
+         if (a > b)
+         {
+            if (a > 1337)
+            {
+               b = 2;
+            }
+         }
+         else
+         {
+            b = 1;
+         }
+
+         return b;
+      }
+      """
+      self.builder.build(snippet)
 
 if __name__ == '__main__':
    do()