[pypy-svn] r68517 - pypy/branch/gc-hash/pypy/rpython/ootypesystem/test
arigo at codespeak.net
arigo at codespeak.net
Thu Oct 15 21:56:43 CEST 2009
Author: arigo
Date: Thu Oct 15 21:56:43 2009
New Revision: 68517
Modified:
pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_ooclean.py
pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oorecord.py
pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oortype.py
Log:
Fix the tests of ootype. Found a typo that, when fixed,
makes the existing test fail; leave it failing for now with
an "xxx" comment.
Modified: pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_ooclean.py
==============================================================================
--- pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_ooclean.py (original)
+++ pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_ooclean.py Thu Oct 15 21:56:43 2009
@@ -438,21 +438,22 @@
def test_hash_preservation():
from pypy.rlib.objectmodel import current_object_addr_as_int
+ from pypy.rlib.objectmodel import compute_identity_hash
class C:
pass
class D(C):
pass
def f1():
d2 = D()
- # xxx we assume that the identityhash doesn't change from
- # one line to the next
+ # xxx we assume that current_object_addr_as_int is defined as
+ # simply returning the identity hash
current_identityhash = current_object_addr_as_int(d2)
- instance_hash = hash(d2)
- return ((current_identityhash & sys.maxint) ==
- (instance_hash & sys.maxint))
+ instance_hash = compute_identity_hash(d2)
+ return current_identityhash == instance_hash
res = interpret(f1, [])
assert res is True
+ py.test.skip("hash is not preserved during an ootype translation")
c = C()
d = D()
def f2(): return hash(c)
Modified: pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oorecord.py
==============================================================================
--- pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oorecord.py (original)
+++ pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oorecord.py Thu Oct 15 21:56:43 2009
@@ -42,12 +42,12 @@
n2 = null(T)
assert n == n2
-def test_ooidentityhash():
+def test_identityhash():
T = Record({"a": Signed, "b": Signed})
t = new(T)
t.a = 1
t.b = 2
t2 = new(T)
- t.a = 1
- t.b = 2
- assert ooidentityhash(t) != ooidentityhash(t2)
+ t2.a = 1
+ t2.b = 2
+ assert identityhash(t) != identityhash(t2) # xxx???
Modified: pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oortype.py (original)
+++ pypy/branch/gc-hash/pypy/rpython/ootypesystem/test/test_oortype.py Thu Oct 15 21:56:43 2009
@@ -351,7 +351,7 @@
res = interpret(fn, [], type_system='ootype')
assert res == 42
-def test_ooidentityhash():
+def test_identityhash():
L = List(Signed)
def fn():
@@ -359,7 +359,7 @@
lst2 = new(L)
obj1 = cast_to_object(lst1)
obj2 = cast_to_object(lst2)
- return ooidentityhash(obj1) == ooidentityhash(obj2)
+ return identityhash(obj1) == identityhash(obj2)
res = interpret(fn, [], type_system='ootype')
assert not res
More information about the Pypy-commit
mailing list