Author: Remi Meier
Branch: c7-weakref
Changeset: r980:f10f5aecb970
Date: 2014-03-12 16:27 +0100
http://bitbucket.org/pypy/stmgc/changeset/f10f5aecb970/
Log: fix
diff --git a/c7/test/common.py b/c7/test/common.py
--- a/c7/test/common.py
+++ b/c7/test/common.py
@@ -14,7 +14,7 @@
os.path.join(parent_dir, "stmgc.c")] + [
os.path.join(parent_dir, 'stm', _n)
for _n in os.listdir(os.path.join(parent_dir, 'stm'))
- if _n.endswith('.h') or _n.endswith('.c')]
+ if (_n.endswith('.h') or _n.endswith('.c')) and not
_n.startswith('.')]
_pycache_ = os.path.join(parent_dir, 'test', '__pycache__')
if os.path.exists(_pycache_):
diff --git a/c7/test/support.py b/c7/test/support.py
--- a/c7/test/support.py
+++ b/c7/test/support.py
@@ -287,7 +287,7 @@
return o
def stm_allocate_weakref(point_to_obj):
- o = lib.stm_allocate(HDR + WORD)
+ o = lib.stm_allocate_weakref(HDR + WORD)
tid = 421420
lib._set_type_id(o, tid)
lib._set_weakref(o, point_to_obj)
diff --git a/c7/test/test_weakref.py b/c7/test/test_weakref.py
--- a/c7/test/test_weakref.py
+++ b/c7/test/test_weakref.py
@@ -10,16 +10,36 @@
self.start_transaction()
self.push_root_no_gc()
- lp1 = stm_allocate_weakref(ffi.NULL) # no collection here
+ lp2 = stm_allocate(48)
+ lp1 = stm_allocate_weakref(lp2) # no collection here
self.pop_root()
- assert stm_get_weakref(lp1) == ffi.NULL
+ assert stm_get_weakref(lp1) == lp2
self.push_root(lp1)
stm_minor_collect()
lp1 = self.pop_root()
+ # lp2 died
+ assert stm_get_weakref(lp1) == ffi.NULL
- assert stm_get_weakref(lp1) == ffi.NULL
+ def test_still_simple(self):
+ lib._stm_set_nursery_free_count(2048)
+ self.start_transaction()
+
+ self.push_root_no_gc()
+ lp2 = stm_allocate(48)
+ lp1 = stm_allocate_weakref(lp2) # no collection here
+ self.pop_root()
+
+ assert stm_get_weakref(lp1) == lp2
+
+ self.push_root(lp1)
+ self.push_root(lp2)
+ stm_minor_collect()
+ lp2 = self.pop_root()
+ lp1 = self.pop_root()
+ # lp2 survived
+ assert stm_get_weakref(lp1) == lp2
# def test_weakref_invalidate(self):
# p2 = nalloc(HDR)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit