@@ -18,7 +18,7 @@ macro_rules! assert_approx_eq {
18
18
/// Verify that floats have the same bitwise representation. Used to avoid the default `0.0 == -0.0`
19
19
/// behavior, as well as to ensure exact NaN bitpatterns.
20
20
macro_rules! assert_biteq {
21
- ( $left: expr, $right: expr, $( $tt: tt) * ) => { {
21
+ ( @inner $left: expr, $right: expr, $msg_sep : literal , $( $tt: tt) * ) => { {
22
22
let l = $left;
23
23
let r = $right;
24
24
@@ -28,11 +28,11 @@ macro_rules! assert_biteq {
28
28
29
29
// Hack to get the width from a value
30
30
let bits = ( l. to_bits( ) - l. to_bits( ) ) . leading_zeros( ) ;
31
- let nl = if stringify!( $( $tt) * ) . is_empty( ) { "" } else { "\n " } ;
32
31
assert!(
33
32
l. to_bits( ) == r. to_bits( ) ,
34
33
"{msg}{nl}l: {l:?} ({lb:#0width$x})\n r: {r:?} ({rb:#0width$x})" ,
35
34
msg = format_args!( $( $tt) * ) ,
35
+ nl = $msg_sep,
36
36
lb = l. to_bits( ) ,
37
37
rb = r. to_bits( ) ,
38
38
width = ( ( bits / 4 ) + 2 ) as usize ,
@@ -44,8 +44,11 @@ macro_rules! assert_biteq {
44
44
assert_eq!( l, r)
45
45
}
46
46
} } ;
47
+ ( $left: expr, $right: expr , $( $tt: tt) * ) => {
48
+ assert_biteq!( @inner $left, $right, "\n " , $( $tt) * )
49
+ } ;
47
50
( $left: expr, $right: expr $( , ) ?) => {
48
- assert_biteq!( $left, $right, "" )
51
+ assert_biteq!( @inner $left, $right, "" , "" )
49
52
} ;
50
53
}
51
54
0 commit comments