@@ -6,7 +6,7 @@ use core::f32;
6
6
use CheckBasis :: { Mpfr , Musl } ;
7
7
use Identifier as Id ;
8
8
9
- use crate :: { CheckBasis , CheckCtx , Float , Identifier , Int , TestResult } ;
9
+ use crate :: { BaseName , CheckBasis , CheckCtx , Float , Identifier , Int , TestResult } ;
10
10
11
11
/// Type implementing [`IgnoreCase`].
12
12
pub struct SpecialCase ;
@@ -106,25 +106,26 @@ impl MaybeOverride<(f32,)> for SpecialCase {
106
106
ctx : & CheckCtx ,
107
107
) -> Option < TestResult > {
108
108
if ctx. basis == CheckBasis :: Musl {
109
- if ctx. fn_name == "expm1f" && input. 0 > 80.0 && actual. is_infinite ( ) {
109
+ if ctx. base_name == BaseName :: Expm1 && input. 0 > 80.0 && actual. is_infinite ( ) {
110
110
// we return infinity but the number is representable
111
111
return XFAIL ;
112
112
}
113
113
114
- if ctx. fn_name == "sinhf" && input. 0 . abs ( ) > 80.0 && actual. is_nan ( ) {
114
+ if ctx. base_name == BaseName :: Sinh && input. 0 . abs ( ) > 80.0 && actual. is_nan ( ) {
115
115
// we return some NaN that should be real values or infinite
116
116
// doesn't seem to happen on x86
117
117
return XFAIL ;
118
118
}
119
119
}
120
120
121
- if ctx. fn_name == "acoshf" && input. 0 < -1.0 {
121
+ if ctx. base_name == BaseName :: Acosh && input. 0 < -1.0 {
122
122
// acoshf is undefined for x <= 1.0, but we return a random result at lower
123
123
// values.
124
124
return XFAIL ;
125
125
}
126
126
127
- if ctx. fn_name == "lgammaf" || ctx. fn_name == "lgammaf_r" && input. 0 < 0.0 {
127
+ if ctx. base_name == BaseName :: Lgamma || ctx. base_name == BaseName :: LgammaR && input. 0 < 0.0
128
+ {
128
129
// loggamma should not be defined for x < 0, yet we both return results
129
130
return XFAIL ;
130
131
}
@@ -141,7 +142,7 @@ impl MaybeOverride<(f32,)> for SpecialCase {
141
142
// On MPFR for lgammaf_r, we set -1 as the integer result for negative infinity but MPFR
142
143
// sets +1
143
144
if ctx. basis == CheckBasis :: Mpfr
144
- && ctx. fn_name == "lgammaf_r"
145
+ && ctx. base_name == BaseName :: LgammaR
145
146
&& input. 0 == f32:: NEG_INFINITY
146
147
&& actual. abs ( ) == expected. abs ( )
147
148
{
@@ -161,13 +162,13 @@ impl MaybeOverride<(f64,)> for SpecialCase {
161
162
ctx : & CheckCtx ,
162
163
) -> Option < TestResult > {
163
164
if ctx. basis == CheckBasis :: Musl {
164
- if cfg ! ( target_arch = "x86" ) && ctx. fn_name == "acosh" && input. 0 < 1.0 {
165
+ if cfg ! ( target_arch = "x86" ) && ctx. base_name == BaseName :: Acosh && input. 0 < 1.0 {
165
166
// The function is undefined, both implementations return random results
166
167
return SKIP ;
167
168
}
168
169
169
170
if cfg ! ( x86_no_sse)
170
- && ctx. fn_name == "ceil"
171
+ && ctx. base_name == BaseName :: Ceil
171
172
&& input. 0 < 0.0
172
173
&& input. 0 > -1.0
173
174
&& expected == F :: ZERO
@@ -178,13 +179,14 @@ impl MaybeOverride<(f64,)> for SpecialCase {
178
179
}
179
180
}
180
181
181
- if ctx. fn_name == "acosh" && input. 0 < 1.0 {
182
+ if ctx. base_name == BaseName :: Acosh && input. 0 < 1.0 {
182
183
// The function is undefined for the inputs, musl and our libm both return
183
184
// random results.
184
185
return XFAIL ;
185
186
}
186
187
187
- if ctx. fn_name == "lgamma" || ctx. fn_name == "lgamma_r" && input. 0 < 0.0 {
188
+ if ctx. base_name == BaseName :: Lgamma || ctx. base_name == BaseName :: LgammaR && input. 0 < 0.0
189
+ {
188
190
// loggamma should not be defined for x < 0, yet we both return results
189
191
return XFAIL ;
190
192
}
@@ -201,7 +203,7 @@ impl MaybeOverride<(f64,)> for SpecialCase {
201
203
// On MPFR for lgamma_r, we set -1 as the integer result for negative infinity but MPFR
202
204
// sets +1
203
205
if ctx. basis == CheckBasis :: Mpfr
204
- && ctx. fn_name == "lgamma_r"
206
+ && ctx. base_name == BaseName :: LgammaR
205
207
&& input. 0 == f64:: NEG_INFINITY
206
208
&& actual. abs ( ) == expected. abs ( )
207
209
{
@@ -214,7 +216,7 @@ impl MaybeOverride<(f64,)> for SpecialCase {
214
216
215
217
/// Check NaN bits if the function requires it
216
218
fn maybe_check_nan_bits < F : Float > ( actual : F , expected : F , ctx : & CheckCtx ) -> Option < TestResult > {
217
- if !( ctx. base_name_str == "fabs" || ctx. base_name_str == "copysign" ) {
219
+ if !( ctx. base_name == BaseName :: Fabs || ctx. base_name == BaseName :: Copysign ) {
218
220
return None ;
219
221
}
220
222
@@ -270,24 +272,16 @@ fn maybe_skip_binop_nan<F1: Float, F2: Float>(
270
272
expected : F2 ,
271
273
ctx : & CheckCtx ,
272
274
) -> Option < TestResult > {
273
- match ctx. basis {
274
- CheckBasis :: Musl => {
275
- if ( ctx. base_name_str == "fmax" || ctx. base_name_str == "fmin" )
276
- && ( input. 0 . is_nan ( ) || input. 1 . is_nan ( ) )
277
- && expected. is_nan ( )
278
- {
279
- XFAIL
280
- } else {
281
- None
282
- }
283
- }
284
- CheckBasis :: Mpfr => {
285
- if ctx. base_name_str == "copysign" && input. 1 . is_nan ( ) {
286
- SKIP
287
- } else {
288
- None
289
- }
275
+ match ( & ctx. basis , ctx. base_name ) {
276
+ ( Musl , BaseName :: Fmin | BaseName :: Fmax )
277
+ if ( input. 0 . is_nan ( ) || input. 1 . is_nan ( ) ) && expected. is_nan ( ) =>
278
+ {
279
+ XFAIL
290
280
}
281
+
282
+ ( Mpfr , BaseName :: Copysign ) if input. 1 . is_nan ( ) => SKIP ,
283
+
284
+ _ => None ,
291
285
}
292
286
}
293
287
@@ -299,20 +293,17 @@ impl MaybeOverride<(i32, f32)> for SpecialCase {
299
293
ulp : & mut u32 ,
300
294
ctx : & CheckCtx ,
301
295
) -> Option < TestResult > {
302
- match ctx. basis {
303
- CheckBasis :: Musl => bessel_prec_dropoff ( input, ulp, ctx) ,
304
- CheckBasis :: Mpfr => {
305
- // We return +0.0, MPFR returns -0.0
306
- if ctx. fn_name == "jnf"
307
- && input. 1 == f32:: NEG_INFINITY
308
- && actual == F :: ZERO
309
- && expected == F :: ZERO
310
- {
311
- XFAIL
312
- } else {
313
- None
314
- }
296
+ match ( & ctx. basis , ctx. base_name ) {
297
+ ( Musl , _) => bessel_prec_dropoff ( input, ulp, ctx) ,
298
+
299
+ // We return +0.0, MPFR returns -0.0
300
+ ( Mpfr , BaseName :: Jn )
301
+ if input. 1 == f32:: NEG_INFINITY && actual == F :: ZERO && expected == F :: ZERO =>
302
+ {
303
+ XFAIL
315
304
}
305
+
306
+ _ => None ,
316
307
}
317
308
}
318
309
}
@@ -324,20 +315,17 @@ impl MaybeOverride<(i32, f64)> for SpecialCase {
324
315
ulp : & mut u32 ,
325
316
ctx : & CheckCtx ,
326
317
) -> Option < TestResult > {
327
- match ctx. basis {
328
- CheckBasis :: Musl => bessel_prec_dropoff ( input, ulp, ctx) ,
329
- CheckBasis :: Mpfr => {
330
- // We return +0.0, MPFR returns -0.0
331
- if ctx. fn_name == "jn"
332
- && input. 1 == f64:: NEG_INFINITY
333
- && actual == F :: ZERO
334
- && expected == F :: ZERO
335
- {
336
- XFAIL
337
- } else {
338
- bessel_prec_dropoff ( input, ulp, ctx)
339
- }
318
+ match ( & ctx. basis , ctx. base_name ) {
319
+ ( Musl , _) => bessel_prec_dropoff ( input, ulp, ctx) ,
320
+
321
+ // We return +0.0, MPFR returns -0.0
322
+ ( Mpfr , BaseName :: Jn )
323
+ if input. 1 == f64:: NEG_INFINITY && actual == F :: ZERO && expected == F :: ZERO =>
324
+ {
325
+ XFAIL
340
326
}
327
+
328
+ _ => None ,
341
329
}
342
330
}
343
331
}
@@ -348,7 +336,7 @@ fn bessel_prec_dropoff<F: Float>(
348
336
ulp : & mut u32 ,
349
337
ctx : & CheckCtx ,
350
338
) -> Option < TestResult > {
351
- if ctx. base_name_str == "jn" {
339
+ if ctx. base_name == BaseName :: Jn {
352
340
if input. 0 > 4000 {
353
341
return XFAIL ;
354
342
} else if input. 0 > 2000 {
0 commit comments