py/modmath: Add math.tau, math.nan and math.inf constants.

Configurable by the new MICROPY_PY_MATH_CONSTANTS option.
This commit is contained in:
stijn
2019-11-20 13:38:33 +01:00
committed by Damien George
parent e0b8d69827
commit dd6967202a
9 changed files with 79 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
# Tests various constants of the math module.
try:
import math
from math import exp, cos
except ImportError:
print("SKIP")
raise SystemExit
print(math.e == exp(1.0))
print(cos(math.pi))

View File

@@ -0,0 +1,17 @@
# Tests constants of the math module available only with MICROPY_PY_MATH_CONSTANTS.
try:
import math
from math import isnan
math.tau
except (ImportError, AttributeError):
print("SKIP")
raise SystemExit
print(math.tau == 2.0 * math.pi)
print(math.inf == float("inf"))
print(-math.inf == -float("inf"))
print(isnan(math.nan))
print(isnan(-math.nan))