Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib XXX: ugly hack to make these valid for vax fp.



details:   https://anonhg.NetBSD.org/src/rev/f5d9a206b8e7
branches:  trunk
changeset: 766952:f5d9a206b8e7
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Jul 04 22:33:29 2011 +0000

description:
XXX: ugly hack to make these valid for vax fp.
XXX: could consolidate some of this into a common header, but i'll
     leave that clean up for another time.

diffstat:

 tests/lib/libc/stdlib/t_strtod.c |  14 ++++++++++----
 tests/lib/libm/t_ceil.c          |  14 ++++++++++----
 tests/lib/libm/t_floor.c         |  14 ++++++++++----
 tests/lib/libm/t_round.c         |  16 +++++++++++-----
 4 files changed, 41 insertions(+), 17 deletions(-)

diffs (173 lines):

diff -r 4762df761b5c -r f5d9a206b8e7 tests/lib/libc/stdlib/t_strtod.c
--- a/tests/lib/libc/stdlib/t_strtod.c  Mon Jul 04 22:20:45 2011 +0000
+++ b/tests/lib/libc/stdlib/t_strtod.c  Mon Jul 04 22:33:29 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_strtod.c,v 1.21 2011/06/14 02:37:31 jruoho Exp $ */
+/*     $NetBSD: t_strtod.c,v 1.22 2011/07/04 22:33:29 mrg Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 /* Public domain, Otto Moerbeek <otto%drijf.net@localhost>, 2006. */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_strtod.c,v 1.21 2011/06/14 02:37:31 jruoho Exp $");
+__RCSID("$NetBSD: t_strtod.c,v 1.22 2011/07/04 22:33:29 mrg Exp $");
 
 #include <errno.h>
 #include <math.h>
@@ -82,6 +82,12 @@
        atf_tc_set_md_var(tc, "descr", "A strtod(3) with hexadecimals");
 }
 
+#ifdef __vax__
+#define SMALL_NUM       1.0e-38
+#else
+#define SMALL_NUM       1.0e-40
+#endif
+
 ATF_TC_BODY(strtod_hex, tc)
 {
        const char *str;
@@ -93,14 +99,14 @@
 
        ATF_REQUIRE(end == str + 4);
        ATF_REQUIRE(signbit(d) != 0);
-       ATF_REQUIRE(fabs(d) < 1.0e-40);
+       ATF_REQUIRE(fabs(d) < SMALL_NUM);
 
        str = "-0x";
        d = strtod(str, &end);  /* -0.0 */
 
        ATF_REQUIRE(end == str + 2);
        ATF_REQUIRE(signbit(d) != 0);
-       ATF_REQUIRE(fabs(d) < 1.0e-40);
+       ATF_REQUIRE(fabs(d) < SMALL_NUM);
 }
 
 ATF_TC(strtod_inf);
