[pypy-svn] r47597 - in pypy/dist/pypy/rpython/lltypesystem: . test
arigo at codespeak.net
arigo at codespeak.net
Fri Oct 19 17:30:35 CEST 2007
Author: arigo
Date: Fri Oct 19 17:30:35 2007
New Revision: 47597
Modified:
pypy/dist/pypy/rpython/lltypesystem/llmemory.py
pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
Log:
We need support for 'NULL-NULL'.
Modified: pypy/dist/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/llmemory.py Fri Oct 19 17:30:35 2007
@@ -329,6 +329,11 @@
def __sub__(self, other):
if isinstance(other, AddressOffset):
return self + (-other)
+ if isinstance(other, fakeaddress):
+ if self == other:
+ return 0
+ else:
+ raise TypeError("cannot subtract fakeaddresses in general")
if other == 0:
return self
return NotImplemented
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 Fri Oct 19 17:30:35 2007
@@ -191,6 +191,13 @@
adr2 += ItemOffset(lltype.Char, -1)
assert adr1 == adr2
+def test_adr_sub():
+ # only (a - a) is supported
+ assert NULL - NULL == 0
+ A = lltype.GcArray(lltype.Char)
+ a = raw_malloc(sizeof(A, 5))
+ assert a - a == 0
+
def test_cast_subarray_pointer():
for a in [lltype.malloc(lltype.GcArray(lltype.Signed), 5),
lltype.malloc(lltype.FixedSizeArray(lltype.Signed, 5),
More information about the Pypy-commit
mailing list