[pypy-svn] r52019 - in pypy/branch/jit-refactoring/pypy/jit: rainbow/test timeshifter timeshifter/test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Mar 1 21:31:53 CET 2008


Author: cfbolz
Date: Sat Mar  1 21:31:53 2008
New Revision: 52019

Added:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_exception.py
      - copied, changed from r51886, pypy/branch/jit-refactoring/pypy/jit/timeshifter/test/test_exception.py
Removed:
   pypy/branch/jit-refactoring/pypy/jit/timeshifter/test/test_exception.py
Modified:
   pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
   pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py
Log:
port over exception tests, most of which pass


Modified: pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/rainbow/test/test_interpreter.py	Sat Mar  1 21:31:53 2008
@@ -10,7 +10,7 @@
 from pypy.jit.rainbow.test.test_serializegraph import AbstractSerializationTest
 from pypy.jit.timeshifter import rtimeshift, rvalue
 from pypy.rpython.lltypesystem import lltype, rstr
-from pypy.rpython.llinterp import LLInterpreter
+from pypy.rpython.llinterp import LLInterpreter, LLException
 from pypy.rpython.module.support import LLSupport
 from pypy.annotation import model as annmodel
 from pypy.objspace.flow.model import summary, Variable
@@ -144,7 +144,7 @@
 
     def serialize(self, func, values, policy=None,
                   inline=None, backendoptimize=False,
-                  portal=None):
+                  portal=None, **kwds):
         key = func, backendoptimize
         try:
             cache, argtypes = self._cache[key]
@@ -205,9 +205,26 @@
             graph.show()
         llinterp = LLInterpreter(
             self.rtyper, exc_data_ptr=writer.exceptiondesc.exc_data_ptr)
-        res = llinterp.eval_graph(graph, residualargs)
+
+        if 'check_raises' not in kwds:
+            res = llinterp.eval_graph(graph, residualargs)
+        else:
+            try:
+                llinterp.eval_graph(graph, residualargs)
+            except LLException, e:
+                exc = kwds['check_raises']
+                assert llinterp.find_exception(e) is exc, (
+                    "wrong exception type")
+            else:
+                raise AssertionError("DID NOT RAISE")
+            return True
         return res
 
+    def interpret_raises(self, ExcCls, ll_function, values, opt_consts=[],
+                         *args, **kwds):
+        kwds['check_raises'] = ExcCls
+        return self.interpret(ll_function, values, opt_consts, *args, **kwds)
+
     def get_residual_graph(self):
         return self.residual_graph
 

Modified: pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py
==============================================================================
--- pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py	(original)
+++ pypy/branch/jit-refactoring/pypy/jit/timeshifter/oop.py	Sat Mar  1 21:31:53 2008
@@ -158,7 +158,7 @@
             ll_evalue = get_ll_instance_for_exccls(ExcCls)
             jitstate.residual_ll_exception(ll_evalue)
         else:
-            residual_exception_nontranslated(jitstate, ExcClass(), self.rtyper)
+            residual_exception_nontranslated(jitstate, ExcCls(), self.rtyper)
         return self.errorbox
     residual_exception._annspecialcase_ = 'specialize:arg(2)'
 



More information about the Pypy-commit mailing list