Skip to content

Commit

Permalink
Skip 3-arg pow tests under PyPy
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarbenjamin committed Oct 21, 2023
1 parent b160740 commit ad97112
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/flint/test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import operator
import pickle
import doctest
import platform

from flint.utils.flint_exceptions import DomainError

Expand All @@ -11,6 +12,8 @@
if sys.version_info[0] >= 3:
long = int

PYPY = platform.python_implementation() == "PyPy"

ctx = flint.ctx

def raises(f, exception):
Expand Down Expand Up @@ -141,13 +144,17 @@ def test_fmpz():
for a, b, c, ab_mod_c in pow_mod_examples:
assert pow(a, b, c) == ab_mod_c
assert pow(flint.fmpz(a), b, c) == ab_mod_c
assert pow(a, flint.fmpz(b), c) == ab_mod_c
assert pow(a, b, flint.fmpz(c)) == ab_mod_c
assert pow(flint.fmpz(a), flint.fmpz(b), c) == ab_mod_c
assert pow(flint.fmpz(a), b, flint.fmpz(c)) == ab_mod_c
assert pow(a, flint.fmpz(b), flint.fmpz(c)) == ab_mod_c
assert pow(flint.fmpz(a), flint.fmpz(b), flint.fmpz(c)) == ab_mod_c

# 3-arg pow cannot be made to work with fmpz on PyPy
# https://github.com/flintlib/python-flint/issues/74
if not PYPY:
assert pow(a, flint.fmpz(b), c) == ab_mod_c
assert pow(a, b, flint.fmpz(c)) == ab_mod_c
assert pow(a, flint.fmpz(b), flint.fmpz(c)) == ab_mod_c

assert raises(lambda: pow(flint.fmpz(2), 2, 0), ValueError)
# XXX: Handle negative modulus like int?
assert raises(lambda: pow(flint.fmpz(2), 2, -1), ValueError)
Expand Down

0 comments on commit ad97112

Please sign in to comment.