[pypy-svn] r64547 - in pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem: . test

antocuni at codespeak.net antocuni at codespeak.net
Tue Apr 21 19:38:58 CEST 2009


Author: antocuni
Date: Tue Apr 21 19:38:57 2009
New Revision: 64547

Modified:
   pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py
   pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py
Log:
make sure that ooidentityhash works on arrays


Modified: pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/ootype.py	Tue Apr 21 19:38:57 2009
@@ -1603,6 +1603,12 @@
         self._array[index] = item
     ll_setitem_fast.oopargcheck = lambda a, index, item: bool(a)
 
+    def _identityhash(self):
+        if self:
+            return intmask(id(self))
+        else:
+            return 0   # for all null arrays
+
 class _null_array(_null_mixin(_array), _array):
 
     def __init__(self, ARRAY):
@@ -1879,7 +1885,7 @@
 
 def ooidentityhash(inst):
     T = typeOf(inst)
-    assert T is Object or isinstance(T, (Instance, Record))
+    assert T is Object or isinstance(T, (Instance, Record, Array))
     return inst._identityhash()
 
 def oohash(inst):

Modified: pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py
==============================================================================
--- pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py	(original)
+++ pypy/branch/pyjitpl5-simplify/pypy/rpython/ootypesystem/test/test_ootype.py	Tue Apr 21 19:38:57 2009
@@ -637,3 +637,10 @@
     obj1 = cast_to_object(m)
     obj2 = cast_to_object(m)
     assert ooidentityhash(obj1) == ooidentityhash(obj2)
+
+def test_ooidentityhash_array():
+    A = Array(Signed)
+    a = oonewarray(A, 10)
+    b = oonewarray(A, 10)
+    assert ooidentityhash(a) != ooidentityhash(b)
+



More information about the Pypy-commit mailing list