changeset 181:9b4cd7d86f1b

test_secret_if: updated to allow ranges to be checked.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 16 Dec 2009 12:53:09 +0100
parents 862f30985ed5
children 4011495cad44
files pysmcl/test/unit/test_secret_ifs.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/test/unit/test_secret_ifs.py	Wed Dec 16 12:51:47 2009 +0100
+++ b/pysmcl/test/unit/test_secret_ifs.py	Wed Dec 16 12:53:09 2009 +0100
@@ -1,4 +1,6 @@
 import unittest
+import pysmcl.setup
+from pysmcl.range_analysis import RangeAnalysis
 from pysmcl.ast_wrapper import parse
 from pysmcl.pretty_print import pprint_string
 from pysmcl.secret_ifs import TransformIfs
@@ -22,7 +24,7 @@
     cond0 = x
     a = a_then0 + (a_else0 - a_then0) * cond0
 """
-        self.make_test(program, expected)
+        self.make_test(program, {"x" : (0, 1)}, expected)
 
     def test_if3(self):
         program = """\
@@ -39,7 +41,7 @@
     else:
         a = 2
 """
-        self.make_test(program, expected)
+        self.make_test(program, {}, expected)
 
     def test_if2(self):
         expected = """\
@@ -62,13 +64,14 @@
     else:
         a = 3
 """
-        self.make_test(program, expected)
+        self.make_test(program, {"x" : (0, 1), "y" : (0, 1)}, expected)
 
 
-    def make_test(self, program, expected):
+    def make_test(self, program, args, expected):
         parsed = parse(program)
         trans = TransformIfs()
         secret_analysis(parsed.body[0])
+        RangeAnalysis(pysmcl.setup.Zp.modulus).apply(parsed.body[0], args)
         prog = trans.visit(parsed)
         result = pprint_string(parsed)
         self.assertEquals(expected, result)