Source-Changes-HG archive

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

[src/trunk]: src IEEE checks for the arcus functions.



details:   https://anonhg.NetBSD.org/src/rev/6eee7a71b0bb
branches:  trunk
changeset: 769673:6eee7a71b0bb
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Sat Sep 17 18:08:35 2011 +0000

description:
IEEE checks for the arcus functions.

diffstat:

 distrib/sets/lists/tests/mi |    8 +-
 tests/lib/libm/Makefile     |    5 +-
 tests/lib/libm/t_acos.c     |  277 ++++++++++++++++++++++++++++++++++++++
 tests/lib/libm/t_asin.c     |  315 ++++++++++++++++++++++++++++++++++++++++++++
 tests/lib/libm/t_atan.c     |  277 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 880 insertions(+), 2 deletions(-)

diffs (truncated from 927 to 300 lines):

diff -r fdfd541fd502 -r 6eee7a71b0bb distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Sep 17 17:06:47 2011 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Sep 17 18:08:35 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.387 2011/09/17 12:00:50 jruoho Exp $
+# $NetBSD: mi,v 1.388 2011/09/17 18:08:36 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -546,6 +546,9 @@
 ./usr/libdata/debug/usr/tests/lib/libevent                             tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libevent/h_event.debug               tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libm                                 tests-lib-debug
+./usr/libdata/debug/usr/tests/lib/libm/t_acos.debug                    tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libm/t_asin.debug                    tests-lib-debug         debug,atf
+./usr/libdata/debug/usr/tests/lib/libm/t_atan.debug                    tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libm/t_ceil.debug                    tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libm/t_cos.debug                     tests-lib-debug         debug,atf
 ./usr/libdata/debug/usr/tests/lib/libm/t_erf.debug                     tests-lib-debug         debug,atf
@@ -2257,6 +2260,9 @@
 ./usr/tests/lib/libevent/t_event               tests-lib-tests         atf
 ./usr/tests/lib/libm                           tests-lib-tests         atf
 ./usr/tests/lib/libm/Atffile                   tests-lib-tests         atf
+./usr/tests/lib/libm/t_acos                    tests-lib-tests         atf
+./usr/tests/lib/libm/t_asin                    tests-lib-tests         atf
+./usr/tests/lib/libm/t_atan                    tests-lib-tests         atf
 ./usr/tests/lib/libm/t_ceil                    tests-lib-tests         atf
 ./usr/tests/lib/libm/t_cos                     tests-lib-tests         atf
 ./usr/tests/lib/libm/t_erf                     tests-lib-tests         atf
diff -r fdfd541fd502 -r 6eee7a71b0bb tests/lib/libm/Makefile
--- a/tests/lib/libm/Makefile   Sat Sep 17 17:06:47 2011 +0000
+++ b/tests/lib/libm/Makefile   Sat Sep 17 18:08:35 2011 +0000
@@ -1,9 +1,12 @@
-# $NetBSD: Makefile,v 1.11 2011/09/17 12:00:50 jruoho Exp $
+# $NetBSD: Makefile,v 1.12 2011/09/17 18:08:35 jruoho Exp $
 
 .include <bsd.own.mk>
 
 TESTSDIR=      ${TESTSBASE}/lib/libm
 
+TESTS_C+=      t_acos
+TESTS_C+=      t_asin
+TESTS_C+=      t_atan
 TESTS_C+=      t_ceil
 TESTS_C+=      t_cos
 TESTS_C+=      t_erf
