Commits

Armin Rigo committed 5ba56e7

Detect mistakes in numeric constants too.

  • Participants
  • Parent commits 98e2050

Comments (0)

Files changed (2)

File pypy/module/pypyjit/test_pypy_c/model.py

     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:

File pypy/module/pypyjit/test_pypy_c/test_00_model.py

             # 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 = """