tools/llvm: Do not build with symbols
[minix3.git] / tests / lib / libm / t_asin.c
blob1b27f05934888f294ee42e9a0b6ed778cd8bc704
1 /* $NetBSD: t_asin.c,v 1.2 2013/04/09 12:11:04 isaki 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.
32 #include <atf-c.h>
33 #include <math.h>
35 static const struct {
36 double x;
37 double y;
38 } values[] = {
39 { -1.0, -M_PI / 2, },
40 { -0.9, -1.119769514998634, },
41 { -0.5, -M_PI / 6, },
42 { -0.1, -0.1001674211615598, },
43 { 0.1, 0.1001674211615598, },
44 { 0.5, M_PI / 6, },
45 { 0.9, 1.119769514998634, },
46 { 1.0, M_PI / 2, },
50 * asin(3)
52 ATF_TC(asin_nan);
53 ATF_TC_HEAD(asin_nan, tc)
55 atf_tc_set_md_var(tc, "descr", "Test asin(NaN) == NaN");
58 ATF_TC_BODY(asin_nan, tc)
60 #ifndef __vax__
61 const double x = 0.0L / 0.0L;
63 if (isnan(asin(x)) == 0)
64 atf_tc_fail_nonfatal("asin(NaN) != NaN");
65 #endif
68 ATF_TC(asin_inf_neg);
69 ATF_TC_HEAD(asin_inf_neg, tc)
71 atf_tc_set_md_var(tc, "descr", "Test asin(-Inf) == NaN");
74 ATF_TC_BODY(asin_inf_neg, tc)
76 #ifndef __vax__
77 const double x = -1.0L / 0.0L;
79 if (isnan(asin(x)) == 0)
80 atf_tc_fail_nonfatal("asin(-Inf) != NaN");
81 #endif
84 ATF_TC(asin_inf_pos);
85 ATF_TC_HEAD(asin_inf_pos, tc)
87 atf_tc_set_md_var(tc, "descr", "Test asin(+Inf) == NaN");
90 ATF_TC_BODY(asin_inf_pos, tc)
92 #ifndef __vax__
93 const double x = 1.0L / 0.0L;
95 if (isnan(asin(x)) == 0)
96 atf_tc_fail_nonfatal("asin(+Inf) != NaN");
97 #endif
100 ATF_TC(asin_range);
101 ATF_TC_HEAD(asin_range, tc)
103 atf_tc_set_md_var(tc, "descr", "Test asin(x) == NaN, x < -1, x > 1");
106 ATF_TC_BODY(asin_range, tc)
108 #ifndef __vax__
109 const double x[] = { -1.1, -1.000000001, 1.1, 1.000000001 };
110 size_t i;
112 for (i = 0; i < __arraycount(x); i++) {
114 if (isnan(asin(x[i])) == 0)
115 atf_tc_fail_nonfatal("asin(%f) != NaN", x[i]);
117 #endif
120 ATF_TC(asin_inrange);
121 ATF_TC_HEAD(asin_inrange, tc)
123 atf_tc_set_md_var(tc, "descr", "Test asin(x) for some values");
126 ATF_TC_BODY(asin_inrange, tc)
128 #ifndef __vax__
129 const double eps = 1.0e-15;
130 double y;
131 size_t i;
133 for (i = 0; i < __arraycount(values); i++) {
134 y = asin(values[i].x);
135 if (fabs(y - values[i].y) > eps)
136 atf_tc_fail_nonfatal("asin(%g) != %g",
137 values[i].x, values[i].y);
139 #endif
142 ATF_TC(asin_zero_neg);
143 ATF_TC_HEAD(asin_zero_neg, tc)
145 atf_tc_set_md_var(tc, "descr", "Test asin(-0.0) == -0.0");
148 ATF_TC_BODY(asin_zero_neg, tc)
150 #ifndef __vax__
151 const double x = -0.0L;
152 double y = asin(x);
154 if (fabs(y) > 0.0 || signbit(y) == 0)
155 atf_tc_fail_nonfatal("asin(-0.0) != -0.0");
156 #endif
159 ATF_TC(asin_zero_pos);
160 ATF_TC_HEAD(asin_zero_pos, tc)
162 atf_tc_set_md_var(tc, "descr", "Test asin(+0.0) == +0.0");
165 ATF_TC_BODY(asin_zero_pos, tc)
167 #ifndef __vax__
168 const double x = 0.0L;
169 double y = asin(x);
171 if (fabs(y) > 0.0 || signbit(y) != 0)
172 atf_tc_fail_nonfatal("asin(+0.0) != +0.0");
173 #endif
177 * asinf(3)
179 ATF_TC(asinf_nan);
180 ATF_TC_HEAD(asinf_nan, tc)
182 atf_tc_set_md_var(tc, "descr", "Test asinf(NaN) == NaN");
185 ATF_TC_BODY(asinf_nan, tc)
187 #ifndef __vax__
188 const float x = 0.0L / 0.0L;
190 if (isnan(asinf(x)) == 0)
191 atf_tc_fail_nonfatal("asinf(NaN) != NaN");
192 #endif
195 ATF_TC(asinf_inf_neg);
196 ATF_TC_HEAD(asinf_inf_neg, tc)
198 atf_tc_set_md_var(tc, "descr", "Test asinf(-Inf) == NaN");
201 ATF_TC_BODY(asinf_inf_neg, tc)
203 #ifndef __vax__
204 const float x = -1.0L / 0.0L;
206 if (isnan(asinf(x)) == 0)
207 atf_tc_fail_nonfatal("asinf(-Inf) != NaN");
208 #endif
211 ATF_TC(asinf_inf_pos);
212 ATF_TC_HEAD(asinf_inf_pos, tc)
214 atf_tc_set_md_var(tc, "descr", "Test asinf(+Inf) == NaN");
217 ATF_TC_BODY(asinf_inf_pos, tc)
219 #ifndef __vax__
220 const float x = 1.0L / 0.0L;
222 if (isnan(asinf(x)) == 0)
223 atf_tc_fail_nonfatal("asinf(+Inf) != NaN");
224 #endif
227 ATF_TC(asinf_range);
228 ATF_TC_HEAD(asinf_range, tc)
230 atf_tc_set_md_var(tc, "descr", "Test asinf(x) == NaN, x < -1, x > 1");
233 ATF_TC_BODY(asinf_range, tc)
235 #ifndef __vax__
236 const float x[] = { -1.1, -1.0000001, 1.1, 1.0000001 };
237 size_t i;
239 for (i = 0; i < __arraycount(x); i++) {
241 if (isnan(asinf(x[i])) == 0)
242 atf_tc_fail_nonfatal("asinf(%f) != NaN", x[i]);
244 #endif
247 ATF_TC(asinf_inrange);
248 ATF_TC_HEAD(asinf_inrange, tc)
250 atf_tc_set_md_var(tc, "descr", "Test asinf(x) for some values");
253 ATF_TC_BODY(asinf_inrange, tc)
255 #ifndef __vax__
256 const float eps = 1.0e-6;
257 float x;
258 float y;
259 size_t i;
261 for (i = 0; i < __arraycount(values); i++) {
262 x = values[i].x;
263 y = values[i].y;
264 if (fabs(asinf(x) - y) > eps)
265 atf_tc_fail_nonfatal("asinf(%g) != %g", x, y);
267 #endif
270 ATF_TC(asinf_zero_neg);
271 ATF_TC_HEAD(asinf_zero_neg, tc)
273 atf_tc_set_md_var(tc, "descr", "Test asinf(-0.0) == -0.0");
276 ATF_TC_BODY(asinf_zero_neg, tc)
278 #ifndef __vax__
279 const float x = -0.0L;
280 float y = asinf(x);
282 if (fabsf(y) > 0.0 || signbit(y) == 0)
283 atf_tc_fail_nonfatal("asinf(-0.0) != -0.0");
284 #endif
287 ATF_TC(asinf_zero_pos);
288 ATF_TC_HEAD(asinf_zero_pos, tc)
290 atf_tc_set_md_var(tc, "descr", "Test asinf(+0.0) == +0.0");
293 ATF_TC_BODY(asinf_zero_pos, tc)
295 #ifndef __vax__
296 const float x = 0.0L;
297 float y = asinf(x);
299 if (fabsf(y) > 0.0 || signbit(y) != 0)
300 atf_tc_fail_nonfatal("asinf(+0.0) != +0.0");
301 #endif
304 ATF_TP_ADD_TCS(tp)
307 ATF_TP_ADD_TC(tp, asin_nan);
308 ATF_TP_ADD_TC(tp, asin_inf_neg);
309 ATF_TP_ADD_TC(tp, asin_inf_pos);
310 ATF_TP_ADD_TC(tp, asin_range);
311 ATF_TP_ADD_TC(tp, asin_inrange);
312 ATF_TP_ADD_TC(tp, asin_zero_neg);
313 ATF_TP_ADD_TC(tp, asin_zero_pos);
315 ATF_TP_ADD_TC(tp, asinf_nan);
316 ATF_TP_ADD_TC(tp, asinf_inf_neg);
317 ATF_TP_ADD_TC(tp, asinf_inf_pos);
318 ATF_TP_ADD_TC(tp, asinf_range);
319 ATF_TP_ADD_TC(tp, asinf_inrange);
320 ATF_TP_ADD_TC(tp, asinf_zero_neg);
321 ATF_TP_ADD_TC(tp, asinf_zero_pos);
323 return atf_no_error();