[pypy-commit] pypy math-improvements: improve test coverage by adding an explicit test for a rare case in division
cfbolz
pypy.commits at gmail.com
Thu Dec 13 07:18:48 EST 2018
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch: math-improvements
Changeset: r95472:bab1896b4351
Date: 2018-12-13 13:09 +0100
http://bitbucket.org/pypy/pypy/changeset/bab1896b4351/
Log: improve test coverage by adding an explicit test for a rare case in
division
diff --git a/rpython/rlib/test/test_rbigint.py b/rpython/rlib/test/test_rbigint.py
--- a/rpython/rlib/test/test_rbigint.py
+++ b/rpython/rlib/test/test_rbigint.py
@@ -900,6 +900,18 @@
assert rem.tolong() == _rem
py.test.raises(ZeroDivisionError, rbigint.fromlong(x).divmod, rbigint.fromlong(0))
+ # an explicit example for a very rare case in _x_divrem:
+ # "add w back if q was too large (this branch taken rarely)"
+ x = 2401064762424988628303678384283622960038813848808995811101817752058392725584695633
+ y = 510439143470502793407446782273075179624699774495710665331026
+ f1 = rbigint.fromlong(x)
+ f2 = rbigint.fromlong(y)
+ div, rem = f1.divmod(f2)
+ _div, _rem = divmod(x, y)
+ assert div.tolong() == _div
+ assert rem.tolong() == _rem
+
+
def test_int_divmod(self):
for x in long_vals:
for y in int_vals + [-sys.maxint-1]:
More information about the pypy-commit
mailing list