[pypy-svn] r24868 - in pypy/branch/pypy-rdict-refactoring/rpython: lltypesystem test
arigo at codespeak.net
arigo at codespeak.net
Thu Mar 23 11:30:58 CET 2006
Author: arigo
Date: Thu Mar 23 11:30:47 2006
New Revision: 24868
Modified:
pypy/branch/pypy-rdict-refactoring/rpython/lltypesystem/lltype.py
pypy/branch/pypy-rdict-refactoring/rpython/test/test_rdict.py
Log:
Typo (thanks Ben Young). Quite hard to test because CPython
eats all exceptions in __eq__ called by the dict lookup
algorithm! Bad CPython!
Modified: pypy/branch/pypy-rdict-refactoring/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/pypy-rdict-refactoring/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/pypy-rdict-refactoring/rpython/lltypesystem/lltype.py Thu Mar 23 11:30:47 2006
@@ -1141,13 +1141,13 @@
return hash(self.obj)
def __eq__(self, other):
- if not isinstance(other, staticMethod):
+ if not isinstance(other, staticAdtMethod):
return NotImplemented
else:
return self.obj == other.obj
def __ne__(self, other):
- if not isinstance(other, staticMethod):
+ if not isinstance(other, staticAdtMethod):
return NotImplemented
else:
return self.obj != other.obj
Modified: pypy/branch/pypy-rdict-refactoring/rpython/test/test_rdict.py
==============================================================================
--- pypy/branch/pypy-rdict-refactoring/rpython/test/test_rdict.py (original)
+++ pypy/branch/pypy-rdict-refactoring/rpython/test/test_rdict.py Thu Mar 23 11:30:47 2006
@@ -561,6 +561,22 @@
assert hasattr(DICT.entries.TO.OF, 'f_everused') # all ints can be zero
assert hasattr(DICT.entries.TO.OF, 'f_valid') # no dummy available
+def test_opt_multiple_identical_dicts():
+ def f(n):
+ s = "x" * n
+ d1 = {s: 12}
+ d2 = {s: 24}
+ d3 = {s: 36}
+ d1["a"] = d2[s] # 24
+ d3[s] += d1["a"] # 60
+ d2["bc"] = d3[s] # 60
+ return d2["bc"], d1, d2, d3
+ res = interpret(f, [5])
+ assert res.item0 == 60
+ # all three dicts should use the same low-level type
+ assert lltype.typeOf(res.item1) == lltype.typeOf(res.item2)
+ assert lltype.typeOf(res.item1) == lltype.typeOf(res.item3)
+
# ____________________________________________________________
def test_id_instances_keys():
More information about the Pypy-commit
mailing list