Commits

Maciej Fijalkowski  committed d91e484

some tests for error messages

  • Participants
  • Parent commits 0160801

Comments (0)

Files changed (1)

File rpython/annotator/test/test_annrpython.py

 
         a.build_types(f, [str])
 
+    def test_negative_number_find(self):
+        def f(s, e):
+            return "xyz".find("x", s, e)
+
+        a = self.RPythonAnnotator()
+        py.test.raises(annmodel.AnnotatorError, "a.build_types(f, [int, int])")
+        a.build_types(f, [annmodel.SomeInteger(nonneg=True),
+                          annmodel.SomeInteger(nonneg=True)])
+        def f(s, e):
+            return "xyz".rfind("x", s, e)
+
+        py.test.raises(annmodel.AnnotatorError, "a.build_types(f, [int, int])")
+        a.build_types(f, [annmodel.SomeInteger(nonneg=True),
+                          annmodel.SomeInteger(nonneg=True)])
+
+        def f(s, e):
+            return "xyz".count("x", s, e)
+
+        py.test.raises(annmodel.AnnotatorError, "a.build_types(f, [int, int])")
+        a.build_types(f, [annmodel.SomeInteger(nonneg=True),
+                          annmodel.SomeInteger(nonneg=True)])
+        
+
     def test_setslice(self):
         def f():
             lst = [2, 5, 7]
         with py.test.raises(annmodel.UnionError) as exc:
             a.build_types(f, [int])
 
-        assert ("RPython cannot unify instances with no common base class" 
+        assert ("RPython cannot unify instances with no common base class"
                 in exc.value.msg)
 
     def test_unionerror_iters(self):
         with py.test.raises(annmodel.UnionError) as exc:
             a.build_types(f, [int])
 
-        assert ("RPython cannot unify incompatible iterator variants" in 
+        assert ("RPython cannot unify incompatible iterator variants" in
                 exc.value.msg)
 
     def test_variable_getattr(self):