[pypy-svn] r26386 - in pypy/dist/pypy/translator/stackless: . test
mwh at codespeak.net
mwh at codespeak.net
Wed Apr 26 22:48:17 CEST 2006
Author: mwh
Date: Wed Apr 26 22:48:16 2006
New Revision: 26386
Modified:
pypy/dist/pypy/translator/stackless/code.py
pypy/dist/pypy/translator/stackless/test/test_depth.py
Log:
two more stackless tests ported from c/test/test_stackless and one consequent
bugfix to slp_main_loop.
Modified: pypy/dist/pypy/translator/stackless/code.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/code.py (original)
+++ pypy/dist/pypy/translator/stackless/code.py Wed Apr 26 22:48:16 2006
@@ -118,7 +118,8 @@
try:
call_function(fn, signature)
except UnwindException, u: #XXX annotation support needed
- nextframe = u.frame_top
+ u.frame_bottom.f_back = nextframe
+ nextframe = u.frame_top
except Exception, e:
global_state.exception = e
else:
Modified: pypy/dist/pypy/translator/stackless/test/test_depth.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/test/test_depth.py (original)
+++ pypy/dist/pypy/translator/stackless/test/test_depth.py Wed Apr 26 22:48:16 2006
@@ -48,3 +48,43 @@
res = run_stackless_function(fn)
assert res.strip() == "10"
+
+def test_manytimes():
+ def f(n):
+ if n > 0:
+ res = f(n-1)
+ else:
+ res = code.stack_frames_depth(), 1
+ return res
+
+ def fn(ignored):
+ count0, _ = f(0)
+ count10, _ = f(100)
+ return count10 - count0
+
+ res = llinterp_stackless_function(fn)
+ assert res == 100
+
+ res = run_stackless_function(fn)
+ assert res.strip() == "100"
+
+def test_arguments():
+ def f(n, d, t):
+ if n > 0:
+ res = f(n-1, d, t)
+ else:
+ res = code.stack_frames_depth(), d, t
+ return res
+
+ def fn(ignored):
+ count0, d, t = f(0, 5.5, (1, 2))
+ count10, d, t = f(10, 5.5, (1, 2))
+ return count10 - count0 + int(d)
+
+ res = llinterp_stackless_function(fn)
+ assert res == 15
+
+ res = run_stackless_function(fn)
+ assert res.strip() == "15"
+
+
More information about the Pypy-commit
mailing list