[pypy-svn] r13534 - pypy/dist/pypy/rpython/test

arigo at codespeak.net arigo at codespeak.net
Fri Jun 17 14:18:19 CEST 2005


Author: arigo
Date: Fri Jun 17 14:18:18 2005
New Revision: 13534

Modified:
   pypy/dist/pypy/rpython/test/test_llinterp.py
Log:
Exceptions are quite difficult to get right, because they are full of
implicitness.  I suggest re-reading the corresponding documentation
http://codespeak.net/pypy/index.cgi?doc/objspace.html#the-flow-model
and then trying to pass this test I check in :-)

Also note that it's quite possible that exceptions are not handled by a
handler, and should simply be re-raised.



Modified: pypy/dist/pypy/rpython/test/test_llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_llinterp.py	(original)
+++ pypy/dist/pypy/rpython/test/test_llinterp.py	Fri Jun 17 14:18:18 2005
@@ -74,6 +74,19 @@
     info = raises(LLException, interpret, call_raise, [43])
     assert find_exception(info.value) is ValueError
 
+def test_call_raise_twice():
+    py.test.skip("exceptions in progress")
+    res = interpret(call_raise_twice, [6, 7])
+    assert res == 13
+    info = raises(LLException, interpret, call_raise_twice, [6, 42])
+    assert find_exception(info.value) is IndexError
+    res = interpret(call_raise_twice, [6, 43])
+    assert res == 1006
+    info = raises(LLException, interpret, call_raise_twice, [42, 7])
+    assert find_exception(info.value) is IndexError
+    info = raises(LLException, interpret, call_raise_twice, [43, 7])
+    assert find_exception(info.value) is ValueError
+
 def test_call_raise_intercept():
     res = interpret(call_raise_intercept, [41])
     assert res == 41
@@ -156,6 +169,14 @@
 def call_raise(i):
     return raise_exception(i)
 
+def call_raise_twice(i, j):
+    x = raise_exception(i)
+    try:
+        y = raise_exception(j)
+    except ValueError:
+        y = 1000
+    return x + y
+
 def call_raise_intercept(i):
     try:
         return raise_exception(i)



More information about the Pypy-commit mailing list