From 4dedf7d555b6476f6fa6e83f3b7d3e97e054982b Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Sat, 13 Aug 2022 11:42:46 +0200 Subject: [PATCH] Remove duplicated `#[cfg(test)]` conditions Several macros used in tests had `#[cfg(test)]` condition on each of them. This deduplicates them by putting them into a separate module and reexporting (with one condition for module and one for re-export). --- src/internal_macros.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/internal_macros.rs b/src/internal_macros.rs index ece0f0f6..288de32a 100644 --- a/src/internal_macros.rs +++ b/src/internal_macros.rs @@ -119,19 +119,19 @@ macro_rules! debug_from_display { pub(crate) use debug_from_display; #[cfg(test)] -macro_rules! hex_script (($s:expr) => (<$crate::Script as core::str::FromStr>::from_str($s).unwrap())); -#[cfg(test)] -pub(crate) use hex_script; +pub(crate) use test_macros::*; #[cfg(test)] -macro_rules! hex_hash (($h:ident, $s:expr) => ($h::from_slice(&<$crate::prelude::Vec as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap())); -#[cfg(test)] -pub(crate) use hex_hash; +mod test_macros { + macro_rules! hex_script (($s:expr) => (<$crate::Script as core::str::FromStr>::from_str($s).unwrap())); + pub(crate) use hex_script; -#[cfg(test)] -macro_rules! hex_decode (($h:ident, $s:expr) => (deserialize::<$h>(&<$crate::prelude::Vec as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap())); -#[cfg(test)] -pub(crate) use hex_decode; + macro_rules! hex_hash (($h:ident, $s:expr) => ($h::from_slice(&<$crate::prelude::Vec as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap())); + pub(crate) use hex_hash; + + macro_rules! hex_decode (($h:ident, $s:expr) => (deserialize::<$h>(&<$crate::prelude::Vec as $crate::hashes::hex::FromHex>::from_hex($s).unwrap()).unwrap())); + pub(crate) use hex_decode; +} macro_rules! serde_string_impl { ($name:ident, $expecting:literal) => {