diff -r fdfd541fd502 -r 6eee7a71b0bb tests/lib/libm/t_acos.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_acos.c   Sat Sep 17 18:08:35 2011 +0000
@@ -0,0 +1,277 @@
+/* $NetBSD: t_acos.c,v 1.1 2011/09/17 18:08:35 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jukka Ruohonen.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <atf-c.h>
+#include <math.h>
+
+/*
+ * acos(3)
+ */
+ATF_TC(acos_nan);
+ATF_TC_HEAD(acos_nan, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acos(NaN) == NaN");
+}
+
+ATF_TC_BODY(acos_nan, tc)
+{
+#ifndef __vax__
+       const double x = 0.0L / 0.0L;
+
+       if (isnan(acos(x)) == 0)
+               atf_tc_fail_nonfatal("acos(NaN) != NaN");
+#endif
+}
+
+ATF_TC(acos_inf_neg);
+ATF_TC_HEAD(acos_inf_neg, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acos(-Inf) == NaN");
+}
+
+ATF_TC_BODY(acos_inf_neg, tc)
+{
+#ifndef __vax__
+       const double x = -1.0L / 0.0L;
+
+       if (isnan(acos(x)) == 0)
+               atf_tc_fail_nonfatal("acos(-Inf) != NaN");
+#endif
+}
+
+ATF_TC(acos_inf_pos);
+ATF_TC_HEAD(acos_inf_pos, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acos(+Inf) == NaN");
+}
+
+ATF_TC_BODY(acos_inf_pos, tc)
+{
+#ifndef __vax__
+       const double x = 1.0L / 0.0L;
+
+       if (isnan(acos(x)) == 0)
+               atf_tc_fail_nonfatal("acos(+Inf) != NaN");
+#endif
+}
+
+ATF_TC(acos_one_pos);
+ATF_TC_HEAD(acos_one_pos, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acos(1.0) == +0.0");
+}
+
+ATF_TC_BODY(acos_one_pos, tc)
+{
+#ifndef __vax__
+       const double y = acos(1.0);
+
+       if (fabs(y) > 0.0 || signbit(y) != 0)
+               atf_tc_fail_nonfatal("acos(1.0) != +0.0");
+#endif
+}
+
+ATF_TC(acos_range);
+ATF_TC_HEAD(acos_range, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acos(x) == NaN, x < -1, x > 1");
+}
+
+ATF_TC_BODY(acos_range, tc)
+{
+#ifndef __vax__
+       const double x[] = { -1.1, -1.000000001, 1.1, 1.000000001 };
+       size_t i;
+
+       for (i = 0; i < __arraycount(x); i++) {
+
+               if (isnan(acos(x[i])) == 0)
+                       atf_tc_fail_nonfatal("acos(%f) != NaN", x[i]);
+       }
+#endif
+}
+
+ATF_TC(acos_cos);
+ATF_TC_HEAD(acos_cos, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acos(cos(x)) == x");
+}
+
+ATF_TC_BODY(acos_cos, tc)
+{
+#ifndef __vax__
+       const double x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 };
+       const double eps = 1.0e-15;
+       double y;
+       size_t i;
+
+       for (i = 0; i < __arraycount(x); i++) {
+
+               y = acos(cos(x[i]));
+
+               if (fabs(y - x[i]) > eps)
+                       atf_tc_fail_nonfatal("acos(cos(%0.03f)) != %0.03f",
+                           x[i], x[i]);
+       }
+#endif
+}
+
+/*
+ * acosf(3)
+ */
+ATF_TC(acosf_nan);
+ATF_TC_HEAD(acosf_nan, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acosf(NaN) == NaN");
+}
+
+ATF_TC_BODY(acosf_nan, tc)
+{
+#ifndef __vax__
+       const float x = 0.0L / 0.0L;
+
+       if (isnan(acosf(x)) == 0)
+               atf_tc_fail_nonfatal("acosf(NaN) != NaN");
+#endif
+}
+
+ATF_TC(acosf_inf_neg);
+ATF_TC_HEAD(acosf_inf_neg, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acosf(-Inf) == NaN");
+}
+
+ATF_TC_BODY(acosf_inf_neg, tc)
+{
+#ifndef __vax__
+       const float x = -1.0L / 0.0L;
+
+       if (isnan(acosf(x)) == 0)
+               atf_tc_fail_nonfatal("acosf(-Inf) != NaN");
+#endif
+}
+
+ATF_TC(acosf_inf_pos);
+ATF_TC_HEAD(acosf_inf_pos, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acosf(+Inf) == NaN");
+}
+
+ATF_TC_BODY(acosf_inf_pos, tc)
+{
+#ifndef __vax__
+       const float x = 1.0L / 0.0L;
+
+       if (isnan(acosf(x)) == 0)
+               atf_tc_fail_nonfatal("acosf(+Inf) != NaN");
+#endif
+}
+
+ATF_TC(acosf_one_pos);
+ATF_TC_HEAD(acosf_one_pos, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acosf(1.0) == +0.0");
+}
+
+ATF_TC_BODY(acosf_one_pos, tc)
+{
+#ifndef __vax__
+       const float y = acosf(1.0);
+
+       if (fabsf(y) > 0.0 || signbit(y) != 0)
+               atf_tc_fail_nonfatal("acosf(1.0) != +0.0");
+#endif
+}
+
+ATF_TC(acosf_range);
+ATF_TC_HEAD(acosf_range, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acosf(x) == NaN, x < -1, x > 1");
+}
+
+ATF_TC_BODY(acosf_range, tc)
+{
+#ifndef __vax__
+       const float x[] = { -1.1, -1.0000001, 1.1, 1.0000001 };
+       size_t i;
+
+       for (i = 0; i < __arraycount(x); i++) {
+
+               if (isnan(acosf(x[i])) == 0)
+                       atf_tc_fail_nonfatal("acosf(%f) != NaN", x[i]);
+       }
+#endif
+}
+
+ATF_TC(acosf_cosf);
+ATF_TC_HEAD(acosf_cosf, tc)
+{
+       atf_tc_set_md_var(tc, "descr", "Test acosf(cosf(x)) == x");
+}
+
+ATF_TC_BODY(acosf_cosf, tc)
+{
+#ifndef __vax__
+       const float x[] = { 0.0, 1.0, M_PI / 2, M_PI / 3, M_PI / 6 };
+       const float eps = 1.0e-15;
+       float y;
+       size_t i;
+
+       for (i = 0; i < __arraycount(x); i++) {
+
+               y = acosf(cosf(x[i]));



Home | Main Index | Thread Index | Old Index