[pypy-svn] r64815 - pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template

arigo at codespeak.net arigo at codespeak.net
Wed Apr 29 17:27:52 CEST 2009


Author: arigo
Date: Wed Apr 29 17:27:51 2009
New Revision: 64815

Modified:
   pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/operations.py
Log:
Test more cases of int_floordiv_ovf_zer and int_mod_ovf_zer.


Modified: pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/operations.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/operations.py	(original)
+++ pypy/branch/pyjitpl5/pypy/translator/oosupport/test_template/operations.py	Wed Apr 29 17:27:51 2009
@@ -58,16 +58,35 @@
                 return -1
         assert self.interpret(fn, [10, 0]) == -1
 
+    def test_div_ovf_zer(self):
+        def fn(x, y):
+            try:
+                return ovfcheck(x // y)
+            except OverflowError:
+                return -41
+            except ZeroDivisionError:
+                return -42
+        assert self.interpret(fn, [50, 3]) == 16
+        assert self.interpret(fn, [50, 0]) == -42
+        assert self.interpret(fn, [50, -3]) == -17
+        assert self.interpret(fn, [-50, 3]) == -17
+        assert self.interpret(fn, [-50, -3]) == 16
+        assert self.interpret(fn, [-sys.maxint-1, -1]) == -41
+    
     def test_mod_ovf_zer(self):
         def fn(x, y):
             try:
                 return ovfcheck(x % y)
             except OverflowError:
-                return -1
+                return -41
             except ZeroDivisionError:
-                return -2
+                return -42
         assert self.interpret(fn, [10, 3]) == 1
-        assert self.interpret(fn, [10, 0]) == -2
+        assert self.interpret(fn, [10, 0]) == -42
+        assert self.interpret(fn, [10, -3]) == -2
+        assert self.interpret(fn, [-10, 3]) == 2
+        assert self.interpret(fn, [-10, -3]) == -1
+        assert self.interpret(fn, [-sys.maxint-1, -1]) == -41
 
     def test_llong_and(self):
         def fn(x, y):



More information about the Pypy-commit mailing list