Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
3 changed files
with
94 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pow(0.0000, -inf) = inf | ||
log(0.0000, -inf) = ValueError | ||
fmod(0.0000, -inf) = 0.0000 | ||
atan2(0.0000, -inf) = 3.1416 | ||
copysign(0.0000, -inf) = -0.0000 |