[pypy-svn] pypy enable-opts: Improve the test to make sure that external() actually reads

arigo commits-noreply at bitbucket.org
Sat Mar 12 20:12:04 CET 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: enable-opts
Changeset: r42530:07f7e085ed08
Date: 2011-03-12 14:11 -0500
http://bitbucket.org/pypy/pypy/changeset/07f7e085ed08/

Log:	Improve the test to make sure that external() actually reads
	'_frame', to prevent optimizations from delaying the allocation of
	X(). It used to work fine because this particular test used to run
	without optimizations.

diff --git a/pypy/jit/metainterp/test/test_virtualref.py b/pypy/jit/metainterp/test/test_virtualref.py
--- a/pypy/jit/metainterp/test/test_virtualref.py
+++ b/pypy/jit/metainterp/test/test_virtualref.py
@@ -39,15 +39,19 @@
         if not isinstance(self, TestLLtype):
             py.test.skip("purely frontend test")
         #
+        class FooBarError(Exception):
+            pass
         class X:
             def __init__(self, n):
                 self.n = n
         class ExCtx:
-            pass
+            _frame = None
         exctx = ExCtx()
         #
         @dont_look_inside
         def external(n):
+            if exctx._frame is None:
+                raise FooBarError
             if n > 100:
                 return exctx.topframeref().n
             return n


More information about the Pypy-commit mailing list