[pypy-svn] r69498 - pypy/branch/faster-raise/pypy/module/pypyjit/test
arigo at codespeak.net
arigo at codespeak.net
Sat Nov 21 19:13:49 CET 2009
Author: arigo
Date: Sat Nov 21 19:13:47 2009
New Revision: 69498
Modified:
pypy/branch/faster-raise/pypy/module/pypyjit/test/test_pypy_c.py
Log:
Two tests about raising and catching exceptions in a loop.
Modified: pypy/branch/faster-raise/pypy/module/pypyjit/test/test_pypy_c.py
==============================================================================
--- pypy/branch/faster-raise/pypy/module/pypyjit/test/test_pypy_c.py (original)
+++ pypy/branch/faster-raise/pypy/module/pypyjit/test/test_pypy_c.py Sat Nov 21 19:13:47 2009
@@ -290,6 +290,49 @@
assert len(bytecode.get_opnames("call")) == 1 # the call to append
assert len(bytecode.get_opnames("guard")) == 1 # guard_no_exception after the call
+ def test_exception_inside_loop_1(self):
+ self.run_source('''
+ def main(n):
+ while n:
+ try:
+ raise ValueError
+ except ValueError:
+ pass
+ n -= 1
+ return n
+ ''',
+ ([30], 0))
+
+ bytecode, = self.get_by_bytecode("SETUP_EXCEPT")
+ #assert not bytecode.get_opnames("new") -- currently, we have
+ # new_with_vtable(pypy.interpreter.pyopcode.ExceptBlock)
+ bytecode, = self.get_by_bytecode("RAISE_VARARGS")
+ assert not bytecode.get_opnames("new")
+ bytecode, = self.get_by_bytecode("COMPARE_OP")
+ assert not bytecode.get_opnames()
+
+ def test_exception_inside_loop_2(self):
+ self.run_source('''
+ def g(n):
+ raise ValueError(n)
+ def f(n):
+ g(n)
+ def main(n):
+ while n:
+ try:
+ f(n)
+ except ValueError:
+ pass
+ n -= 1
+ return n
+ ''',
+ ([30], 0))
+
+ bytecode, = self.get_by_bytecode("RAISE_VARARGS")
+ assert not bytecode.get_opnames("new")
+ bytecode, = self.get_by_bytecode("COMPARE_OP")
+ assert len(bytecode.get_opnames()) <= 2 # oois, guard_true
+
class AppTestJIT(PyPyCJITTests):
def setup_class(cls):
More information about the Pypy-commit
mailing list