@@ -5,12 +5,12 @@ fn main() {
55
66#[ cfg( feature = "test-musl-serialized" ) ]
77mod musl_reference_tests {
8- use rand:: seq:: SliceRandom ;
9- use rand:: Rng ;
10- use std:: env;
11- use std:: fs;
128 use std:: path:: PathBuf ;
139 use std:: process:: Command ;
10+ use std:: { env, fs} ;
11+
12+ use rand:: Rng ;
13+ use rand:: seq:: SliceRandom ;
1414
1515 // Number of tests to generate for each function
1616 const NTESTS : usize = 500 ;
@@ -60,10 +60,7 @@ mod musl_reference_tests {
6060 return ;
6161 }
6262
63- let files = fs:: read_dir ( math_src)
64- . unwrap ( )
65- . map ( |f| f. unwrap ( ) . path ( ) )
66- . collect :: < Vec < _ > > ( ) ;
63+ let files = fs:: read_dir ( math_src) . unwrap ( ) . map ( |f| f. unwrap ( ) . path ( ) ) . collect :: < Vec < _ > > ( ) ;
6764
6865 let mut math = Vec :: new ( ) ;
6966 for file in files {
@@ -112,12 +109,7 @@ mod musl_reference_tests {
112109 let tail = eat ( tail, " -> " ) ;
113110 let ret = parse_retty ( tail. replace ( "{" , "" ) . trim ( ) ) ;
114111
115- return Function {
116- name : name. to_string ( ) ,
117- args,
118- ret,
119- tests : Vec :: new ( ) ,
120- } ;
112+ return Function { name : name. to_string ( ) , args, ret, tests : Vec :: new ( ) } ;
121113
122114 fn parse_ty ( s : & str ) -> Ty {
123115 match s {
@@ -156,11 +148,7 @@ mod musl_reference_tests {
156148 }
157149
158150 fn generate_test < R : Rng > ( function : & Function , rng : & mut R ) -> Test {
159- let mut inputs = function
160- . args
161- . iter ( )
162- . map ( |ty| ty. gen_i64 ( rng) )
163- . collect :: < Vec < _ > > ( ) ;
151+ let mut inputs = function. args . iter ( ) . map ( |ty| ty. gen_i64 ( rng) ) . collect :: < Vec < _ > > ( ) ;
164152
165153 // First argument to this function appears to be a number of
166154 // iterations, so passing in massive random numbers causes it to
@@ -180,25 +168,20 @@ mod musl_reference_tests {
180168
181169 impl Ty {
182170 fn gen_i64 < R : Rng > ( & self , r : & mut R ) -> i64 {
183- use std:: f32;
184- use std:: f64;
171+ use std:: { f32, f64} ;
185172
186173 return match self {
187174 Ty :: F32 => {
188175 if r. gen_range ( 0 ..20 ) < 1 {
189- let i = * [ f32:: NAN , f32:: INFINITY , f32:: NEG_INFINITY ]
190- . choose ( r)
191- . unwrap ( ) ;
176+ let i = * [ f32:: NAN , f32:: INFINITY , f32:: NEG_INFINITY ] . choose ( r) . unwrap ( ) ;
192177 i. to_bits ( ) . into ( )
193178 } else {
194179 r. gen :: < f32 > ( ) . to_bits ( ) . into ( )
195180 }
196181 }
197182 Ty :: F64 => {
198183 if r. gen_range ( 0 ..20 ) < 1 {
199- let i = * [ f64:: NAN , f64:: INFINITY , f64:: NEG_INFINITY ]
200- . choose ( r)
201- . unwrap ( ) ;
184+ let i = * [ f64:: NAN , f64:: INFINITY , f64:: NEG_INFINITY ] . choose ( r) . unwrap ( ) ;
202185 i. to_bits ( ) as i64
203186 } else {
204187 r. gen :: < f64 > ( ) . to_bits ( ) as i64
@@ -424,11 +407,7 @@ mod musl_reference_tests {
424407 src. push_str ( ");" ) ;
425408
426409 for ( i, ret) in function. ret . iter ( ) . enumerate ( ) {
427- let get = if function. ret . len ( ) == 1 {
428- String :: new ( )
429- } else {
430- format ! ( ".{}" , i)
431- } ;
410+ let get = if function. ret . len ( ) == 1 { String :: new ( ) } else { format ! ( ".{}" , i) } ;
432411 src. push_str ( & ( match ret {
433412 Ty :: F32 => format ! ( "if libm::_eqf(output{}, f32::from_bits(expected[{}] as u32)).is_ok() {{ continue }}" , get, i) ,
434413 Ty :: F64 => format ! ( "if libm::_eq(output{}, f64::from_bits(expected[{}] as u64)).is_ok() {{ continue }}" , get, i) ,
0 commit comments