[pypy-svn] r27569 - in pypy/dist/pypy/rpython: lltypesystem lltypesystem/test memory/test
mwh at codespeak.net
mwh at codespeak.net
Mon May 22 01:55:26 CEST 2006
Author: mwh
Date: Mon May 22 01:55:23 2006
New Revision: 27569
Modified:
pypy/dist/pypy/rpython/lltypesystem/llmemory.py
pypy/dist/pypy/rpython/lltypesystem/lltype.py
pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py
Log:
so my previous work on fakeaddress.__eq__ wasn't quite right as I didn't really
understand how fakeaddess worked any more. fix + test.
this was the last thing preventing test_x_become() from working, yay!
Modified: pypy/dist/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/llmemory.py Mon May 22 01:55:23 2006
@@ -222,7 +222,8 @@
def __eq__(self, other):
if self.__class__ is not other.__class__:
return False
- return self.array is other.array and self.index == other.index
+ return self.array._same_obj(other.array) and \
+ self.index == other.index
def type(self):
return lltype.typeOf(self.array).TO.OF
@@ -237,7 +238,7 @@
def __eq__(self, other):
if self.__class__ is not other.__class__:
return False
- return self.array is other.array
+ return self.array._same_obj(other.array)
def type(self):
return lltype.Signed
@@ -252,7 +253,8 @@
def __eq__(self, other):
if self.__class__ is not other.__class__:
return False
- return self.struct is other.struct and self.fieldname == other.fieldname
+ return self.struct._same_obj(other.struct) and \
+ self.fieldname == other.fieldname
def type(self):
return getattr(lltype.typeOf(self.struct).TO, self.fieldname)
@@ -266,7 +268,7 @@
def __eq__(self, other):
if self.__class__ is not other.__class__:
return False
- return self.ob is other.ob
+ return self.ob._same_obj(other.ob)
def type(self):
return lltype.typeOf(self.ob)
Modified: pypy/dist/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/lltype.py Mon May 22 01:55:23 2006
@@ -851,6 +851,9 @@
def __ne__(self, other):
return not (self == other)
+ def _same_obj(self, other):
+ return self._obj == other._obj
+
def __hash__(self):
raise TypeError("pointer objects are not hashable")
Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py Mon May 22 01:55:23 2006
@@ -101,7 +101,17 @@
assert a1s1 != as2
assert a1s1 != at
assert as2 != at
-
+
+def test_more_fakeaddress_equality():
+ S = lltype.GcStruct('S', ('x', lltype.Signed))
+ T = lltype.GcStruct('T', ('s', S))
+
+ t = lltype.malloc(T)
+ t.s.x = 1
+ s = lltype.cast_pointer(lltype.Ptr(S), t)
+
+ a_t, a_s = map(cast_ptr_to_adr, [s, t])
+ assert a_t == a_s
def test_cast_adr_to_int():
from pypy.rpython.memory.test.test_llinterpsim import interpret
Modified: pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py Mon May 22 01:55:23 2006
@@ -507,7 +507,6 @@
GC_PARAMS = {'start_heap_size': 4096 }
def test_x_become(self):
- py.test.skip('fails less mysteriously')
S = lltype.GcStruct("S", ('x', lltype.Signed))
def f():
x = lltype.malloc(S)
More information about the Pypy-commit
mailing list