diff options
author | Damien George <damien@micropython.org> | 2023-06-16 12:08:34 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-06-18 12:45:55 +1000 |
commit | ed962f1f233eb74edf2cee83dc488d3cac5e02ee (patch) | |
tree | 02ab1470a0bf698100b1d161e6bf13c714113ee1 /tests/float/math_domain_python311.py | |
parent | 47dc7d0130d583ce3c9426a82eabe0473ec1cfa5 (diff) |
tests/float: Test domain errors for more combos of args to math funcs.
Instead of having a special set of arguments to test for each math-module
function, just test all functions with all sets of arguments. This gives
improved test cases to prevent regressions.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/float/math_domain_python311.py')
-rw-r--r-- | tests/float/math_domain_python311.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/float/math_domain_python311.py b/tests/float/math_domain_python311.py new file mode 100644 index 000000000..f56fd5585 --- /dev/null +++ b/tests/float/math_domain_python311.py @@ -0,0 +1,26 @@ +# Tests domain errors in math functions. +# This is split out from math_domain.py because math.pow(0, -inf) was changed +# in Python 3.11, and so this test requires a .py.exp file. +# (See https://github.com/python/cpython/issues/88505) + +try: + import math +except ImportError: + print("SKIP") + raise SystemExit + +inf = float("inf") + +for name, f in ( + ("pow", math.pow), + ("log", math.log), + ("fmod", math.fmod), + ("atan2", math.atan2), + ("copysign", math.copysign), +): + for x in ((0, -inf),): + try: + ans = "%.4f" % f(*x) + except ValueError: + ans = "ValueError" + print("%s(%.4f, %.4f) = %s" % (name, x[0], x[1], ans)) |