[pypy-commit] lang-smalltalk default: added test for weak pointersobjects

lwassermann noreply at buildbot.pypy.org
Mon Apr 29 11:42:26 CEST 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: 
Changeset: r346:92f8216c6434
Date: 2013-04-29 11:42 +0200
http://bitbucket.org/pypy/lang-smalltalk/changeset/92f8216c6434/

Log:	added test for weak pointersobjects

diff --git a/spyvm/test/test_model.py b/spyvm/test/test_model.py
--- a/spyvm/test/test_model.py
+++ b/spyvm/test/test_model.py
@@ -314,3 +314,19 @@
         assert target.pixelbuffer[i] == 0xff000000
     for i in xrange(24, 32):
         assert target.pixelbuffer[i] == 0xffffffff
+
+
+def test_weak_pointers():
+    from spyvm.shadow import WEAK_POINTERS
+
+    w_cls = mockclass(space, 1)
+    s_cls = w_cls.as_class_get_shadow(space)
+    s_cls.instance_kind = WEAK_POINTERS
+
+    weak_object = s_cls.new()
+    referenced = model.W_SmallInteger(10)
+    weak_object.store(space, 0, referenced)
+
+    assert weak_object.fetch(space, 0) is referenced
+    del referenced
+    assert weak_object.fetch(space, 0) is space.w_nil


More information about the pypy-commit mailing list