diff options
| author | Damien George <damien@micropython.org> | 2023-02-16 10:27:10 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2023-02-16 10:38:38 +1100 |
| commit | 177ae2f346b840f6e10dffc41e9cd1e47c9c9c1b (patch) | |
| tree | 48892a39d6ca571c49a33b5ff9e81468e3ee7781 /tests/float/math_fun.py | |
| parent | 799d88818232a1c73095e848c116170d7db1852e (diff) | |
tests/float: Make output of math function tests more readable.
By explicitly naming the function, its arguments, and result.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/float/math_fun.py')
| -rw-r--r-- | tests/float/math_fun.py | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/tests/float/math_fun.py b/tests/float/math_fun.py index 0d443a475..789158c0e 100644 --- a/tests/float/math_fun.py +++ b/tests/float/math_fun.py @@ -38,12 +38,12 @@ functions = [ ] for function_name, function, test_vals in functions: - print(function_name) for value in test_vals: try: - print("{:.5g}".format(function(value))) + ans = "{:.5g}".format(function(value)) except ValueError as e: - print(str(e)) + ans = str(e) + print("{}({:.5g}) = {}".format(function_name, value, ans)) tuple_functions = [ ("frexp", frexp, test_values), @@ -51,10 +51,9 @@ tuple_functions = [ ] for function_name, function, test_vals in tuple_functions: - print(function_name) for value in test_vals: x, y = function(value) - print("{:.5g} {:.5g}".format(x, y)) + print("{}({:.5g}) = ({:.5g}, {:.5g})".format(function_name, value, x, y)) binary_functions = [ ( @@ -83,9 +82,9 @@ binary_functions = [ ] for function_name, function, test_vals in binary_functions: - print(function_name) for value1, value2 in test_vals: try: - print("{:.5g}".format(function(value1, value2))) + ans = "{:.5g}".format(function(value1, value2)) except (ValueError, ZeroDivisionError) as e: - print(type(e)) + ans = type(e) + print("{}({:.5g}, {:.5g}) = {}".format(function_name, value1, value2, ans)) |
