summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2011-10-15 05:28:13 +0000
committerdas <das@FreeBSD.org>2011-10-15 05:28:13 +0000
commit6cd0a1e46e61415ef23d11fba7b7c3869a557664 (patch)
tree8414dc0cfb7574a664dfb7e590727bb91997cb91 /tools
parent9f9eca0faeddcd96e9dd393f6be53a363a536fc8 (diff)
downloadFreeBSD-src-6cd0a1e46e61415ef23d11fba7b7c3869a557664.zip
FreeBSD-src-6cd0a1e46e61415ef23d11fba7b7c3869a557664.tar.gz
Add some tests for corner cases of log() in unusual rounding modes.
I wrote these ages ago, but they've been failing until now.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/lib/msun/test-logarithm.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/tools/regression/lib/msun/test-logarithm.c b/tools/regression/lib/msun/test-logarithm.c
index 52f562c..258c514 100644
--- a/tools/regression/lib/msun/test-logarithm.c
+++ b/tools/regression/lib/msun/test-logarithm.c
@@ -97,7 +97,7 @@ void
run_generic_tests(void)
{
- /* exp(1) == 0, no exceptions raised */
+ /* log(1) == 0, no exceptions raised */
testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0);
@@ -142,11 +142,35 @@ run_log2_tests(void)
}
}
+void
+run_roundingmode_tests(void)
+{
+
+ /*
+ * Corner cases in other rounding modes.
+ */
+ fesetround(FE_DOWNWARD);
+ /* These are still positive per IEEE 754R */
+ testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
+ testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
+ fesetround(FE_TOWARDZERO);
+ testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
+ testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
+
+ fesetround(FE_UPWARD);
+ testall0(1.0, 0.0, ALL_STD_EXCEPT, 0);
+ testall1(0.0, 0.0, ALL_STD_EXCEPT, 0);
+ /* log1p(-0.0) == -0.0 even when rounding upwards */
+ testall1(-0.0, -0.0, ALL_STD_EXCEPT, 0);
+
+ fesetround(FE_TONEAREST);
+}
+
int
main(int argc, char *argv[])
{
- printf("1..2\n");
+ printf("1..3\n");
run_generic_tests();
printf("ok 1 - logarithm\n");
@@ -154,5 +178,8 @@ main(int argc, char *argv[])
run_log2_tests();
printf("ok 2 - logarithm\n");
+ run_roundingmode_tests();
+ printf("ok 3 - logarithm\n");
+
return (0);
}
OpenPOWER on IntegriCloud