[pypy-svn] r47296 - in pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem: . test

arigo at codespeak.net arigo at codespeak.net
Mon Oct 8 18:34:34 CEST 2007


Author: arigo
Date: Mon Oct  8 18:34:34 2007
New Revision: 47296

Modified:
   pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llarena.py
   pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llmemory.py
   pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/test/test_llarena.py
Log:
Fix fakearenaaddress comparison.  Write paranoid test.


Modified: pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llarena.py	(original)
+++ pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llarena.py	Mon Oct  8 18:34:34 2007
@@ -139,14 +139,15 @@
             if other.ptr and other.ptr._obj in Arena.object_arena_location:
                 arena, offset = Arena.object_arena_location[other.ptr._obj]
             else:
-                return 1   # arbitrarily, 'self' > any address not in any arena
+                # arbitrarily, 'self' > any address not in any arena
+                return False
         else:
             raise TypeError("comparing a %s and a %s" % (
                 self.__class__.__name__, other.__class__.__name__))
         if self.arena is arena:
-            return cmp(self.offset, offset)
+            return self.offset < offset
         else:
-            return cmp(self.arena._getid(), arena._getid())
+            return self.arena._getid() < arena._getid()
 
     def _cast_to_int(self):
         return self.arena._getid() + self.offset

Modified: pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/llmemory.py	Mon Oct  8 18:34:34 2007
@@ -25,7 +25,7 @@
     def _raw_malloc(self, rest, zero):
         raise NotImplementedError("_raw_malloc(%r, %r)" % (self, rest))
 
-    def raw_memcopy(self, srcadr, dstsrc):
+    def raw_memcopy(self, srcadr, dstadr):
         raise NotImplementedError("raw_memcopy(%r)" % (self,))
 
 

Modified: pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/test/test_llarena.py
==============================================================================
--- pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/test/test_llarena.py	(original)
+++ pypy/branch/kill-keepalives-again/pypy/rpython/lltypesystem/test/test_llarena.py	Mon Oct  8 18:34:34 2007
@@ -60,3 +60,47 @@
     assert cast_adr_to_ptr((a + ssize + 1) - 1, S2PTR).y == 'X'
 
     assert (a + 4) - (a + 1) == 3
+
+
+def lt(x, y):
+    if x < y:
+        assert     (x < y)  and     (y > x)
+        assert     (x <= y) and     (y >= x)
+        assert not (x == y) and not (y == x)
+        assert     (x != y) and     (y != x)
+        assert not (x > y)  and not (y < x)
+        assert not (x >= y) and not (y <= x)
+        return True
+    else:
+        assert (x >= y) and (y <= x)
+        assert (x == y) == (not (x != y)) == (y == x) == (not (y != x))
+        assert (x > y) == (not (x == y)) == (y < x)
+        return False
+
+def eq(x, y):
+    if x == y:
+        assert not (x != y) and not (y != x)
+        assert not (x < y)  and not (y > x)
+        assert not (x > y)  and not (y < x)
+        assert     (x <= y) and     (y >= x)
+        assert     (x >= y) and     (y <= x)
+        return True
+    else:
+        assert (x != y) and (y != x)
+        assert ((x < y) == (x <= y) == (not (x > y)) == (not (x >= y)) ==
+                (y > x) == (y >= x) == (not (y < x)) == (not (y <= x)))
+        return False
+
+
+def test_address_order():
+    a = arena_malloc(20, False)
+    assert eq(a, a)
+    assert lt(a, a+1)
+    assert lt(a+5, a+20)
+
+    b = arena_malloc(20, False)
+    if a > b:
+        a, b = a, b
+    assert lt(a, b)
+    assert lt(a+19, b)
+    assert lt(a, b+19)



More information about the Pypy-commit mailing list