[pypy-commit] pypy gc-del: Fix test

arigo noreply at buildbot.pypy.org
Mon Mar 25 23:25:24 CET 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: gc-del
Changeset: r62759:1fef469bc625
Date: 2013-03-25 21:49 +0100
http://bitbucket.org/pypy/pypy/changeset/1fef469bc625/

Log:	Fix test

diff --git a/rpython/translator/backendopt/destructor.py b/rpython/translator/backendopt/destructor.py
--- a/rpython/translator/backendopt/destructor.py
+++ b/rpython/translator/backendopt/destructor.py
@@ -3,7 +3,8 @@
 from rpython.rtyper.lltypesystem import lltype
 
 class DestructorError(Exception):
-    """The __del__() method contains unsupported operations"""
+    """The __del__() method contains unsupported operations.
+    (You may have to use the newer rgc.register_finalizer())"""
 
 class DestructorAnalyzer(graphanalyze.BoolGraphAnalyzer):
     """ Analyzer that checks if a destructor is lightweight enough for
diff --git a/rpython/translator/backendopt/test/test_finalizer.py b/rpython/translator/backendopt/test/test_destructor.py
rename from rpython/translator/backendopt/test/test_finalizer.py
rename to rpython/translator/backendopt/test/test_destructor.py
--- a/rpython/translator/backendopt/test/test_finalizer.py
+++ b/rpython/translator/backendopt/test/test_destructor.py
@@ -1,7 +1,7 @@
 
 import py
-from rpython.translator.backendopt.finalizer import FinalizerAnalyzer,\
-     FinalizerError
+from rpython.translator.backendopt.destructor import DestructorAnalyzer,\
+     DestructorError
 from rpython.translator.translator import TranslationContext, graphof
 from rpython.translator.backendopt.all import backend_optimizations
 from rpython.translator.unsimplify import varoftype
@@ -10,7 +10,7 @@
 from rpython.rlib import rgc
 
 
-class BaseFinalizerAnalyzerTests(object):
+class BaseDestructorAnalyzerTests(object):
     """ Below are typical destructors that we encounter in pypy
     """
 
@@ -26,9 +26,9 @@
             backend_optimizations(t)
         if option.view:
             t.view()
-        a = FinalizerAnalyzer(t)
+        a = DestructorAnalyzer(t)
         fgraph = graphof(t, func_to_analyze)
-        result = a.analyze_light_finalizer(fgraph)
+        result = a.analyze_direct_call(fgraph)
         return result
 
     def test_nothing(self):
@@ -47,7 +47,7 @@
                         ('z', Z))
     v1 = varoftype(lltype.Bool)
     v2 = varoftype(lltype.Signed)
-    f = FinalizerAnalyzer(None)
+    f = DestructorAnalyzer(None)
     r = f.analyze(SpaceOperation('cast_int_to_bool', [v2],
                                                        v1))
     assert not r
@@ -63,7 +63,7 @@
                                                           v4], None))
     
         
-class TestLLType(BaseFinalizerAnalyzerTests):
+class TestLLType(BaseDestructorAnalyzerTests):
     type_system = 'lltype'
 
     def test_malloc(self):
@@ -126,17 +126,6 @@
         r = self.analyze(f, [], A.__del__.im_func)
         assert r
 
-    def test_must_be_light_finalizer_decorator(self):
-        S = lltype.GcStruct('S')
 
-        @rgc.must_be_light_finalizer
-        def f():
-            lltype.malloc(S)
-        @rgc.must_be_light_finalizer
-        def g():
-            pass
-        self.analyze(g, []) # did not explode
-        py.test.raises(FinalizerError, self.analyze, f, [])
-
-class TestOOType(BaseFinalizerAnalyzerTests):
+class TestOOType(BaseDestructorAnalyzerTests):
     type_system = 'ootype'


More information about the pypy-commit mailing list