diff -r 4762df761b5c -r f5d9a206b8e7 tests/lib/libm/t_ceil.c
--- a/tests/lib/libm/t_ceil.c   Mon Jul 04 22:20:45 2011 +0000
+++ b/tests/lib/libm/t_ceil.c   Mon Jul 04 22:33:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ceil.c,v 1.3 2011/03/25 10:42:38 jruoho Exp $ */
+/* $NetBSD: t_ceil.c,v 1.4 2011/07/04 22:33:29 mrg Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ceil.c,v 1.3 2011/03/25 10:42:38 jruoho Exp $");
+__RCSID("$NetBSD: t_ceil.c,v 1.4 2011/07/04 22:33:29 mrg Exp $");
 
 #include <math.h>
 #include <limits.h>
@@ -42,6 +42,12 @@
        atf_tc_set_md_var(tc, "descr", "A basic test of ceil(3)");
 }
 
+#ifdef __vax__
+#define SMALL_NUM      1.0e-38
+#else
+#define SMALL_NUM      1.0e-40
+#endif
+
 ATF_TC_BODY(ceil, tc)
 {
        const int n = 10240;
@@ -53,8 +59,8 @@
                x = i + 0.999999999;
                y = i + 0.000000001;
 
-               ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < 1.0e-40);
-               ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < 1.0e-40);
+               ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < SMALL_NUM);
+               ATF_REQUIRE(fabs(ceil(x) - (double)(i + 1)) < SMALL_NUM);
        }
 }
 
diff -r 4762df761b5c -r f5d9a206b8e7 tests/lib/libm/t_floor.c
--- a/tests/lib/libm/t_floor.c  Mon Jul 04 22:20:45 2011 +0000
+++ b/tests/lib/libm/t_floor.c  Mon Jul 04 22:33:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_floor.c,v 1.4 2011/03/25 10:42:38 jruoho Exp $ */
+/* $NetBSD: t_floor.c,v 1.5 2011/07/04 22:33:29 mrg Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_floor.c,v 1.4 2011/03/25 10:42:38 jruoho Exp $");
+__RCSID("$NetBSD: t_floor.c,v 1.5 2011/07/04 22:33:29 mrg Exp $");
 
 #include <math.h>
 #include <limits.h>
@@ -43,6 +43,12 @@
        atf_tc_set_md_var(tc, "descr", "A basic test of floor(3)");
 }
 
+#ifdef __vax__
+#define SMALL_NUM      1.0e-38
+#else
+#define SMALL_NUM      1.0e-40
+#endif
+
 ATF_TC_BODY(floor, tc)
 {
        const int n = 10240;
@@ -60,8 +66,8 @@
                x = i + 0.999999999;
                y = i + 0.000000001;
 
-               ATF_REQUIRE(fabs(floor(x) - (double)i) < 1.0e-40);
-               ATF_REQUIRE(fabs(floor(y) - (double)i) < 1.0e-40);
+               ATF_REQUIRE(fabs(floor(x) - (double)i) < SMALL_NUM);
+               ATF_REQUIRE(fabs(floor(y) - (double)i) < SMALL_NUM);
        }
 }
 
diff -r 4762df761b5c -r f5d9a206b8e7 tests/lib/libm/t_round.c
--- a/tests/lib/libm/t_round.c  Mon Jul 04 22:20:45 2011 +0000
+++ b/tests/lib/libm/t_round.c  Mon Jul 04 22:33:29 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_round.c,v 1.1 2011/04/08 06:49:21 jruoho Exp $ */
+/* $NetBSD: t_round.c,v 1.2 2011/07/04 22:33:29 mrg Exp $ */
 
 #include <atf-c.h>
 #include <math.h>
@@ -13,6 +13,12 @@
 #define VAL    0x0.7ffffffffffffcp0
 #define VALF   0x0.7fffff8p0
 
+#ifdef __vax__
+#define SMALL_NUM      1.0e-38
+#else
+#define SMALL_NUM      1.0e-40
+#endif
+
 ATF_TC(round_dir);
 ATF_TC_HEAD(round_dir, tc)
 {
@@ -27,14 +33,14 @@
        b = round(a);
        bf = roundf(af);
 
-       ATF_REQUIRE(fabs(b) < 1.0e-40);
-       ATF_REQUIRE(fabsf(bf) < 1.0e-40);
+       ATF_REQUIRE(fabs(b) < SMALL_NUM);
+       ATF_REQUIRE(fabsf(bf) < SMALL_NUM);
 
        c = round(-a);
        cf = roundf(-af);
 
-       ATF_REQUIRE(fabs(c) < 1.0e-40);
-       ATF_REQUIRE(fabsf(cf) < 1.0e-40);
+       ATF_REQUIRE(fabs(c) < SMALL_NUM);
+       ATF_REQUIRE(fabsf(cf) < SMALL_NUM);
 }
 
 ATF_TP_ADD_TCS(tp)



Home | Main Index | Thread Index | Old Index