[pypy-svn] r17540 - in pypy/dist/pypy/rpython: . test
pedronis at codespeak.net
pedronis at codespeak.net
Tue Sep 13 19:31:12 CEST 2005
Author: pedronis
Date: Tue Sep 13 19:31:10 2005
New Revision: 17540
Modified:
pypy/dist/pypy/rpython/rtuple.py
pypy/dist/pypy/rpython/test/test_rtuple.py
Log:
extend in constant tuple, to support annotated constansts vs just inline one
Modified: pypy/dist/pypy/rpython/rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/rtuple.py (original)
+++ pypy/dist/pypy/rpython/rtuple.py Tue Sep 13 19:31:10 2005
@@ -83,16 +83,16 @@
class __extend__(pairtype(TupleRepr, Repr)):
- def rtype_contains((r_tup, r_item), hop):
- v_tup = hop.args_v[0]
- if not isinstance(v_tup, Constant):
+ def rtype_contains((r_tup, r_item), hop):
+ s_tup = hop.args_s[0]
+ if not s_tup.is_constant():
raise TyperError("contains() on non-const tuple")
- t = v_tup.value
+ t = s_tup.const
typ = type(t[0])
for x in t[1:]:
if type(x) is not typ:
raise TyperError("contains() on mixed-type tuple "
- "constant %r" % (v_tup,))
+ "constant %r" % (t,))
d = {}
for x in t:
d[x] = None
Modified: pypy/dist/pypy/rpython/test/test_rtuple.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rtuple.py (original)
+++ pypy/dist/pypy/rpython/test/test_rtuple.py Tue Sep 13 19:31:10 2005
@@ -78,6 +78,17 @@
res = interpret(f, [0])
assert res is False
+def test_constant_tuple_contains2():
+ def t1():
+ return (1,2,3,4)
+ def f(i):
+ return i in t1()
+ res = interpret(f, [3], view=False, viewbefore=False)
+ assert res is True
+ res = interpret(f, [0])
+ assert res is False
+
+
def test_constant_unichar_tuple_contains():
def f(i):
return unichr(i) in (u'1', u'9')
More information about the Pypy-commit
mailing list