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

[NFC/Unit Test] - Help avoid problems when using assertApproxEquals with integers instead of fractions #20089

Merged
merged 1 commit into from
Apr 17, 2021

Conversation

demeritcowboy
Copy link
Contributor

Overview

Pick up my guitar and play
Just like yesterday
Then I'll get on my knees and pray
We don't get fooled again

This makes your test fail if you pass integers into assertApproxEquals with a threshold of 1. It's come up twice that I know of. It gives you a helpful message to use a bigger number, such as 2, or 5.

Before

Kinda

After

Sorta

Technical Details

Integers-first is how humans think, not fractions as do Alpha-Centaurans, or complex numbers as do humpback whales (source: Star Trek IV). But the approxEquals function is a fractions-first thinking function, where a threshold of 1 when applied to integers means they need to be identical.

Fool me once shame on you. Fool me ... can't get fooled again.

Comments

Is test

@seamuslee001

@civibot
Copy link

civibot bot commented Apr 17, 2021

(Standard links)

@civibot civibot bot added the master label Apr 17, 2021
@totten
Copy link
Member

totten commented Apr 17, 2021

@seamuslee001 seamuslee001 merged commit ac37a7c into civicrm:master Apr 17, 2021
@demeritcowboy demeritcowboy deleted the approx branch April 18, 2021 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants