Author: Armin Rigo <ar...@tunes.org>
Branch: flow-no-local-exception
Changeset: r65869:52641ef0a6dd
Date: 2013-07-31 12:34 +0200
http://bitbucket.org/pypy/pypy/changeset/52641ef0a6dd/

Log:    RPython test fixes

diff --git a/rpython/rtyper/test/test_llinterp.py 
b/rpython/rtyper/test/test_llinterp.py
--- a/rpython/rtyper/test/test_llinterp.py
+++ b/rpython/rtyper/test/test_llinterp.py
@@ -162,22 +162,22 @@
 def test_raise():
     res = interpret(raise_exception, [41])
     assert res == 41
-    interpret_raises(IndexError, raise_exception, [42])
+    interpret_raises(KeyError, raise_exception, [42])
     interpret_raises(ValueError, raise_exception, [43])
 
 def test_call_raise():
     res = interpret(call_raise, [41])
     assert res == 41
-    interpret_raises(IndexError, call_raise, [42])
+    interpret_raises(KeyError, call_raise, [42])
     interpret_raises(ValueError, call_raise, [43])
 
 def test_call_raise_twice():
     res = interpret(call_raise_twice, [6, 7])
     assert res == 13
-    interpret_raises(IndexError, call_raise_twice, [6, 42])
+    interpret_raises(KeyError, call_raise_twice, [6, 42])
     res = interpret(call_raise_twice, [6, 43])
     assert res == 1006
-    interpret_raises(IndexError, call_raise_twice, [42, 7])
+    interpret_raises(KeyError, call_raise_twice, [42, 7])
     interpret_raises(ValueError, call_raise_twice, [43, 7])
 
 def test_call_raise_intercept():
@@ -459,7 +459,7 @@
 
 def raise_exception(i):
     if i == 42:
-        raise IndexError
+        raise KeyError
     elif i == 43:
         raise ValueError
     return i
@@ -478,7 +478,7 @@
 def call_raise_intercept(i):
     try:
         return raise_exception(i)
-    except IndexError:
+    except KeyError:
         return i
     except ValueError:
         raise TypeError
diff --git a/rpython/rtyper/test/test_rstr.py b/rpython/rtyper/test/test_rstr.py
--- a/rpython/rtyper/test/test_rstr.py
+++ b/rpython/rtyper/test/test_rstr.py
@@ -29,26 +29,6 @@
             assert res == expected
             assert res.__class__ is expected.__class__
 
-    def test_implicit_index_error(self):
-        const = self.const
-        def fn(i):
-            s = const('hello')
-            try:
-                return s[i]
-            except IndexError:
-                return const('*')
-        for i in range(-5, 5):
-            res = self.interpret(fn, [i])
-            expected = fn(i)
-            assert res == expected
-            assert res.__class__ is expected.__class__
-        res = self.interpret(fn, [5])
-        assert res == '*'
-        res = self.interpret(fn, [6])
-        assert res == '*'
-        res = self.interpret(fn, [-42])
-        assert res == '*'
-
     def test_nonzero(self):
         const = self.const
         def fn(i, j):
@@ -903,63 +883,6 @@
             s.count(s, -10)
         py.test.raises(TyperError, self.interpret, f, ())
 
-    def test_getitem_exc(self):
-        const = self.const
-        def f(x):
-            s = const("z")
-            return s[x]
-
-        res = self.interpret(f, [0])
-        assert res == 'z'
-        try:
-            self.interpret_raises(IndexError, f, [1])
-        except (AssertionError,), e:
-            pass
-        else:
-            assert False
-
-        def f(x):
-            s = const("z")
-            try:
-                return s[x]
-            except IndexError:
-                return const('X')
-            except Exception:
-                return const(' ')
-
-        res = self.interpret(f, [0])
-        assert res == 'z'
-        res = self.interpret(f, [1])
-        assert res == 'X'
-
-        def f(x):
-            s = const("z")
-            try:
-                return s[x]
-            except Exception:
-                return const(' ')
-
-        res = self.interpret(f, [0])
-        assert res == 'z'
-        res = self.interpret(f, [1])
-        assert res == ' '
-
-        def f(x):
-            s = const("z")
-            try:
-                return s[x]
-            except ValueError:
-                return const(' ')
-
-        res = self.interpret(f, [0])
-        assert res == 'z'
-        try:
-            self.interpret_raises(IndexError, f, [1])
-        except (AssertionError,), e:
-            pass
-        else:
-            assert False
-
     def test_fold_concat(self):
         const = self.const
         def g(tail):
@@ -1134,4 +1057,4 @@
         array = lltype.malloc(TP, 12, flavor='raw')
         self.interpret(f, [array, 4])
         assert list(array) == list('abc'*4)
-        lltype.free(array, flavor='raw')
\ No newline at end of file
+        lltype.free(array, flavor='raw')
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to