[pypy-svn] r28228 - pypy/dist/pypy/translator/stackless/test

mwh at codespeak.net mwh at codespeak.net
Sun Jun 4 11:43:34 CEST 2006


Author: mwh
Date: Sun Jun  4 11:43:32 2006
New Revision: 28228

Modified:
   pypy/dist/pypy/translator/stackless/test/test_resume_point.py
Log:
(mwh, pedronis)
Add another test, which passes, but broken versions of it flushed out a number
of bugs in the transform :)


Modified: pypy/dist/pypy/translator/stackless/test/test_resume_point.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/test/test_resume_point.py	(original)
+++ pypy/dist/pypy/translator/stackless/test/test_resume_point.py	Sun Jun  4 11:43:32 2006
@@ -179,3 +179,26 @@
     res = llinterp_stackless_function(example)
     assert res == 242
     
+def test_resume_and_raise_and_catch():
+    def g(x):
+        rstack.resume_point("rp0", x)
+        if x == 0:
+            raise KeyError
+        return x + 1
+    def f(x):
+        x = x - 1
+        try:
+            r = g(x)
+            rstack.resume_point("rp1", returns=r)
+        except KeyError:
+            r = 42
+        return r - 1
+    def example():
+        v1 = f(one()+one())
+        s1 = rstack.resume_state_create(None, "rp1")
+        s0 = rstack.resume_state_create(s1, "rp0", one()-1)
+        v2 = rstack.resume_state_invoke(int, s0)
+        return v1*100 + v2
+    res = llinterp_stackless_function(example)
+    assert res == 141
+    



More information about the Pypy-commit mailing list