Skip to content

Commit 7de59e6

Browse files
committed
fixup! float: Use a shared assert_biteq! macro for tests
1 parent d752721 commit 7de59e6

File tree

1 file changed

+6
-3
lines changed
  • library/coretests/tests/floats

1 file changed

+6
-3
lines changed

library/coretests/tests/floats/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ macro_rules! assert_approx_eq {
1818
/// Verify that floats have the same bitwise representation. Used to avoid the default `0.0 == -0.0`
1919
/// behavior, as well as to ensure exact NaN bitpatterns.
2020
macro_rules! assert_biteq {
21-
($left:expr, $right:expr, $($tt:tt)*) => {{
21+
(@inner $left:expr, $right:expr, $msg_sep:literal, $($tt:tt)*) => {{
2222
let l = $left;
2323
let r = $right;
2424

@@ -28,11 +28,11 @@ macro_rules! assert_biteq {
2828

2929
// Hack to get the width from a value
3030
let bits = (l.to_bits() - l.to_bits()).leading_zeros();
31-
let nl = if stringify!($($tt)*).is_empty() { "" } else { "\n" };
3231
assert!(
3332
l.to_bits() == r.to_bits(),
3433
"{msg}{nl}l: {l:?} ({lb:#0width$x})\nr: {r:?} ({rb:#0width$x})",
3534
msg = format_args!($($tt)*),
35+
nl = $msg_sep,
3636
lb = l.to_bits(),
3737
rb = r.to_bits(),
3838
width = ((bits / 4) + 2) as usize,
@@ -44,8 +44,11 @@ macro_rules! assert_biteq {
4444
assert_eq!(l, r)
4545
}
4646
}};
47+
($left:expr, $right:expr , $($tt:tt)*) => {
48+
assert_biteq!(@inner $left, $right, "\n", $($tt)*)
49+
};
4750
($left:expr, $right:expr $(,)?) => {
48-
assert_biteq!($left, $right, "")
51+
assert_biteq!(@inner $left, $right, "", "")
4952
};
5053
}
5154

0 commit comments

Comments
 (0)