summaryrefslogtreecommitdiff
path: root/tests/float
diff options
context:
space:
mode:
Diffstat (limited to 'tests/float')
-rw-r--r--tests/float/cmath_fun.py3
-rw-r--r--tests/float/math_fun_special.py5
-rw-r--r--tests/float/string_format_fp30.py42
3 files changed, 8 insertions, 42 deletions
diff --git a/tests/float/cmath_fun.py b/tests/float/cmath_fun.py
index 39011733b..0037d7c65 100644
--- a/tests/float/cmath_fun.py
+++ b/tests/float/cmath_fun.py
@@ -51,6 +51,9 @@ for f_name, f, test_vals in functions:
print("%.5g" % ret)
elif type(ret) == tuple:
print("%.5g %.5g" % ret)
+ elif f_name == "exp":
+ # exp amplifies REPR_C inaccuracies, so we need to check one digit less
+ print("complex(%.4g, %.4g)" % (real, ret.imag))
else:
# some test (eg cmath.sqrt(-0.5)) disagree with CPython with tiny real part
real = ret.real
diff --git a/tests/float/math_fun_special.py b/tests/float/math_fun_special.py
index e674ec8df..a747f73e9 100644
--- a/tests/float/math_fun_special.py
+++ b/tests/float/math_fun_special.py
@@ -43,10 +43,15 @@ functions = [
("lgamma", lgamma, pos_test_values + [50.0, 100.0]),
]
+is_REPR_C = float("1.0000001") == float("1.0")
+
for function_name, function, test_vals in functions:
for value in test_vals:
try:
ans = "{:.4g}".format(function(value))
except ValueError as e:
ans = str(e)
+ # a tiny error in REPR_C value for 1.5204998778 causes a wrong rounded value
+ if is_REPR_C and function_name == 'erfc' and ans == "1.521":
+ ans = "1.52"
print("{}({:.4g}) = {}".format(function_name, value, ans))
diff --git a/tests/float/string_format_fp30.py b/tests/float/string_format_fp30.py
deleted file mode 100644
index 5f0b213da..000000000
--- a/tests/float/string_format_fp30.py
+++ /dev/null
@@ -1,42 +0,0 @@
-def test(fmt, *args):
- print("{:8s}".format(fmt) + ">" + fmt.format(*args) + "<")
-
-
-test("{:10.4}", 123.456)
-test("{:10.4e}", 123.456)
-test("{:10.4e}", -123.456)
-# test("{:10.4f}", 123.456)
-# test("{:10.4f}", -123.456)
-test("{:10.4g}", 123.456)
-test("{:10.4g}", -123.456)
-test("{:10.4n}", 123.456)
-test("{:e}", 100)
-test("{:f}", 200)
-test("{:g}", 300)
-
-test("{:10.4E}", 123.456)
-test("{:10.4E}", -123.456)
-# test("{:10.4F}", 123.456)
-# test("{:10.4F}", -123.456)
-test("{:10.4G}", 123.456)
-test("{:10.4G}", -123.456)
-
-test("{:06e}", float("inf"))
-test("{:06e}", float("-inf"))
-test("{:06e}", float("nan"))
-
-# The following fails right now
-# test("{:10.1}", 0.0)
-
-print("%.0f" % (1.750000 % 0.08333333333))
-# Below isn't compatible with single-precision float
-# print("%.1f" % (1.750000 % 0.08333333333))
-# print("%.2f" % (1.750000 % 0.08333333333))
-# print("%.12f" % (1.750000 % 0.08333333333))
-
-# tests for errors in format string
-
-try:
- "{:10.1b}".format(0.0)
-except ValueError:
- print("ValueError")