diff --git a/src/tests/helper.rs b/src/tests/helper.rs index 53d54111..2f6d8752 100644 --- a/src/tests/helper.rs +++ b/src/tests/helper.rs @@ -1427,11 +1427,23 @@ macro_rules! __test_atomic_ptr { }; } -macro_rules! __test_atomic_int_load_store_pub { +macro_rules! __test_atomic_int_pub { ($atomic_type:ty, $int_type:ident) => { __test_atomic_pub_common!($atomic_type, $int_type); use std::{boxed::Box, mem}; #[test] + fn fetch_update() { + let a = <$atomic_type>::new(7); + test_compare_exchange_ordering(|set, fetch| a.fetch_update(set, fetch, |x| Some(x))); + for &(success, failure) in &test_helper::COMPARE_EXCHANGE_ORDERINGS { + let a = <$atomic_type>::new(7); + assert_eq!(a.fetch_update(success, failure, |_| None), Err(7)); + assert_eq!(a.fetch_update(success, failure, |x| Some(x + 1)), Ok(7)); + assert_eq!(a.fetch_update(success, failure, |x| Some(x + 1)), Ok(8)); + assert_eq!(a.load(Ordering::SeqCst), 9); + } + } + #[test] fn impls() { #[cfg(not(portable_atomic_no_const_transmute))] const _: $int_type = { @@ -1456,22 +1468,6 @@ macro_rules! __test_atomic_int_load_store_pub { drop(Box::from_raw(ptr)); } } - }; -} -macro_rules! __test_atomic_int_pub { - ($atomic_type:ty, $int_type:ident) => { - #[test] - fn fetch_update() { - let a = <$atomic_type>::new(7); - test_compare_exchange_ordering(|set, fetch| a.fetch_update(set, fetch, |x| Some(x))); - for &(success, failure) in &test_helper::COMPARE_EXCHANGE_ORDERINGS { - let a = <$atomic_type>::new(7); - assert_eq!(a.fetch_update(success, failure, |_| None), Err(7)); - assert_eq!(a.fetch_update(success, failure, |x| Some(x + 1)), Ok(7)); - assert_eq!(a.fetch_update(success, failure, |x| Some(x + 1)), Ok(8)); - assert_eq!(a.load(Ordering::SeqCst), 9); - } - } ::quickcheck::quickcheck! { fn quickcheck_fetch_update(x: $int_type, y: $int_type) -> bool { let z = loop { @@ -1823,20 +1819,6 @@ macro_rules! test_atomic_int_load_store { } }; } -macro_rules! test_atomic_bool_load_store { - () => { - #[allow( - clippy::alloc_instead_of_core, - clippy::std_instead_of_alloc, - clippy::std_instead_of_core, - clippy::undocumented_unsafe_blocks - )] - mod test_atomic_bool { - use super::*; - __test_atomic_bool_load_store!(AtomicBool); - } - }; -} macro_rules! test_atomic_ptr_load_store { () => { #[allow( @@ -1869,21 +1851,6 @@ macro_rules! test_atomic_int_single_thread { } }; } -macro_rules! test_atomic_bool_single_thread { - () => { - #[allow( - clippy::alloc_instead_of_core, - clippy::std_instead_of_alloc, - clippy::std_instead_of_core, - clippy::undocumented_unsafe_blocks - )] - mod test_atomic_bool { - use super::*; - __test_atomic_bool_load_store!(AtomicBool, single_thread); - __test_atomic_bool!(AtomicBool, single_thread); - } - }; -} macro_rules! test_atomic_ptr_single_thread { () => { #[allow( @@ -1917,21 +1884,6 @@ macro_rules! test_atomic_int { } }; } -macro_rules! test_atomic_bool { - () => { - #[allow( - clippy::alloc_instead_of_core, - clippy::std_instead_of_alloc, - clippy::std_instead_of_core, - clippy::undocumented_unsafe_blocks - )] - mod test_atomic_bool { - use super::*; - __test_atomic_bool_load_store!(AtomicBool); - __test_atomic_bool!(AtomicBool); - } - }; -} macro_rules! test_atomic_ptr { () => { #[allow( @@ -1962,29 +1914,11 @@ macro_rules! test_atomic_int_pub { use super::*; __test_atomic_int_load_store!([], $int_type); __test_atomic_int!([], $int_type); - __test_atomic_int_load_store_pub!([], $int_type); __test_atomic_int_pub!([], $int_type); } } }; } -macro_rules! test_atomic_int_load_store_pub { - ($int_type:ident) => { - paste::paste! { - #[allow( - clippy::alloc_instead_of_core, - clippy::std_instead_of_alloc, - clippy::std_instead_of_core, - clippy::undocumented_unsafe_blocks - )] - mod [] { - use super::*; - __test_atomic_int_load_store!([], $int_type); - __test_atomic_int_load_store_pub!([], $int_type); - } - } - }; -} #[cfg(feature = "float")] macro_rules! test_atomic_float_pub { ($float_type:ident) => {