@@ -28,10 +28,8 @@ mod musl_reference_tests {
2828 // defining a function we want to test.
2929 const IGNORED_FILES : & [ & str ] = & [
3030 "fenv.rs" ,
31- "sincos.rs" , // more than 1 result
32- "sincosf.rs" , // more than 1 result
33- "jn.rs" , // passed, but very slow
34- "jnf.rs" , // passed, but very slow
31+ "jn.rs" , // passed, but very slow
32+ "jnf.rs" , // passed, but very slow
3533 ] ;
3634
3735 struct Function {
@@ -228,14 +226,22 @@ mod musl_reference_tests {
228226 src. push_str ( "extern { fn " ) ;
229227 src. push_str ( & function. name ) ;
230228 src. push_str ( "(" ) ;
229+
230+ let ( ret, retptr) = match function. name . as_str ( ) {
231+ "sincos" | "sincosf" => ( None , & function. ret [ ..] ) ,
232+ _ => ( Some ( & function. ret [ 0 ] ) , & function. ret [ 1 ..] ) ,
233+ } ;
231234 for ( i, arg) in function. args . iter ( ) . enumerate ( ) {
232235 src. push_str ( & format ! ( "arg{}: {}," , i, arg. libc_ty( ) ) ) ;
233236 }
234- for ( i, ret) in function . ret . iter ( ) . skip ( 1 ) . enumerate ( ) {
237+ for ( i, ret) in retptr . iter ( ) . enumerate ( ) {
235238 src. push_str ( & format ! ( "argret{}: {}," , i, ret. libc_pty( ) ) ) ;
236239 }
237- src. push_str ( ") -> " ) ;
238- src. push_str ( function. ret [ 0 ] . libc_ty ( ) ) ;
240+ src. push_str ( ")" ) ;
241+ if let Some ( ty) = ret {
242+ src. push_str ( " -> " ) ;
243+ src. push_str ( ty. libc_ty ( ) ) ;
244+ }
239245 src. push_str ( "; }" ) ;
240246
241247 src. push_str ( & format ! ( "static TESTS: &[[i64; {}]]" , function. args. len( ) ) ) ;
@@ -251,13 +257,8 @@ mod musl_reference_tests {
251257 src. push_str ( "];" ) ;
252258
253259 src. push_str ( "for test in TESTS {" ) ;
254- for ( i, arg) in function . ret . iter ( ) . skip ( 1 ) . enumerate ( ) {
260+ for ( i, arg) in retptr . iter ( ) . enumerate ( ) {
255261 src. push_str ( & format ! ( "let mut argret{} = {};" , i, arg. default ( ) ) ) ;
256- src. push_str ( & format ! (
257- "let argret_ptr{0} = &mut argret{0} as *mut {1};" ,
258- i,
259- arg. libc_ty( )
260- ) ) ;
261262 }
262263 src. push_str ( "let output = " ) ;
263264 src. push_str ( & function. name ) ;
@@ -271,18 +272,20 @@ mod musl_reference_tests {
271272 } ) ;
272273 src. push_str ( "," ) ;
273274 }
274- for ( i, _) in function . ret . iter ( ) . skip ( 1 ) . enumerate ( ) {
275- src. push_str ( & format ! ( "argret_ptr {}," , i) ) ;
275+ for ( i, _) in retptr . iter ( ) . enumerate ( ) {
276+ src. push_str ( & format ! ( "&mut argret {}," , i) ) ;
276277 }
277278 src. push_str ( ");" ) ;
278- src. push_str ( & format ! ( "let output = output{};" , function. ret[ 0 ] . to_i64( ) ) ) ;
279- src. push_str ( "result.extend_from_slice(&output.to_le_bytes());" ) ;
279+ if let Some ( ty) = & ret {
280+ src. push_str ( & format ! ( "let output = output{};" , ty. to_i64( ) ) ) ;
281+ src. push_str ( "result.extend_from_slice(&output.to_le_bytes());" ) ;
282+ }
280283
281- for ( i, ret) in function. ret . iter ( ) . skip ( 1 ) . enumerate ( ) {
282- src. push_str ( & format ! ( "let output{0} = argret{0}{1};" , i, ret. to_i64( ) ) ) ;
284+ for ( i, ret) in retptr. iter ( ) . enumerate ( ) {
283285 src. push_str ( & format ! (
284- "result.extend_from_slice(&output{}.to_le_bytes());" ,
285- i
286+ "result.extend_from_slice(&(argret{}{}).to_le_bytes());" ,
287+ i,
288+ ret. to_i64( ) ,
286289 ) ) ;
287290 }
288291 src. push_str ( "}" ) ;
@@ -323,10 +326,7 @@ mod musl_reference_tests {
323326
324327 for f in functions. iter_mut ( ) {
325328 for test in f. tests . iter_mut ( ) {
326- test. outputs = vec ! [ results. next( ) . unwrap( ) ] ;
327- for _ in f. ret . iter ( ) . skip ( 1 ) {
328- test. outputs . push ( results. next ( ) . unwrap ( ) ) ;
329- }
329+ test. outputs = ( 0 ..f. ret . len ( ) ) . map ( |_| results. next ( ) . unwrap ( ) ) . collect ( ) ;
330330 }
331331 }
332332 assert ! ( results. next( ) . is_none( ) ) ;
@@ -380,26 +380,19 @@ mod musl_reference_tests {
380380 src. push_str ( "," ) ;
381381 }
382382 src. push_str ( ");" ) ;
383- if function. ret . len ( ) > 1 {
384- for ( i, ret) in function. ret . iter ( ) . enumerate ( ) {
385- src. push_str ( & ( match ret {
386- Ty :: F32 => format ! ( "if _eqf(output.{0}, f32::from_bits(expected[{0}] as u32)).is_ok() {{ continue }}" , i) ,
387- Ty :: F64 => format ! ( "if _eq(output.{0}, f64::from_bits(expected[{0}] as u64)).is_ok() {{ continue }}" , i) ,
388- Ty :: I32 => format ! ( "if output.{0} as i64 == expected[{0}] {{ continue }}" , i) ,
389- Ty :: Bool => unreachable ! ( ) ,
390- } ) ) ;
391- }
392- } else {
393- src. push_str ( match function. ret [ 0 ] {
394- Ty :: F32 => {
395- "if _eqf(output, f32::from_bits(expected[0] as u32)).is_ok() { continue }"
396- }
397- Ty :: F64 => {
398- "if _eq(output, f64::from_bits(expected[0] as u64)).is_ok() { continue }"
399- }
400- Ty :: I32 => "if output as i64 == expected[0] { continue }" ,
383+
384+ for ( i, ret) in function. ret . iter ( ) . enumerate ( ) {
385+ let get = if function. ret . len ( ) == 1 {
386+ String :: new ( )
387+ } else {
388+ format ! ( ".{}" , i)
389+ } ;
390+ src. push_str ( & ( match ret {
391+ Ty :: F32 => format ! ( "if _eqf(output{}, f32::from_bits(expected[{}] as u32)).is_ok() {{ continue }}" , get, i) ,
392+ Ty :: F64 => format ! ( "if _eq(output{}, f64::from_bits(expected[{}] as u64)).is_ok() {{ continue }}" , get, i) ,
393+ Ty :: I32 => format ! ( "if output{} as i64 == expected[{}] {{ continue }}" , get, i) ,
401394 Ty :: Bool => unreachable ! ( ) ,
402- } ) ;
395+ } ) ) ;
403396 }
404397
405398 src. push_str (
0 commit comments