[pypy-svn] r7458 - in pypy/trunk/src/pypy/translator: . test

arigo at codespeak.net arigo at codespeak.net
Fri Nov 19 18:13:14 CET 2004


Author: arigo
Date: Fri Nov 19 18:13:14 2004
New Revision: 7458

Modified:
   pypy/trunk/src/pypy/translator/annrpython.py
   pypy/trunk/src/pypy/translator/test/test_annrpython.py
Log:
Better handling of isinstance(x, type): try hard not to lose any information
(added a test for that) and, maybe, to work better somewhere in
translate_pypy.py.



Modified: pypy/trunk/src/pypy/translator/annrpython.py
==============================================================================
--- pypy/trunk/src/pypy/translator/annrpython.py	(original)
+++ pypy/trunk/src/pypy/translator/annrpython.py	Fri Nov 19 18:13:14 2004
@@ -329,7 +329,7 @@
             cells = []
             for a in link.args:
                 if link.exitcase is True and a is knownvar \
-                       and self.binding(a).contains(knownvarvalue):
+                       and not knownvarvalue.contains(self.binding(a)):
                     cell = knownvarvalue
                 else:
                     cell = self.binding(a)

Modified: pypy/trunk/src/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/trunk/src/pypy/translator/test/test_annrpython.py	(original)
+++ pypy/trunk/src/pypy/translator/test/test_annrpython.py	Fri Nov 19 18:13:14 2004
@@ -283,6 +283,14 @@
         #a.translator.view()
         self.assertEquals(s.knowntype, int)
 
+    def test_flow_type_info_2(self):
+        a = RPythonAnnotator()
+        s = a.build_types(snippet.flow_type_info,
+                          [annmodel.SomeInteger(nonneg=True)])
+        # this checks that isinstance(i, int) didn't loose the
+        # actually more precise information that i is non-negative
+        self.assertEquals(s, annmodel.SomeInteger(nonneg=True))
+
     def test_flow_identity_info(self):
         a = RPythonAnnotator()
         s = a.build_types(snippet.flow_identity_info, [object, object])



More information about the Pypy-commit mailing list