Skip to content
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

Merged
merged 9 commits into from Sep 7, 2022
Merged

Conversation

uint
Copy link
Contributor

@uint uint commented Sep 6, 2022

No description provided.

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

libwasmvm/src/test_utils.rs Outdated Show resolved Hide resolved
libwasmvm/src/test_utils.rs Outdated Show resolved Hide resolved
libwasmvm/src/test_utils.rs Show resolved Hide resolved
libwasmvm/src/test_utils.rs Outdated Show resolved Hide resolved
Comment on lines 38 to 39
let smallest = std::cmp::min(left, right);
let rel_diff = Decimal::from_ratio(largest - smallest, largest);
Copy link
Member

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?

Suggested change
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

Copy link
Contributor Author

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uint
Copy link
Contributor Author

uint commented Sep 7, 2022

Rebase since I wasn't working on the up-to-date main apparently

Copy link
Member

@webmaster128 webmaster128 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants