Author: Armin Rigo <[email protected]>
Branch: gc-del-2
Changeset: r66071:3ca3e70a4f17
Date: 2013-08-11 17:31 +0200
http://bitbucket.org/pypy/pypy/changeset/3ca3e70a4f17/

Log:    A test that would pass if it did major collects instead of minor
        collects. The goal is to pass this test now with minor collects.

diff --git a/rpython/memory/test/test_minimark_gc.py 
b/rpython/memory/test/test_minimark_gc.py
--- a/rpython/memory/test/test_minimark_gc.py
+++ b/rpython/memory/test/test_minimark_gc.py
@@ -1,3 +1,5 @@
+from rpython.rlib import rgc
+from rpython.rlib.debug import ll_assert
 from rpython.rlib.rarithmetic import LONG_BIT
 
 from rpython.memory.test import test_semispace_gc
@@ -9,3 +11,37 @@
     GC_CAN_SHRINK_BIG_ARRAY = False
     GC_CAN_MALLOC_NONMOVABLE = True
     BUT_HOW_BIG_IS_A_BIG_STRING = 11*WORD
+
+    def test_finalizer_chain_minor_collect(self):
+        class A:
+            def __init__(self, n, next):
+                self.n = n
+                self.next = next
+            def __del__(self):
+                state.freed.append(self.n)
+        class State:
+            pass
+        state = State()
+
+        def make(n):
+            a = None
+            i = 0
+            while i < n:
+                a = A(i, a)
+                i += 1
+
+        def f(n):
+            state.freed = []
+            make(n)
+            ll_assert(len(state.freed) == 0, "should be empty before collect")
+            i = 0
+            while i < n:
+                rgc.collect(0)    # minor collection only
+                i += 1
+                ll_assert(len(state.freed) == i, "every collect should grow 1")
+            i = 0
+            while i < n:
+                ll_assert(state.freed[i] == n - i - 1, "bogus ordering")
+                i += 1
+
+        self.interpret(f, [4])
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to