diff options
Diffstat (limited to 'math')
| -rw-r--r-- | math/fenv.h | 6 | ||||
| -rw-r--r-- | math/libm-test.c | 1167 |
2 files changed, 866 insertions, 307 deletions
diff --git a/math/fenv.h b/math/fenv.h index c9a8a5c94b..c065d662e0 100644 --- a/math/fenv.h +++ b/math/fenv.h @@ -22,7 +22,7 @@ #ifndef _FENV_H -#define __FENV_H 1 +#define _FENV_H 1 #include <features.h> /* Get the architecture dependend definitions. The following definitions @@ -40,7 +40,7 @@ The following macros are defined iff the implementation supports this kind of exception. - FE_INEXACT inxeact result + FE_INEXACT inexact result FE_DIVBYZERO devision by zero FE_UNDERFLOW result not representable due to underflow FE_OVERFLOW result not representable due to overflow @@ -86,7 +86,7 @@ extern int fetestexcept __P ((int __excepts)); extern int fegetround __P ((void)); /* Establish the rounding direction represented by ROUND. */ -extern int fesetround __P ((int __round)); +extern int fesetround __P ((int __rounding_direction)); /* Floating-point environment. */ diff --git a/math/libm-test.c b/math/libm-test.c index 72c27b16ca..ccb8aa80d5 100644 --- a/math/libm-test.c +++ b/math/libm-test.c @@ -70,6 +70,7 @@ #include <complex.h> #include <math.h> #include <float.h> +#include <fenv.h> #include <errno.h> #include <stdlib.h> @@ -87,9 +88,6 @@ #define PRINT 1 #define NO_PRINT 0 -#define TEST_EXCEPTION(test) do {} while (0); -/* As long as no exception code is available prevent warnings. */ -#define UNUSED __attribute__ ((unused)) static int noErrors; @@ -155,6 +153,9 @@ random_value (MATHTYPE min_value, MATHTYPE max_value) if ((x <= min_value) || (x >= max_value) || !isfinite (x)) x = (max_value - min_value) / 2 + min_value; + /* Make sure the RNG has no influence on the exceptions. */ + feclearexcept (FE_ALL_EXCEPT); + return x; } @@ -173,6 +174,84 @@ random_less (MATHTYPE max_value) } +/* Test whether a given exception was raised. */ +static void +test_single_exception (const char *test_name, + short int exception, + short int exc_flag, + fexcept_t fe_flag, + const char *flag_name) +{ + if (exception & exc_flag) + { + if (fetestexcept (fe_flag)) + { + if (verbose > 2) + printf ("Pass: %s:\nException \"%s\" set\n", test_name, flag_name); + } + else + { + if (verbose) + printf ("Fail: %s:\nException \"%s\" not set\n", + test_name, flag_name); + ++noErrors; + } + } + else + { + if (fetestexcept (fe_flag)) + { + if (verbose) + printf ("Fail: %s:\nException \"%s\" set\n", + test_name, flag_name); + ++noErrors; + } + else + { + if (verbose > 2) + printf ("Pass: %s:\nException \"%s\" not set\n", + test_name, flag_name); + } + } +} + + +/* Test whether exception given by EXCEPTION are raised. */ +static void +test_not_exception (const char *test_name, short int exception) +{ +#ifdef FE_DIVBYZERO + if ((exception & FE_DIVBYZERO) == 0) + test_single_exception (test_name, exception, + DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO, + "Divide by zero"); +#endif +#ifdef FE_INVALID + if ((exception & FE_INVALID) == 0) + test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID, + "Invalid operation"); +#endif + feclearexcept (FE_ALL_EXCEPT); +} + + +/* Test whether exceptions given by EXCEPTION are raised. */ +static void +test_exceptions (const char *test_name, short int exception) +{ +#ifdef FE_DIVBYZERO + test_single_exception (test_name, exception, + DIVIDE_BY_ZERO_EXCEPTION, FE_DIVBYZERO, + "Divide by zero"); +#endif +#ifdef FE_INVALID + test_single_exception (test_name, exception, INVALID_EXCEPTION, FE_INVALID, + "Invalid operation"); +#endif + feclearexcept (FE_ALL_EXCEPT); +} + + /* Test if two floating point numbers are equal. */ static int check_equal (MATHTYPE computed, MATHTYPE supplied, MATHTYPE eps, MATHTYPE * diff) @@ -327,6 +406,7 @@ check (const char *test_name, MATHTYPE computed, MATHTYPE expected) MATHTYPE diff; int result; + test_exceptions (test_name, NO_EXCEPTION); result = check_equal (computed, expected, 0, &diff); output_result (test_name, result, computed, expected, diff, PRINT, PRINT); @@ -340,6 +420,7 @@ check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected, MATHTYPE diff; int result; + test_exceptions (test_name, NO_EXCEPTION); result = check_equal (computed, expected, 0, &diff); output_result_ext (test_name, result, computed, expected, diff, parameter, PRINT, PRINT); @@ -347,12 +428,27 @@ check_ext (const char *test_name, MATHTYPE computed, MATHTYPE expected, static void +check_exc (const char *test_name, MATHTYPE computed, MATHTYPE expected, + short exception) +{ + MATHTYPE diff; + int result; + + test_exceptions (test_name, exception); + result = check_equal (computed, expected, 0, &diff); + output_result (test_name, result, + computed, expected, diff, PRINT, PRINT); +} + + +static void check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected, MATHTYPE epsilon) { MATHTYPE diff; int result; + test_exceptions (test_name, NO_EXCEPTION); result = check_equal (computed, expected, epsilon, &diff); output_result (test_name, result, computed, expected, diff, PRINT, PRINT); @@ -362,6 +458,7 @@ check_eps (const char *test_name, MATHTYPE computed, MATHTYPE expected, static void check_bool (const char *test_name, int computed) { + test_exceptions (test_name, NO_EXCEPTION); output_result_bool (test_name, computed); } @@ -372,6 +469,8 @@ check_long (const char *test_name, long int computed, long int expected) long int diff = computed - expected; int result = diff == 0; + test_exceptions (test_name, NO_EXCEPTION); + if (result) { if (verbose > 2) @@ -401,6 +500,8 @@ check_longlong (const char *test_name, long long int computed, long long int diff = computed - expected; int result = diff == 0; + test_exceptions (test_name, NO_EXCEPTION); + if (result) { if (verbose > 2) @@ -426,14 +527,25 @@ check_longlong (const char *test_name, long long int computed, static void check_isnan (const char *test_name, MATHTYPE computed) { + test_exceptions (test_name, NO_EXCEPTION); output_isvalue (test_name, isnan (computed), computed); } static void check_isnan_exc (const char *test_name, MATHTYPE computed, - short exception UNUSED) + short exception) { + test_exceptions (test_name, exception); + output_isvalue (test_name, isnan (computed), computed); +} + + +static void +check_isnan_maybe_exc (const char *test_name, MATHTYPE computed, + short exception) +{ + test_not_exception (test_name, exception); output_isvalue (test_name, isnan (computed), computed); } @@ -442,6 +554,7 @@ static void check_isnan_ext (const char *test_name, MATHTYPE computed, MATHTYPE parameter) { + test_exceptions (test_name, NO_EXCEPTION); output_isvalue_ext (test_name, isnan (computed), computed, parameter); } @@ -450,6 +563,7 @@ check_isnan_ext (const char *test_name, MATHTYPE computed, static void check_isinfp (const char *test_name, MATHTYPE computed) { + test_exceptions (test_name, NO_EXCEPTION); output_isvalue (test_name, (ISINF (computed) == +1), computed); } @@ -458,6 +572,7 @@ static void check_isinfp_ext (const char *test_name, MATHTYPE computed, MATHTYPE parameter) { + test_exceptions (test_name, NO_EXCEPTION); output_isvalue_ext (test_name, (ISINF (computed) == +1), computed, parameter); } @@ -465,8 +580,9 @@ check_isinfp_ext (const char *test_name, MATHTYPE computed, /* Tests if computed is +Inf */ static void check_isinfp_exc (const char *test_name, MATHTYPE computed, - int exception UNUSED) + int exception) { + test_exceptions (test_name, exception); output_isvalue (test_name, (ISINF (computed) == +1), computed); } @@ -474,6 +590,7 @@ check_isinfp_exc (const char *test_name, MATHTYPE computed, static void check_isinfn (const char *test_name, MATHTYPE computed) { + test_exceptions (test_name, NO_EXCEPTION); output_isvalue (test_name, (ISINF (computed) == -1), computed); } @@ -482,6 +599,7 @@ static void check_isinfn_ext (const char *test_name, MATHTYPE computed, MATHTYPE parameter) { + test_exceptions (test_name, NO_EXCEPTION); output_isvalue_ext (test_name, (ISINF (computed) == -1), computed, parameter); } @@ -489,8 +607,9 @@ check_isinfn_ext (const char *test_name, MATHTYPE computed, /* Tests if computed is -Inf */ static void check_isinfn_exc (const char *test_name, MATHTYPE computed, - int exception UNUSED) + int exception) { + test_exceptions (test_name, exception); output_isvalue (test_name, (ISINF (computed) == -1), computed); } @@ -507,7 +626,7 @@ acos_test (void) check ("acos (1) == 0", FUNC(acos) (1), 0); x = random_greater (1); - check_isnan_exc ("acos (x) == NaN + invalid exception for |x| > 1", + check_isnan_exc ("acos (x) == NaN plus invalid exception for |x| > 1", FUNC(acos) (x), INVALID_EXCEPTION); } @@ -533,7 +652,7 @@ asin_test (void) check ("asin (0) == 0", FUNC(asin) (0), 0); x = random_greater (1); - check_isnan_exc ("asin x == NaN + invalid exception for |x| > 1", + check_isnan_exc ("asin x == NaN plus invalid exception for |x| > 1", FUNC(asin) (x), INVALID_EXCEPTION); } @@ -882,14 +1001,14 @@ ldexp_test (void) static void log_test (void) { - check_isinfn_exc ("log (+0) == -inf", FUNC(log) (0), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfn_exc ("log (-0) == -inf", FUNC(log) (minus_zero), - DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("log (+0) == -inf plus divide-by-zero exception", + FUNC(log) (0), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("log (-0) == -inf plus divide-by-zero exception", + FUNC(log) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION); check ("log (1) == 0", FUNC(log) (1), 0); - check_isnan_exc ("log (x) == NaN plus divide-by-zero exception if x < 0", + check_isnan_exc ("log (x) == NaN plus invalid exception if x < 0", FUNC(log) (-1), INVALID_EXCEPTION); check_isinfp ("log (+inf) == +inf", FUNC(log) (plus_infty)); @@ -905,14 +1024,14 @@ log_test (void) static void log10_test (void) { - check_isinfn_exc ("log10 (+0) == -inf", FUNC(log10) (0), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfn_exc ("log10 (-0) == -inf", FUNC(log10) (minus_zero), - DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("log10 (+0) == -inf plus divide-by-zero exception", + FUNC(log10) (0), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("log10 (-0) == -inf plus divide-by-zero exception", + FUNC(log10) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION); check ("log10 (1) == +0", FUNC(log10) (1), 0); - check_isnan_exc ("log10 (x) == NaN plus divide-by-zero exception if x < 0", + check_isnan_exc ("log10 (x) == NaN plus invalid exception if x < 0", FUNC(log10) (-1), INVALID_EXCEPTION); check_isinfp ("log10 (+inf) == +inf", FUNC(log10) (plus_infty)); @@ -935,9 +1054,9 @@ log1p_test (void) check ("log1p (+0) == +0", FUNC(log1p) (0), 0); check ("log1p (-0) == -0", FUNC(log1p) (minus_zero), minus_zero); - check_isinfn_exc ("log1p (-1) == -inf", FUNC(log1p) (-1), - DIVIDE_BY_ZERO_EXCEPTION); - check_isnan_exc ("log1p (x) == NaN plus divide-by-zero exception if x < -1", + check_isinfn_exc ("log1p (-1) == -inf plus divide-by-zero exception", + FUNC(log1p) (-1), DIVIDE_BY_ZERO_EXCEPTION); + check_isnan_exc ("log1p (x) == NaN plus invalid exception if x < -1", FUNC(log1p) (-2), INVALID_EXCEPTION); check_isinfp ("log1p (+inf) == +inf", FUNC(log1p) (plus_infty)); @@ -951,14 +1070,14 @@ log1p_test (void) static void log2_test (void) { - check_isinfn_exc ("log2 (+0) == -inf", FUNC(log2) (0), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfn_exc ("log2 (-0) == -inf", FUNC(log2) (minus_zero), - DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("log2 (+0) == -inf plus divide-by-zero exception", + FUNC(log2) (0), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("log2 (-0) == -inf plus divide-by-zero exception", + FUNC(log2) (minus_zero), DIVIDE_BY_ZERO_EXCEPTION); check ("log2 (1) == +0", FUNC(log2) (1), 0); - check_isnan_exc ("log2 (x) == NaN plus divide-by-zero exception if x < 0", + check_isnan_exc ("log2 (x) == NaN plus invalid exception if x < 0", FUNC(log2) (-1), INVALID_EXCEPTION); check_isinfp ("log2 (+inf) == +inf", FUNC(log2) (plus_infty)); @@ -1254,41 +1373,41 @@ pow_test (void) x = random_greater (0.0); check_isnan_ext ("pow (x, NaN) == NaN", FUNC(pow) (x, nan_value), x); - check_isnan_exc ("pow (+1, +inf) == NaN", FUNC(pow) (1, plus_infty), - INVALID_EXCEPTION); - check_isnan_exc ("pow (-1, +inf) == NaN", FUNC(pow) (-1, plus_infty), - INVALID_EXCEPTION); - check_isnan_exc ("pow (+1, -inf) == NaN", FUNC(pow) (1, minus_infty), - INVALID_EXCEPTION); - check_isnan_exc ("pow (-1, -inf) == NaN", FUNC(pow) (-1, minus_infty), - INVALID_EXCEPTION); - - check_isnan_exc ("pow (-0.1, 1.1) == NaN", FUNC(pow) (-0.1, 1.1), - INVALID_EXCEPTION); - check_isnan_exc ("pow (-0.1, -1.1) == NaN", FUNC(pow) (-0.1, -1.1), - INVALID_EXCEPTION); - check_isnan_exc ("pow (-10.1, 1.1) == NaN", FUNC(pow) (-10.1, 1.1), - INVALID_EXCEPTION); - check_isnan_exc ("pow (-10.1, -1.1) == NaN", FUNC(pow) (-10.1, -1.1), - INVALID_EXCEPTION); - - check_isinfp_exc ("pow (+0, -1) == +inf", FUNC(pow) (0, -1), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfp_exc ("pow (+0, -11) == +inf", FUNC(pow) (0, -11), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfn_exc ("pow (-0, -1) == -inf", FUNC(pow) (minus_zero, -1), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfn_exc ("pow (-0, -11) == -inf", FUNC(pow) (minus_zero, -11), - DIVIDE_BY_ZERO_EXCEPTION); - - check_isinfp_exc ("pow (+0, -2) == +inf", FUNC(pow) (0, -2), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfp_exc ("pow (+0, -11.1) == +inf", FUNC(pow) (0, -11.1), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfp_exc ("pow (-0, -2) == +inf", FUNC(pow) (minus_zero, -2), - DIVIDE_BY_ZERO_EXCEPTION); - check_isinfp_exc ("pow (-0, -11.1) == +inf", FUNC(pow) (minus_zero, -11.1), - DIVIDE_BY_ZERO_EXCEPTION); + check_isnan_exc ("pow (+1, +inf) == NaN plus invalid exception", + FUNC(pow) (1, plus_infty), INVALID_EXCEPTION); + check_isnan_exc ("pow (-1, +inf) == NaN plus invalid exception", + FUNC(pow) (-1, plus_infty), INVALID_EXCEPTION); + check_isnan_exc ("pow (+1, -inf) == NaN plus invalid exception", + FUNC(pow) (1, minus_infty), INVALID_EXCEPTION); + check_isnan_exc ("pow (-1, -inf) == NaN plus invalid exception", + FUNC(pow) (-1, minus_infty), INVALID_EXCEPTION); + + check_isnan_exc ("pow (-0.1, 1.1) == NaN plus invalid exception", + FUNC(pow) (-0.1, 1.1), INVALID_EXCEPTION); + check_isnan_exc ("pow (-0.1, -1.1) == NaN plus invalid exception", + FUNC(pow) (-0.1, -1.1), INVALID_EXCEPTION); + check_isnan_exc ("pow (-10.1, 1.1) == NaN plus invalid exception", + FUNC(pow) (-10.1, 1.1), INVALID_EXCEPTION); + check_isnan_exc ("pow (-10.1, -1.1) == NaN plus invalid exception", + FUNC(pow) (-10.1, -1.1), INVALID_EXCEPTION); + + check_isinfp_exc ("pow (+0, -1) == +inf plus divide-by-zero exception", + FUNC(pow) (0, -1), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfp_exc ("pow (+0, -11) == +inf plus divide-by-zero exception", + FUNC(pow) (0, -11), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("pow (-0, -1) == -inf plus divide-by-zero exception", + FUNC(pow) (minus_zero, -1), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfn_exc ("pow (-0, -11) == -inf plus divide-by-zero exception", + FUNC(pow) (minus_zero, -11), DIVIDE_BY_ZERO_EXCEPTION); + + check_isinfp_exc ("pow (+0, -2) == +inf plus divide-by-zero exception", + FUNC(pow) (0, -2), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfp_exc ("pow (+0, -11.1) == +inf plus divide-by-zero exception", + FUNC(pow) (0, -11.1), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfp_exc ("pow (-0, -2) == +inf plus divide-by-zero exception", + FUNC(pow) (minus_zero, -2), DIVIDE_BY_ZERO_EXCEPTION); + check_isinfp_exc ("pow (-0, -11.1) == +inf plus divide-by-zero exception", + FUNC(pow) (minus_zero, -11.1), DIVIDE_BY_ZERO_EXCEPTION); check ("pow (+0, 1) == +0", FUNC(pow) (0, 1), 0); check ("pow (+0, 11) == +0", FUNC(pow) (0, 11), 0); @@ -1622,12 +1741,46 @@ cexp_test (void) check ("real(cexp(-inf - 0i)) = 0", __real__ result, 0); check ("imag(cexp(-inf - 0i)) = -0", __imag__ result, minus_zero); + result = FUNC(cexp) (BUILD_COMPLEX (0.0, plus_infty)); + check_isnan_exc ("real(cexp(0 + i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(0 + i inf)) = NaN plus invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, plus_infty)); + check_isnan_exc ("real(cexp(-0 + i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(-0 + i inf)) = NaN plus invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (0.0, minus_infty)); + check_isnan_exc ("real(cexp(0 - i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(0 - i inf)) = NaN plus invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (minus_zero, minus_infty)); + check_isnan_exc ("real(cexp(-0 - i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(-0 - i inf)) = NaN plus invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (100.0, plus_infty)); - check_isnan ("real(cexp(x + i inf)) = NaN", __real__ result); - check_isnan ("imag(cexp(x + i inf)) = NaN", __imag__ result); + check_isnan_exc ("real(cexp(100.0 + i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(100.0 + i inf)) = NaN plus invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (-100.0, plus_infty)); + check_isnan_exc ("real(cexp(-100.0 + i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(-100.0 + i inf)) = NaN plus invalid exception", + __imag__ result); result = FUNC(cexp) (BUILD_COMPLEX (100.0, minus_infty)); - check_isnan ("real(cexp(x - i inf)) = NaN", __real__ result); - check_isnan ("imag(cexp(x - i inf)) = NaN", __imag__ result); + check_isnan_exc ("real(cexp(100.0 - i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(100.0 - i inf)) = NaN plus invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (-100.0, minus_infty)); + check_isnan_exc ("real(cexp(-100.0 - i inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(-100.0 - i inf)) = NaN", __imag__ result); result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, 2.0)); check ("real(cexp(-inf + 2.0i)) = -0", __real__ result, minus_zero); @@ -1644,11 +1797,15 @@ cexp_test (void) check_isinfn ("imag(cexp(+inf + 4.0i)) = -inf", __imag__ result); result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, plus_infty)); - check_isinfp ("real(cexp(+inf + i inf)) = +inf", __real__ result); - check_isnan ("imag(cexp(+inf + i inf)) = NaN", __imag__ result); + check_isinfp_exc ("real(cexp(+inf + i inf)) = +inf plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(+inf + i inf)) = NaN plus invalid exception", + __imag__ result); result = FUNC(cexp) (BUILD_COMPLEX (plus_infty, minus_infty)); - check_isinfp ("real(cexp(+inf - i inf)) = +inf", __real__ result); - check_isnan ("imag(cexp(+inf - i inf)) = NaN", __imag__ result); + check_isinfp_exc ("real(cexp(+inf - i inf)) = +inf plus invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(+inf - i inf)) = NaN plus invalid exception", + __imag__ result); result = FUNC(cexp) (BUILD_COMPLEX (minus_infty, plus_infty)); check ("real(cexp(-inf + i inf)) = 0", __real__ result, 0); @@ -1665,22 +1822,201 @@ cexp_test (void) check_isinfp ("real(cexp(+inf + i NaN)) = +inf", __real__ result); check_isnan ("imag(cexp(+inf + i NaN)) = NaN", __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 0.0)); + check_isnan_maybe_exc ("real(cexp(NaN + i0)) = NaN plus maybe invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(NaN + i0)) = NaN plus maybe invalid exception", + __imag__ result); result = FUNC(cexp) (BUILD_COMPLEX (nan_value, 1.0)); - check_isnan ("real(cexp(NaN + 1i)) = NaN", __real__ result); - check_isnan ("imag(cexp(NaN + 1i)) = NaN", __imag__ result); + check_isnan_maybe_exc ("real(cexp(NaN + 1i)) = NaN plus maybe invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(NaN + 1i)) = NaN plus maybe invalid exception", + __imag__ result); result = FUNC(cexp) (BUILD_COMPLEX (nan_value, plus_infty)); - check_isnan ("real(cexp(NaN + i inf)) = NaN", __real__ result); - check_isnan ("imag(cexp(NaN + i inf)) = NaN", __imag__ result); + check_isnan_maybe_exc ("real(cexp(NaN + i inf)) = NaN plus maybe invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(NaN + i inf)) = NaN plus maybe invalid exception", + __imag__ result); + + result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value)); + check_isnan_maybe_exc ("real(cexp(0 + i NaN)) = NaN plus maybe invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(0 + i NaN)) = NaN plus maybe invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value)); + check_isnan_maybe_exc ("real(cexp(1 + i NaN)) = NaN plus maybe invalid exception", + __real__ result, FE_INVALID); + check_isnan ("imag(cexp(1 + i NaN)) = NaN plus maybe invalid exception", + __imag__ result); + result = FUNC(cexp) (BUILD_COMPLEX (nan_value, nan_value)); check_isnan ("real(cexp(NaN + i NaN)) = NaN", __real__ result); check_isnan ("imag(cexp(NaN + i NaN)) = NaN", __imag__ result); +} - result = FUNC(cexp) (BUILD_COMPLEX (0, nan_value)); - check_isnan ("real(cexp(0 + i NaN)) = NaN", __real__ result); - check_isnan ("imag(cexp(0 + i NaN)) = NaN", __imag__ result); - result = FUNC(cexp) (BUILD_COMPLEX (1, nan_value)); - check_isnan ("real(cexp(1 + i NaN)) = NaN", __real__ result); - check_isnan ("imag(cexp(1 + i NaN)) = NaN", __imag__ result); + +static void +csin_test (void) +{ + __complex__ MATHTYPE result; + + result = FUNC(csin) (BUILD_COMPLEX (0.0, 0.0)); + check ("real(csin(0 + 0i)) = 0", __real__ result, 0); + check ("imag(csin(0 + 0i)) = 0", __imag__ result, 0); + result = FUNC(csin) (BUILD_COMPLEX (minus_zero, 0.0)); + check ("real(csin(-0 + 0i)) = -0", __real__ result, minus_zero); + check ("imag(csin(-0 + 0i)) = 0", __imag__ result, 0); + result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_zero)); + check ("real(csin(0 - 0i)) = 0", __real__ result, 0); + check ("imag(csin(0 - 0i)) = -0", __imag__ result, minus_zero); + result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_zero)); + check ("real(csin(-0 - 0i)) = -0", __real__ result, minus_zero); + check ("imag(csin(-0 - 0i)) = -0", __imag__ result, minus_zero); + + result = FUNC(csin) (BUILD_COMPLEX (0.0, plus_infty)); + check ("real(csin(0 + i Inf)) = 0", __real__ result, 0); + check_isinfp ("imag(csin(0 + i Inf)) = +Inf", __imag__ result); + result = FUNC(csin) (BUILD_COMPLEX (minus_zero, plus_infty)); + check ("real(csin(-0 + i Inf)) = -0", __real__ result, minus_zero); + check_isinfp ("imag(csin(-0 + i Inf)) = +Inf", __imag__ result); + result = FUNC(csin) (BUILD_COMPLEX (0.0, minus_infty)); + check ("real(csin(0 - i Inf)) = 0", __real__ result, 0); + check_isinfn ("imag(csin(0 - i Inf)) = -Inf", __imag__ result); + result = FUNC(csin) (BUILD_COMPLEX (minus_zero, minus_infty)); + check ("real(csin(-0 - i Inf)) = -0", __real__ result, minus_zero); + check_isinfn("imag(csin(-0 - i Inf)) = -Inf", __imag__ result); + + result = FUNC(csin) (BUILD_COMPLEX (plus_infty, 0.0)); + check_isnan_exc ("real(csin(+Inf + 0i)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check ("imag(csin(+Inf + 0i)) = +-0 plus invalid exception", + FUNC(fabs) (__imag__ result), 0); + result = FUNC(csin) (BUILD_COMPLEX (minus_infty, 0.0)); + check_isnan_exc ("real(csin(-Inf + 0i)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check ("imag(csin(-Inf + 0i)) = +-0 plus invalid exception", + FUNC(fabs) (__imag__ result), 0); + result = FUNC(csin) (BUILD_COMPLEX (plus_infty, minus_zero)); + check_isnan_exc ("real(csin(+Inf - 0i)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check ("imag(csin(+Inf - 0i)) = +-0 plus invalid exception", + FUNC(fabs) (__imag__ result), 0.0); + result = FUNC(csin) (BUILD_COMPLEX (minus_infty, minus_zero)); + check_isnan_exc ("real(csin(-Inf - 0i)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check ("imag(csin(-Inf - 0i)) = +-0 plus invalid exception", + FUNC(fabs) (__imag__ result), 0.0); + + result = FUNC(csin) (BUILD_COMPLEX (plus_infty, plus_infty)); + check_isnan_exc ("real(csin(+Inf + i Inf)) = NaN plus invalid exception", + __real__ result, FE_INVALID); + check_isinfp ("imag(csin(+Inf + i Inf)) = +-Inf plus invalid exception", + FUNC(fabs) (__imag__ result)); + result = FUNC(csin) (BUILD_COMPLEX (minus_infty, plus_infty)); + check_isnan_exc ("real(csin(-Inf + i Inf)) = NaN plus invalid excepti |
