[pypy-svn] r15765 - in pypy/dist/pypy/rpython/memory: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Aug 8 14:17:45 CEST 2005


Author: cfbolz
Date: Mon Aug  8 14:17:44 2005
New Revision: 15765

Modified:
   pypy/dist/pypy/rpython/memory/lltypesimulation.py
   pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py
Log:
arggh!! did not define __ne__ for simulatorptr which leads to annoying bugs.


Modified: pypy/dist/pypy/rpython/memory/lltypesimulation.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lltypesimulation.py	(original)
+++ pypy/dist/pypy/rpython/memory/lltypesimulation.py	Mon Aug  8 14:17:44 2005
@@ -213,6 +213,9 @@
     def __nonzero__(self):
         return self._address != lladdress.NULL
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     def __eq__(self, other):
         if not isinstance(other, simulatorptr):
             raise TypeError("comparing pointer with %r object" % (

Modified: pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py	Mon Aug  8 14:17:44 2005
@@ -305,3 +305,12 @@
     F = lltype.FuncType((lltype.Signed, lltype.Signed), lltype.Signed)
     funcptr = functionptr(F, "add", _callable=f)
     assert funcptr(1, 2) == 3
+
+def test_pointer_equality():
+    S0 = lltype.GcStruct("s0",
+                         ('a', lltype.Struct("s1", ('a', lltype.Signed))),
+                         ('b', lltype.Signed))
+    s0 = malloc(S0)
+    assert s0.a == s0.a
+    assert not s0.a != s0.a
+    



More information about the Pypy-commit mailing list