Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 7 Apr 2012 04:00:30 +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: r233974 - head/tools/regression/lib/msun
Message-ID:  <201204070400.q3740UCK041023@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: das
Date: Sat Apr  7 04:00:30 2012
New Revision: 233974
URL: http://svn.freebsd.org/changeset/base/233974

Log:
  Add some tests from PR 166463.  Also make sure that all of the tests,
  old and new, check the sign bits of both the remainder and the
  quotient.

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

Modified: head/tools/regression/lib/msun/test-rem.c
==============================================================================
--- head/tools/regression/lib/msun/test-rem.c	Sat Apr  7 03:59:12 2012	(r233973)
+++ head/tools/regression/lib/msun/test-rem.c	Sat Apr  7 04:00:30 2012	(r233974)
@@ -55,7 +55,7 @@ int
 main(int argc, char *argv[])
 {
 
-	printf("1..2\n");
+	printf("1..3\n");
 
 	test_invalid(0.0, 0.0);
 	test_invalid(1.0, 0.0);
@@ -96,6 +96,14 @@ main(int argc, char *argv[])
 
 	printf("ok 2 - rem\n");
 
+	test(0x1.66666cp+120, 0x1p+71, 0.0, 1476395008);
+	testd(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1);
+	testl(-0x1.0000000000003p+0, 0x1.0000000000003p+0, -0.0, -1);
+	testd(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189);
+	testl(-0x1.0000000000001p-749, 0x1.4p-1072, 0x1p-1074, -1288490189);
+
+	printf("ok 3 - rem\n");
+
 	return (0);
 }
 
@@ -136,10 +144,16 @@ static void
 testl(long double x, long double y, long double expected_rem, int expected_quo)
 {
 	int q;
+	long double rem;
 
 	q = random();
-	assert(remainderl(x, y) == expected_rem);
-	assert(remquol(x, y, &q) == expected_rem);
+	rem = remainderl(x, y);
+	assert(rem == expected_rem);
+	assert(!signbit(rem) == !signbit(expected_rem));
+	rem = remquol(x, y, &q);
+	assert(rem == expected_rem);
+	assert(!signbit(rem) == !signbit(expected_rem));
+	assert((q ^ expected_quo) >= 0); /* sign(q) == sign(expected_quo) */
 	assert((q & 0x7) == (expected_quo & 0x7));
 	if (q != 0) {
 		assert((q > 0) ^ !(expected_quo > 0));
@@ -152,10 +166,16 @@ static void
 testd(double x, double y, double expected_rem, int expected_quo)
 {
 	int q;
+	double rem;
 
 	q = random();
-	assert(remainder(x, y) == expected_rem);
-	assert(remquo(x, y, &q) == expected_rem);
+	rem = remainder(x, y);
+	assert(rem == expected_rem);
+	assert(!signbit(rem) == !signbit(expected_rem));
+	rem = remquo(x, y, &q);
+	assert(rem == expected_rem);
+	assert(!signbit(rem) == !signbit(expected_rem));
+	assert((q ^ expected_quo) >= 0); /* sign(q) == sign(expected_quo) */
 	assert((q & 0x7) == (expected_quo & 0x7));
 	if (q != 0) {
 		assert((q > 0) ^ !(expected_quo > 0));
@@ -168,10 +188,16 @@ static void
 testf(float x, float y, float expected_rem, int expected_quo)
 {
 	int q;
+	float rem;
 
 	q = random();
-	assert(remainderf(x, y) == expected_rem);
-	assert(remquof(x, y, &q) == expected_rem);
+	rem = remainderf(x, y);
+	assert(rem == expected_rem);
+	assert(!signbit(rem) == !signbit(expected_rem));
+	rem = remquof(x, y, &q);
+	assert(rem == expected_rem);
+	assert(!signbit(rem) == !signbit(expected_rem));
+	assert((q ^ expected_quo) >= 0); /* sign(q) == sign(expected_quo) */
 	assert((q & 0x7) == (expected_quo & 0x7));
 	if (q != 0) {
 		assert((q > 0) ^ !(expected_quo > 0));



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