Skip to content

Commit

Permalink
replace a macro by a function
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Jul 14, 2022
1 parent 820f322 commit 07c3e42
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions tests/pass/weak_memory/weak.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn seq_cst() -> bool {

fn initialization_write() -> bool {
let x = static_atomic(11);
assert_eq!(x.load(Relaxed), 11);
assert_eq!(x.load(Relaxed), 11); // work around https://github.com/rust-lang/miri/issues/2164

let wait = static_atomic(0);

Expand All @@ -94,15 +94,13 @@ fn initialization_write() -> bool {
r2 == 11
}

// Asserts that the function returns true at least once in 100 runs
macro_rules! assert_once {
($f:ident) => {
assert!(std::iter::repeat_with(|| $f()).take(100).any(|x| x));
};
/// Asserts that the function returns true at least once in 100 runs
fn assert_once(f: fn() -> bool) {
assert!(std::iter::repeat_with(|| f()).take(100).any(|x| x));
}

pub fn main() {
assert_once!(relaxed);
assert_once!(seq_cst);
assert_once!(initialization_write);
assert_once(relaxed);
assert_once(seq_cst);
assert_once(initialization_write);
}

0 comments on commit 07c3e42

Please sign in to comment.