Author: Armin Rigo <[email protected]>
Branch: rpython-hash
Changeset: r89819:9f2a9fe34a09
Date: 2017-01-28 13:09 +0100
http://bitbucket.org/pypy/pypy/changeset/9f2a9fe34a09/
Log: test fixes or removals
diff --git a/rpython/annotator/test/test_annrpython.py
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -3704,25 +3704,6 @@
s = a.build_types(f, [int])
assert s.const == 0
- def test_hash_sideeffect(self):
- class X:
- pass
- x1 = X()
- x2 = X()
- x3 = X()
- d = {(2, x1): 5, (3, x2): 7}
- def f(n, m):
- if m == 1: x = x1
- elif m == 2: x = x2
- else: x = x3
- return d[n, x]
- a = self.RPythonAnnotator()
- s = a.build_types(f, [int, int])
- assert s.knowntype == int
- assert hasattr(x1, '__precomputed_identity_hash')
- assert hasattr(x2, '__precomputed_identity_hash')
- assert not hasattr(x3, '__precomputed_identity_hash')
-
def test_contains_of_empty_dict(self):
class A(object):
def meth(self):
diff --git a/rpython/rlib/test/test_objectmodel.py
b/rpython/rlib/test/test_objectmodel.py
--- a/rpython/rlib/test/test_objectmodel.py
+++ b/rpython/rlib/test/test_objectmodel.py
@@ -166,7 +166,6 @@
foo = Foo()
h = compute_hash(foo)
assert h == object.__hash__(foo)
- assert h == getattr(foo, '__precomputed_identity_hash')
assert compute_hash(None) == 0
def test_compute_hash_float():
@@ -182,7 +181,6 @@
foo = Foo()
h = compute_identity_hash(foo)
assert h == object.__hash__(foo)
- assert h == getattr(foo, '__precomputed_identity_hash')
def test_compute_unique_id():
from rpython.rlib.rarithmetic import intmask
@@ -410,36 +408,6 @@
res = self.interpret(f, [])
assert res == 1
- def test_compute_hash_across_translation(self):
- class Foo(object):
- pass
- q = Foo()
-
- def f(i):
- assert compute_hash(None) == 0
- assert compute_hash(i) == h_42
- assert compute_hash(i + 1.0) == h_43_dot_0
- assert compute_hash((i + 3) / 6.0) == h_7_dot_5
- assert compute_hash("Hello" + str(i)) == h_Hello42
- if i == 42:
- p = None
- else:
- p = Foo()
- assert compute_hash(p) == h_None
- assert compute_hash(("world", None, i, 7.5)) == h_tuple
- assert compute_hash(q) == h_q
- return i * 2
- h_42 = compute_hash(42)
- h_43_dot_0 = compute_hash(43.0)
- h_7_dot_5 = compute_hash(7.5)
- h_Hello42 = compute_hash("Hello42")
- h_None = compute_hash(None)
- h_tuple = compute_hash(("world", None, 42, 7.5))
- h_q = compute_hash(q)
-
- res = self.interpret(f, [42])
- assert res == 84
-
def test_fetch_translated_config(self):
assert fetch_translated_config() is None
def f():
diff --git a/rpython/rtyper/lltypesystem/test/test_lltype.py
b/rpython/rtyper/lltypesystem/test/test_lltype.py
--- a/rpython/rtyper/lltypesystem/test/test_lltype.py
+++ b/rpython/rtyper/lltypesystem/test/test_lltype.py
@@ -749,22 +749,10 @@
assert hash3 == identityhash(s3)
assert hash3 == identityhash(s3.super)
assert hash3 == identityhash(s3.super.super)
- py.test.raises(ValueError, init_identity_hash, s3, hash3^1)
- py.test.raises(ValueError, init_identity_hash, s3.super, hash3^4)
- py.test.raises(ValueError, init_identity_hash, s3.super.super, hash3^9)
-
- s3 = malloc(S3)
- init_identity_hash(s3.super, -123)
- assert -123 == identityhash(s3)
- assert -123 == identityhash(s3.super)
- assert -123 == identityhash(s3.super.super)
- py.test.raises(ValueError, init_identity_hash, s3, 4313)
- py.test.raises(ValueError, init_identity_hash, s3.super, 0)
- py.test.raises(ValueError, init_identity_hash, s3.super.super, -124)
from rpython.rtyper.lltypesystem import llmemory
p3 = cast_opaque_ptr(llmemory.GCREF, s3)
- assert -123 == identityhash(p3)
+ assert hash3 == identityhash(p3)
A = GcArray(Signed)
a = malloc(A, 3)
diff --git a/rpython/rtyper/test/test_rclass.py
b/rpython/rtyper/test/test_rclass.py
--- a/rpython/rtyper/test/test_rclass.py
+++ b/rpython/rtyper/test/test_rclass.py
@@ -459,8 +459,7 @@
res = self.interpret(f, [3])
assert ''.join(res.chars) == 'CCls'
- def test_hash_preservation(self):
- from rpython.rlib.objectmodel import current_object_addr_as_int
+ def test_compute_identity_hash(self):
from rpython.rlib.objectmodel import compute_identity_hash
class C:
pass
@@ -468,27 +467,15 @@
pass
c = C()
d = D()
- h_c = compute_identity_hash(c)
- h_d = compute_identity_hash(d)
#
def f():
d2 = D()
return (compute_identity_hash(d2),
- current_object_addr_as_int(d2),
compute_identity_hash(c),
compute_identity_hash(d))
- res = self.interpret(f, [])
- # xxx the following test is too precise, checking the exact
- # implementation. On Python 2.7 it doesn't work anyway, because
- # object.__hash__(x) is different from id(x). The test is disabled
- # for now, and nobody should rely on compute_identity_hash() returning
- # a value that is (or was) the current_object_addr_as_int().
- # --- disabled: assert res.item0 == res.item1
- # the following property is essential on top of the lltypesystem
- # otherwise prebuilt dictionaries are broken.
- assert res.item2 == h_c
- assert res.item3 == h_d
+ self.interpret(f, [])
+ # check does not crash
def test_circular_hash_initialization(self):
class B:
diff --git a/rpython/translator/c/test/test_lltyped.py
b/rpython/translator/c/test/test_lltyped.py
--- a/rpython/translator/c/test/test_lltyped.py
+++ b/rpython/translator/c/test/test_lltyped.py
@@ -332,6 +332,7 @@
assert res == 3050
def test_gcarray_nolength(self):
+ py.test.skip("GcArrays should never be 'nolength'")
A = GcArray(Signed, hints={'nolength': True})
a1 = malloc(A, 3, immortal=True)
a1[0] = 30
diff --git a/rpython/translator/tool/test/test_staticsizereport.py
b/rpython/translator/tool/test/test_staticsizereport.py
--- a/rpython/translator/tool/test/test_staticsizereport.py
+++ b/rpython/translator/tool/test/test_staticsizereport.py
@@ -59,13 +59,14 @@
assert guess_size(func.builder.db, dictvalnode, set()) > 100
assert guess_size(func.builder.db, dictvalnode2, set()) == (
(4 * S + 2 * P) + # struct dicttable
- (S + 16) + # indexes, length 16
+ # (S + 16) + # indexes, length 16, but is absent here
(S + S + S)) # entries, length 1
r_set = set()
dictnode_size = guess_size(db, test_dictnode, r_set)
assert dictnode_size == (
(4 * S + 2 * P) + # struct dicttable
- (S + 2 * 8192) + # indexes, length 8192, rffi.USHORT
+ # (S + 2 * 8192) + # indexes, length 8192, rffi.USHORT,
+ # but is absent here during translation
(S + (S + S) * 3840) + # entries, length 3840
(S + S + 6) * 3840) # 3840 strings with 5 chars each (+1 final)
assert guess_size(func.builder.db, fixarrayvalnode, set()) == 100 *
rffi.sizeof(lltype.Signed) + 1 * rffi.sizeof(lltype.Signed)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit