This is just an idea / feature request, it's totally fine to close the issue if it does not spark any interest.
Currently check_determinism verifies that the randomness state after running the input function twice is the same.
If the input function is truly deterministic, it must return the same result.
Here is how I currently check that a function is deterministic:
#[test]
fn ulid_generation_should_be_deterministic() {
let mut builder_a = madsim::runtime::Builder::from_env();
builder_a.check = true;
let mut builder_b = madsim::runtime::Builder::from_env(); // Builder: Clone would be useful
builder_b.check = true;
builder_b.seed = builder_a.seed;
assert_eq!(
builder_a.run(|| async { ulid::Ulid::new() }),
builder_b.run(|| async { ulid::Ulid::new() })
);
}
It would be nice to have less boilerplate, given that the function returns a value implementing Debug and PartialEq
This is just an idea / feature request, it's totally fine to close the issue if it does not spark any interest.
Currently
check_determinismverifies that the randomness state after running the input function twice is the same.If the input function is truly deterministic, it must return the same result.
Here is how I currently check that a function is deterministic:
It would be nice to have less boilerplate, given that the function returns a value implementing
DebugandPartialEq