changeset 269:969224be66ad

test: Updated test_secret_ifs Seems to work now
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 10 Mar 2010 15:10:53 +0100
parents 8d7e2d7848f1
children 1c640e470a51
files pysmcl/test/unit/test_secret_ifs.py
diffstat 1 files changed, 15 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/test/unit/test_secret_ifs.py	Wed Mar 10 15:10:19 2010 +0100
+++ b/pysmcl/test/unit/test_secret_ifs.py	Wed Mar 10 15:10:53 2010 +0100
@@ -6,23 +6,26 @@
 from pysmcl.secret_ifs import TransformIfs
 from pysmcl.secret_annotator import secret_analysis
 
+from pysmcl.test.util import write_delta
 
 class SecretIfTest(unittest.TestCase):
 
     def test_if1(self):
         program = """
-def f(x):
+def f():
+    x = input("Give a bit", 3, 0, 1)
     if(x):
         a = 1
     else:
         a = 2
 """
         expected = """\
-def f(x):
+def f():
+    x = input("Give a bit", 3, 0, 1)
     a_then0 = 1
     a_else0 = 2
     cond0 = x
-    a = a_then0 + (a_else0 - a_then0) * cond0
+    a = a_else0 + (a_then0 - a_else0) * cond0
 """
         self.make_test(program, {"x" : (0, 1)}, expected)
 
@@ -45,17 +48,21 @@
 
     def test_if2(self):
         expected = """\
-def f(x, y):
+def f():
+    x = input("Give a bit", 3, 0, 1)
+    y = input("Give a bit2", 3, 0, 1)
     a_then0 = 1
     a_else0 = 2
     cond0 = y
-    a_then1 = a_then0 + (a_else0 - a_then0) * cond0
+    a_then1 = a_else0 + (a_then0 - a_else0) * cond0
     a_else1 = 3
     cond1 = x
-    a = a_then1 + (a_else1 - a_then1) * cond1
+    a = a_else1 + (a_then1 - a_else1) * cond1
 """
         program = """\
-def f(x, y):
+def f():
+    x = input("Give a bit", 3, 0, 1)
+    y = input("Give a bit2", 3, 0, 1)
     if(x):
         if(y):
             a = 1
@@ -74,6 +81,7 @@
         RangeAnalysis().apply(parsed.body[0], args)
         prog = trans.visit(parsed)
         result = pprint_string(parsed)
+        write_delta(expected, result)
         self.assertEquals(expected, result)
 
 if __name__ == '__main__':