[pypy-svn] r67460 - in pypy/branch/weakdict/pypy: rlib rpython/memory/test
arigo at codespeak.net
arigo at codespeak.net
Thu Sep 3 19:40:02 CEST 2009
Author: arigo
Date: Thu Sep 3 19:40:01 2009
New Revision: 67460
Modified:
pypy/branch/weakdict/pypy/rlib/rweakrefimpl.py
pypy/branch/weakdict/pypy/rpython/memory/test/test_gc.py
Log:
Adding the test that I want to pass next.
Modified: pypy/branch/weakdict/pypy/rlib/rweakrefimpl.py
==============================================================================
--- pypy/branch/weakdict/pypy/rlib/rweakrefimpl.py (original)
+++ pypy/branch/weakdict/pypy/rlib/rweakrefimpl.py Thu Sep 3 19:40:01 2009
@@ -63,7 +63,7 @@
# ____________________________________________________________
-pristine_marker = lltype.malloc(rstr.STR, 0)
+pristine_marker = lltype.malloc(rstr.STR, 0, zero=True)
DICT_INITSIZE = 8
WEAKDICTENTRY = lltype.Struct("weakdictentry",
Modified: pypy/branch/weakdict/pypy/rpython/memory/test/test_gc.py
==============================================================================
--- pypy/branch/weakdict/pypy/rpython/memory/test/test_gc.py (original)
+++ pypy/branch/weakdict/pypy/rpython/memory/test/test_gc.py Thu Sep 3 19:40:01 2009
@@ -222,7 +222,7 @@
assert 160 <= res <= 165
def test_weakref(self):
- import weakref, gc
+ import weakref
class A(object):
pass
def g():
@@ -243,7 +243,7 @@
assert res
def test_weakref_to_object_with_finalizer(self):
- import weakref, gc
+ import weakref
class A(object):
count = 0
a = A()
@@ -262,6 +262,31 @@
res = self.interpret(f, [])
assert res
+ def test_weakvaluedict(self):
+ py.test.skip("in-progress")
+ from pypy.rlib.rweakref import RWeakValueDictionary
+ class X(object):
+ def __init__(self, n):
+ self.n = n
+ def g(d, x111):
+ x222 = X(222)
+ d.set("abc", x111)
+ d.set("def", x222)
+ return ((d.get("abc") is x111) * 100 +
+ (d.get("def") is x222) * 10 +
+ (d.get("foobar") is not None))
+ def f():
+ d = RWeakValueDictionary(X)
+ x111 = X(111)
+ res = g(d, x111)
+ llop.gc__collect(lltype.Void)
+ llop.gc__collect(lltype.Void)
+ res = res + ((d.get("abc") is x111) * 10000 +
+ (d.get("def") is not None) * 1000)
+ return res
+ res = self.interpret(f, [])
+ assert res == 10110
+
def test_id(self):
class A(object):
pass
More information about the Pypy-commit
mailing list