tools/llvm: Do not build with symbols
[minix3.git] / tests / lib / libm / t_tanh.c
blob0e645a977af033bede5060944aa2910a3de7f9f6
1 /* $NetBSD: t_tanh.c,v 1.6 2011/09/12 17:45:51 jruoho Exp $ */
3 /*-
4 * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jukka Ruohonen.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: t_tanh.c,v 1.6 2011/09/12 17:45:51 jruoho Exp $");
34 #include <atf-c.h>
35 #include <math.h>
38 * tanh(3)
40 ATF_TC(tanh_nan);
41 ATF_TC_HEAD(tanh_nan, tc)
43 atf_tc_set_md_var(tc, "descr", "Test tanh(NaN) == NaN");
46 ATF_TC_BODY(tanh_nan, tc)
48 #ifndef __vax__
49 const double x = 0.0L / 0.0L;
51 ATF_CHECK(isnan(x) != 0);
52 ATF_CHECK(isnan(tanh(x)) != 0);
53 #endif
56 ATF_TC(tanh_inf_neg);
57 ATF_TC_HEAD(tanh_inf_neg, tc)
59 atf_tc_set_md_var(tc, "descr", "Test tanh(-Inf) == -1.0");
62 ATF_TC_BODY(tanh_inf_neg, tc)
64 #ifndef __vax__
65 const double x = -1.0L / 0.0L;
67 ATF_CHECK(tanh(x) == -1.0);
68 #endif
71 ATF_TC(tanh_inf_pos);
72 ATF_TC_HEAD(tanh_inf_pos, tc)
74 atf_tc_set_md_var(tc, "descr", "Test tanh(+Inf) == +1.0");
77 ATF_TC_BODY(tanh_inf_pos, tc)
79 #ifndef __vax__
80 const double x = 1.0L / 0.0L;
82 ATF_CHECK(tanh(x) == 1.0);
83 #endif
86 ATF_TC(tanh_zero_neg);
87 ATF_TC_HEAD(tanh_zero_neg, tc)
89 atf_tc_set_md_var(tc, "descr", "Test tanh(-0.0) == -0.0");
92 ATF_TC_BODY(tanh_zero_neg, tc)
94 #ifndef __vax__
95 const double x = -0.0L;
96 double y = tanh(x);
98 ATF_CHECK(x == y);
99 ATF_CHECK(signbit(x) != 0);
101 ATF_REQUIRE_MSG(signbit(y) != 0,
102 "compiler bug, waiting for newer gcc import, see PR lib/44057");
103 #endif
106 ATF_TC(tanh_zero_pos);
107 ATF_TC_HEAD(tanh_zero_pos, tc)
109 atf_tc_set_md_var(tc, "descr", "Test tanh(+0.0) == +0.0");
112 ATF_TC_BODY(tanh_zero_pos, tc)
114 #ifndef __vax__
115 const double x = 0.0L;
116 double y = tanh(x);
118 ATF_CHECK(x == y);
119 ATF_CHECK(signbit(x) == 0);
120 ATF_CHECK(signbit(y) == 0);
121 #endif
125 * tanhf(3)
127 ATF_TC(tanhf_nan);
128 ATF_TC_HEAD(tanhf_nan, tc)
130 atf_tc_set_md_var(tc, "descr", "Test tanhf(NaN) == NaN");
133 ATF_TC_BODY(tanhf_nan, tc)
135 #ifndef __vax__
136 const float x = 0.0L / 0.0L;
138 ATF_CHECK(isnan(x) != 0);
139 ATF_CHECK(isnan(tanhf(x)) != 0);
140 #endif
143 ATF_TC(tanhf_inf_neg);
144 ATF_TC_HEAD(tanhf_inf_neg, tc)
146 atf_tc_set_md_var(tc, "descr", "Test tanhf(-Inf) == -1.0");
149 ATF_TC_BODY(tanhf_inf_neg, tc)
151 #ifndef __vax__
152 const float x = -1.0L / 0.0L;
154 ATF_CHECK(tanhf(x) == -1.0);
155 #endif
158 ATF_TC(tanhf_inf_pos);
159 ATF_TC_HEAD(tanhf_inf_pos, tc)
161 atf_tc_set_md_var(tc, "descr", "Test tanhf(+Inf) == +1.0");
164 ATF_TC_BODY(tanhf_inf_pos, tc)
166 #ifndef __vax__
167 const float x = 1.0L / 0.0L;
169 ATF_CHECK(tanhf(x) == 1.0);
170 #endif
173 ATF_TC(tanhf_zero_neg);
174 ATF_TC_HEAD(tanhf_zero_neg, tc)
176 atf_tc_set_md_var(tc, "descr", "Test tanhf(-0.0) == -0.0");
179 ATF_TC_BODY(tanhf_zero_neg, tc)
181 #ifndef __vax__
182 const float x = -0.0L;
183 float y = tanh(x);
185 ATF_CHECK(x == y);
186 ATF_CHECK(signbit(x) != 0);
188 ATF_REQUIRE_MSG(signbit(y) != 0,
189 "compiler bug, waiting for newer gcc import, see PR lib/44057");
190 #endif
193 ATF_TC(tanhf_zero_pos);
194 ATF_TC_HEAD(tanhf_zero_pos, tc)
196 atf_tc_set_md_var(tc, "descr", "Test tanhf(+0.0) == +0.0");
199 ATF_TC_BODY(tanhf_zero_pos, tc)
201 #ifndef __vax__
202 const float x = 0.0L;
203 float y = tanhf(x);
205 ATF_CHECK(x == y);
206 ATF_CHECK(signbit(x) == 0);
207 ATF_CHECK(signbit(y) == 0);
208 #endif
211 ATF_TP_ADD_TCS(tp)
214 ATF_TP_ADD_TC(tp, tanh_nan);
215 ATF_TP_ADD_TC(tp, tanh_inf_neg);
216 ATF_TP_ADD_TC(tp, tanh_inf_pos);
217 ATF_TP_ADD_TC(tp, tanh_zero_neg);
218 ATF_TP_ADD_TC(tp, tanh_zero_pos);
220 ATF_TP_ADD_TC(tp, tanhf_nan);
221 ATF_TP_ADD_TC(tp, tanhf_inf_neg);
222 ATF_TP_ADD_TC(tp, tanhf_inf_pos);
223 ATF_TP_ADD_TC(tp, tanhf_zero_neg);
224 ATF_TP_ADD_TC(tp, tanhf_zero_pos);
226 return atf_no_error();