changeset 86:154a31dbff5c

Added testcase and support for return.
author Janus Dam Nielsen <janus.nielsen@alexandra.dk>
date Fri, 29 May 2009 11:56:48 +0200
parents 84bf087135c2
children 015b29ec71fd
files pysmcl/range_analysis.py pysmcl/test/unit/test_rangeanalysis.py
diffstat 2 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pysmcl/range_analysis.py	Fri May 29 11:12:55 2009 +0200
+++ b/pysmcl/range_analysis.py	Fri May 29 11:56:48 2009 +0200
@@ -104,6 +104,9 @@
             def visit_While(self, node):
                 return env
 
+            def visit_Return(self, node):
+                return env
+
         r = Visitor(self.prime).visit(node)
         if debug:
             print "Result of combination", r
--- a/pysmcl/test/unit/test_rangeanalysis.py	Fri May 29 11:12:55 2009 +0200
+++ b/pysmcl/test/unit/test_rangeanalysis.py	Fri May 29 11:56:48 2009 +0200
@@ -266,6 +266,30 @@
         r = prog.body[0].body[-1].out_values["range"]
         self.assertEquals(r, {'y': (1, Bottom()), 'x': (Bottom(), 3), '_': (1, Bottom())})
 
+    def test_range_return(self):
+        p = 7
+        prog = parse(
+"""
+def f(x):
+    return x
+""")
+        range_analysis = RangeAnalysis(p)
+        range_analysis.apply(prog.body[0])
+        r = prog.body[0].body[-1].out_values["range"]
+        self.assertEquals(r, {'x': (0, p)})
+
+#     def test_range_result(self):
+#         p = 7
+#         prog = parse(
+# """
+# def f(x):
+#     return x
+# """)
+#         range_analysis = RangeAnalysis(p)
+#         range_analysis.apply(prog.body[0])
+#         r = prog.body[0].body[-1].out_values["range"]
+#         self.assertEquals(r, {'x': (0, Bottom())})
+
 #     def test_range_multiple_assign_and_tuples(self):
 #         p = 7
 #         prog = parse("def f():\n\tx,y = (1, 2)")