[pypy-commit] pypy default: More tests. Fix.
arigo
noreply at buildbot.pypy.org
Mon Aug 13 10:36:18 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r56719:e311e98feac7
Date: 2012-08-13 10:35 +0200
http://bitbucket.org/pypy/pypy/changeset/e311e98feac7/
Log: More tests. Fix.
diff --git a/pypy/rpython/test/test_rdict.py b/pypy/rpython/test/test_rdict.py
--- a/pypy/rpython/test/test_rdict.py
+++ b/pypy/rpython/test/test_rdict.py
@@ -111,6 +111,16 @@
assert self.interpret(func, [42, 0]) == False
assert self.interpret(func, [42, 42]) == True
+ def test_contains_2(self):
+ d = {'5': None, '7': None}
+ def func(x):
+ return chr(x) in d
+ #assert self.interpret(func, [ord('5')]) == True
+ #assert self.interpret(func, [ord('6')]) == False
+
+ def func(n):
+ return str(n) in d
+ assert self.interpret(func, [512]) == False
def test_dict_iteration(self):
def func(i, j):
diff --git a/pypy/rpython/test/test_rlist.py b/pypy/rpython/test/test_rlist.py
--- a/pypy/rpython/test/test_rlist.py
+++ b/pypy/rpython/test/test_rlist.py
@@ -712,11 +712,26 @@
assert res is True
- def test_not_a_char_list_after_all(self):
+ def test_not_a_char_list_after_all_1(self):
+ def fn(n):
+ l = ['h', 'e', 'l', 'l', '0']
+ return str(n) in l # turns into: str(n) in {'h','e','l','0'}
+ res = self.interpret(fn, [5])
+ assert res is False
+ res = self.interpret(fn, [0])
+ assert res is True
+
def fn():
- l = ['h', 'e', 'l', 'l', 'o']
+ l = ['h', 'e', 'l', 'l', '0']
+ return 'hi' in l # turns into: 'hi' in {'h','e','l','0'}
+ res = self.interpret(fn, [])
+ assert res is False
+
+ def test_not_a_char_list_after_all_2(self):
+ def fn(n):
+ l = ['h', 'e', 'l', 'l', 'o', chr(n)]
return 'world' in l
- res = self.interpret(fn, [])
+ res = self.interpret(fn, [0])
assert res is False
def test_list_index(self):
diff --git a/pypy/translator/transform.py b/pypy/translator/transform.py
--- a/pypy/translator/transform.py
+++ b/pypy/translator/transform.py
@@ -134,6 +134,8 @@
else:
# all arguments of the newlist are annotation constants
op.args[0] = Constant(items)
+ s_dict = self.binding(op.args[0])
+ s_dict.dictdef.generalize_key(self.binding(op.args[1]))
def transform_dead_op_vars(self, block_subset):
More information about the pypy-commit
mailing list