[pypy-svn] pypy refactor-not-in-translator: (arigo, cfbolz): test and fix

cfbolz commits-noreply at bitbucket.org
Fri Feb 25 20:31:18 CET 2011


Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: refactor-not-in-translator
Changeset: r42304:539fbad9fcf7
Date: 2011-02-25 20:18 +0100
http://bitbucket.org/pypy/pypy/changeset/539fbad9fcf7/

Log:	(arigo, cfbolz): test and fix

diff --git a/pypy/annotation/test/test_annrpython.py b/pypy/annotation/test/test_annrpython.py
--- a/pypy/annotation/test/test_annrpython.py
+++ b/pypy/annotation/test/test_annrpython.py
@@ -1680,6 +1680,14 @@
         assert isinstance(s2.dictdef.dictkey.  s_value, annmodel.SomeInteger)
         assert isinstance(s2.dictdef.dictvalue.s_value, annmodel.SomeInteger)
 
+    def test_not_dict(self):
+        def f(x):
+            d = {x: x}
+            return not d
+        a = self.RPythonAnnotator()
+        s = a.build_types(f, [str])
+        assert isinstance(s, annmodel.SomeBool)
+
     def test_pbc_union(self):
         class A:
             def meth(self):

diff --git a/pypy/annotation/unaryop.py b/pypy/annotation/unaryop.py
--- a/pypy/annotation/unaryop.py
+++ b/pypy/annotation/unaryop.py
@@ -86,7 +86,7 @@
         knowntypedata = r.knowntypedata = {}
         fn, block, i = bk.position_key
         op = block.operations[i]
-        assert op.opname == "is_true" or op.opname == "nonzero"
+        assert op.opname in ["is_true", "nonzero", "is_false"]
         assert len(op.args) == 1
         arg = op.args[0]
         s_nonnone_obj = s_obj


More information about the Pypy-commit mailing list