-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assert_approx_eq
macro for nicer testing
#352
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool stuff!
Can you use the new macro in https://github.com/CosmWasm/wasmvm/blob/v1.1.0/libwasmvm/src/cache.rs#L714-L722?
libwasmvm/src/test_utils.rs
Outdated
let smallest = std::cmp::min(left, right); | ||
let rel_diff = Decimal::from_ratio(largest - smallest, largest); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't that the same as this?
let smallest = std::cmp::min(left, right); | |
let rel_diff = Decimal::from_ratio(largest - smallest, largest); | |
let rel_diff = Decimal::from_ratio(left.abs_diff(right), largest); |
The suggestion would be coser to to formula from Wikipedia
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does abs_diff
come from? These types don't have that method that I've seen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bautiful!
Only open wish is using this in https://github.com/CosmWasm/wasmvm/blob/v1.1.0/libwasmvm/src/cache.rs#L714-L722.
Rebase since I wasn't working on the up-to-date |
e823043
to
9f9542a
Compare
9f9542a
to
c276a8e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🏅
No description provided.