Author: Armin Rigo <[email protected]>
Branch:
Changeset: r65430:cdd7666ee866
Date: 2013-07-17 12:34 +0200
http://bitbucket.org/pypy/pypy/changeset/cdd7666ee866/
Log: int_mod
diff --git a/pypy/module/__pypy__/interp_intop.py
b/pypy/module/__pypy__/interp_intop.py
--- a/pypy/module/__pypy__/interp_intop.py
+++ b/pypy/module/__pypy__/interp_intop.py
@@ -19,3 +19,7 @@
@unwrap_spec(n=int, m=int)
def int_floordiv(space, n, m):
return space.wrap(llop.int_floordiv(lltype.Signed, n, m))
+
+@unwrap_spec(n=int, m=int)
+def int_mod(space, n, m):
+ return space.wrap(llop.int_mod(lltype.Signed, n, m))
diff --git a/pypy/module/__pypy__/test/test_intop.py
b/pypy/module/__pypy__/test/test_intop.py
--- a/pypy/module/__pypy__/test/test_intop.py
+++ b/pypy/module/__pypy__/test/test_intop.py
@@ -50,3 +50,13 @@
assert intop.int_floordiv(-41, -3) == 13
assert intop.int_floordiv(-sys.maxint, -1) == sys.maxint
assert intop.int_floordiv(sys.maxint, -1) == -sys.maxint
+
+ def test_int_mod(self):
+ import sys
+ from __pypy__ import intop
+ assert intop.int_mod(41, 3) == 2
+ assert intop.int_mod(41, -3) == 2
+ assert intop.int_mod(-41, 3) == -2
+ assert intop.int_mod(-41, -3) == -2
+ assert intop.int_mod(-sys.maxint, -1) == 0
+ assert intop.int_mod(sys.maxint, -1) == 0
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit