[pypy-svn] r10249 - in pypy/dist/pypy/translator: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Apr 2 17:02:22 CEST 2005
Author: arigo
Date: Sat Apr 2 17:02:22 2005
New Revision: 10249
Modified:
pypy/dist/pypy/translator/test/test_ctrans.py
pypy/dist/pypy/translator/unsimplify.py
Log:
Typo in unsimplify.py. Added a test that exercices this code,
and also crashes if remove_direct_loops() is not called at all on the graph.
Modified: pypy/dist/pypy/translator/test/test_ctrans.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_ctrans.py (original)
+++ pypy/dist/pypy/translator/test/test_ctrans.py Sat Apr 2 17:02:22 2005
@@ -201,6 +201,19 @@
fn = self.build_cfunc(snippet.one_thing2)
assert fn() == 4
+ def test_direct_loop(self):
+ # check that remove_direct_loops() does its job correctly
+ def direct_loop(n, m):
+ while 1:
+ o = n; n = m; m = o
+ n -= 10
+ if n < 0:
+ return n
+ fn = self.build_cfunc(direct_loop)
+ assert fn(117, 114) == -6
+ assert fn(117, 124) == -3
+
+
class TestTypedTestCase:
def getcompiled(self, func):
Modified: pypy/dist/pypy/translator/unsimplify.py
==============================================================================
--- pypy/dist/pypy/translator/unsimplify.py (original)
+++ pypy/dist/pypy/translator/unsimplify.py Sat Apr 2 17:02:22 2005
@@ -1,6 +1,6 @@
from pypy.objspace.flow.model import *
-def copyvar(v):
+def copyvar(translator, v):
"""Make a copy of the Variable v, preserving annotations and type_cls."""
assert isinstance(v, Variable)
newvar = Variable(v)
@@ -20,7 +20,7 @@
def visit(link):
if isinstance(link, Link) and link.prevblock is link.target:
# insert an empty block with fresh variables.
- intermediate = [copyvar(a) for a in link.args]
+ intermediate = [copyvar(translator, a) for a in link.args]
b = Block(intermediate)
b.closeblock(Link(intermediate, link.target))
link.target = b
More information about the Pypy-commit
mailing list