[pypy-commit] pypy default: Detect mistakes in numeric constants too.

arigo noreply at buildbot.pypy.org
Thu Jul 26 10:49:56 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r56459:5ba56e798290
Date: 2012-07-26 10:41 +0200
http://bitbucket.org/pypy/pypy/changeset/5ba56e798290/

Log:	Detect mistakes in numeric constants too.

diff --git a/pypy/module/pypyjit/test_pypy_c/model.py b/pypy/module/pypyjit/test_pypy_c/model.py
--- a/pypy/module/pypyjit/test_pypy_c/model.py
+++ b/pypy/module/pypyjit/test_pypy_c/model.py
@@ -346,10 +346,21 @@
     def is_const(cls, v1):
         return isinstance(v1, str) and v1.startswith('ConstClass(')
 
+    @staticmethod
+    def as_numeric_const(v1):
+        try:
+            return int(v1)
+        except (ValueError, TypeError):
+            return None
+
     def match_var(self, v1, exp_v2):
         assert v1 != '_'
         if exp_v2 == '_':
             return True
+        n1 = self.as_numeric_const(v1)
+        n2 = self.as_numeric_const(exp_v2)
+        if n1 is not None and n2 is not None:
+            return n1 == n2
         if self.is_const(v1) or self.is_const(exp_v2):
             return v1[:-1].startswith(exp_v2[:-1])
         if v1 not in self.alpha_map:
diff --git a/pypy/module/pypyjit/test_pypy_c/test_00_model.py b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
--- a/pypy/module/pypyjit/test_pypy_c/test_00_model.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_00_model.py
@@ -200,6 +200,12 @@
             # missing op at the end
         """
         assert not self.match(loop, expected)
+        #
+        expected = """
+            i5 = int_add(i2, 2)
+            jump(i5, descr=...)
+        """
+        assert not self.match(loop, expected)
 
     def test_match_descr(self):
         loop = """


More information about the pypy-commit mailing list