When performing a trunc op in a float value there is, basically, three scenarios: when the exponent is < 0, when it is > bitsize of the significand or with a value in the middle. Current generator was using data for values in the middle and < 0 but not for the last case so we add now a couple of values in that range and also the interesting 0.0 special value.
Signed-off-by: Andres Gomez <[email protected]> --- generated_tests/builtin_function.py | 8 +++++++- generated_tests/builtin_function_fp64.py | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/generated_tests/builtin_function.py b/generated_tests/builtin_function.py index b587851..7cbd237 100644 --- a/generated_tests/builtin_function.py +++ b/generated_tests/builtin_function.py @@ -859,7 +859,13 @@ def _make_componentwise_test_vectors(test_suite_dict): f('sign', 1, 110, np.sign, None, [np.linspace(-1.5, 1.5, 5)]) f('sign', 1, 130, np.sign, None, [ints]) f('floor', 1, 110, np.floor, None, [np.linspace(-2.0, 2.0, 4)]) - f('trunc', 1, 130, _trunc, None, [np.linspace(-2.0, 2.0, 8)]) + + # Note: with trunc we want to test values in which the floating + # point exponent is < 0, > 23 or in the middle. Hence, we append + # some numbers to cover all possible scenarios. + f('trunc', 1, 130, _trunc, None, + [np.append(np.linspace(-2.0, 2.0, 8), + [0.0, 45027112.0, -45027112.0])]) # Note: the direction of rounding used by round() is not specified # for half-integer values, so we test it over a range that doesn't diff --git a/generated_tests/builtin_function_fp64.py b/generated_tests/builtin_function_fp64.py index 7e4d3eb..af3599b 100644 --- a/generated_tests/builtin_function_fp64.py +++ b/generated_tests/builtin_function_fp64.py @@ -768,7 +768,13 @@ def _make_componentwise_test_vectors(test_suite_dict): f('abs', 1, np.abs, None, [np.linspace(-1.5, 1.5, 5)]) f('sign', 1, np.sign, None, [np.linspace(-1.5, 1.5, 5)]) f('floor', 1, np.floor, None, [np.linspace(-2.0, 2.0, 4)]) - f('trunc', 1, _trunc, None, [np.linspace(-2.0, 2.0, 8)]) + + # Note: with trunc we want to test values in which the floating + # point exponent is < 0, > 52 or in the middle. Hence, we append + # some numbers to cover all possible scenarios. + f('trunc', 1, _trunc, None, + [np.append(np.linspace(-2.0, 2.0, 8), + [0.0, 4.5027112340958570e19, -4.5027112340958570e19])]) # Note: the direction of rounding used by round() is not specified # for half-integer values, so we test it over a range that doesn't -- 2.8.0.rc3 _______________________________________________ Piglit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/piglit
