diff python/testc3.py @ 167:0b5b2ee6b435

Added 2 unit tests
author Windel Bouwman
date Fri, 22 Mar 2013 17:40:13 +0100
parents da0087b82fbe
children 49f1ab80d040
line wrap: on
line diff
--- a/python/testc3.py	Fri Mar 22 16:15:31 2013 +0100
+++ b/python/testc3.py	Fri Mar 22 17:40:13 2013 +0100
@@ -1,5 +1,6 @@
 import c3
 import time, ppci, x86, ir
+import unittest
 
 testsrc = """package test;
 
@@ -7,7 +8,7 @@
 var double e;
 var int f;
 
-const int A = 1337.;
+const int A = 1337;
 
 function void test1() 
 {
@@ -34,7 +35,7 @@
 {
    if (a > 0)
    {
-      a = 2 + t2(a - 1);
+      a = 2 + t2(a - 1, 1.0);
    }
 
    return a + b;
@@ -77,5 +78,43 @@
    diag = ppci.DiagnosticsManager()
    c3compile(testsrc, diag)
 
-do()
+class testA(unittest.TestCase):
+   def setUp(self):
+      self.diag = ppci.DiagnosticsManager()
+      self.builder = c3.Builder(self.diag)
+   def testFunctArgs(self):
+      snippet = """
+         package testargs;
+         function void t2(int a, double b)
+         {
+            t2(2, 2);
+            t2(2);
+            t2(1, 1.2);
+         }
+      """
+      self.diag.clear()
+      ir = self.builder.build(snippet)
+      print(self.diag.diags)
 
+   def testExpressions(self):
+      snippet = """
+         package test;
+         function void t(int a, double b)
+         {
+            var int a2;
+            var bool c;
+
+            a2 = b * a;
+            c = a;
+            c = b > 1;
+         }
+      """
+      self.diag.clear()
+      ir = self.builder.build(snippet)
+      print(self.diag.diags)
+
+if __name__ == '__main__':
+   do()
+   unittest.main()
+
+