[pypy-svn] r67711 - in pypy/trunk/pypy: rpython translator/test
antocuni at codespeak.net
antocuni at codespeak.net
Wed Sep 16 11:42:33 CEST 2009
Author: antocuni
Date: Wed Sep 16 11:42:33 2009
New Revision: 67711
Modified:
pypy/trunk/pypy/rpython/rlist.py
pypy/trunk/pypy/translator/test/test_simplify.py
Log:
test and fix: ootypesystem.rdict.*.rtype_len relies on hop.r_result to assign
the resulttype but the one in hop2 is wrong because it has been copied from
hop (which is a 'hint'): fix it.
Modified: pypy/trunk/pypy/rpython/rlist.py
==============================================================================
--- pypy/trunk/pypy/rpython/rlist.py (original)
+++ pypy/trunk/pypy/rpython/rlist.py Wed Sep 16 11:42:33 2009
@@ -162,6 +162,7 @@
return list_eq
def _get_v_maxlength(self, hop):
+ from pypy.rpython.rint import signed_repr
v_iterable = hop.args_v[1]
s_iterable = hop.args_s[1]
r_iterable = hop.args_r[1]
@@ -169,6 +170,7 @@
while hop2.nb_args > 0:
hop2.r_s_popfirstarg()
hop2.v_s_insertfirstarg(v_iterable, s_iterable)
+ hop2.r_result = signed_repr
v_maxlength = r_iterable.rtype_len(hop2)
return v_maxlength
Modified: pypy/trunk/pypy/translator/test/test_simplify.py
==============================================================================
--- pypy/trunk/pypy/translator/test/test_simplify.py (original)
+++ pypy/trunk/pypy/translator/test/test_simplify.py Wed Sep 16 11:42:33 2009
@@ -400,6 +400,18 @@
res = interp.eval_graph(graph, [8, 3])
assert res == 28 - 3
+ def test_dict(self):
+ def main(n, m):
+ d = {n: m, m: n}
+ lst = [i*17 for i in d]
+ return len(lst) + lst[0] + lst[-1]
+ interp, graph = self.specialize(main, [int, int])
+ res = interp.eval_graph(graph, [8, 5])
+ assert res == 2 + 8 * 17 + 5 * 17
+ res = interp.eval_graph(graph, [4, 4])
+ assert res == 1 + 4 * 17 + 4 * 17
+
+
def test_list_iterator(self):
# for now, this is not optimized as a list comp
def main(n):
More information about the Pypy-commit
mailing list