Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Oct 2011 05:28:13 +0000 (UTC)
From:      David Schultz <das@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r226378 - head/tools/regression/lib/msun
Message-ID:  <201110150528.p9F5SD0T096943@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: das
Date: Sat Oct 15 05:28:13 2011
New Revision: 226378
URL: http://svn.freebsd.org/changeset/base/226378

Log:
  Add some tests for corner cases of log() in unusual rounding modes.
  I wrote these ages ago, but they've been failing until now.

Modified:
  head/tools/regression/lib/msun/test-logarithm.c

Modified: head/tools/regression/lib/msun/test-logarithm.c
==============================================================================
--- head/tools/regression/lib/msun/test-logarithm.c	Sat Oct 15 05:26:16 2011	(r226377)
+++ head/tools/regression/lib/msun/test-logarithm.c	Sat Oct 15 05:28:13 2011	(r226378)
@@ -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);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201110150528.p9F5SD0T096943>