1. karen hamer
  2. pypy

Commits

Armin Rigo  committed e311e98

More tests. Fix.

  • Participants
  • Parent commits dbcaebc
  • Branches default

Comments (0)

Files changed (3)

File pypy/rpython/test/test_rdict.py

View file
  • Ignore whitespace
         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):

File pypy/rpython/test/test_rlist.py

View file
  • Ignore whitespace
         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):

File pypy/translator/transform.py

View file
  • Ignore whitespace
                 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):