[Gambas-bugtracker] Bug #1851: gb.test Assert.Approximate is wrong

bugtracker at gambaswiki.org bugtracker at gambaswiki.org
Mon Aug 3 22:07:01 CEST 2020


http://gambaswiki.org/bugtracker/edit?object=BUG.1851&from=L21haW4-

Comment #1 by Tobias BOEGE:

I think the two assertions in your project produce the correct output.
Do you perhaps misunderstand what Approximate does?

Approximate(Got, Expected, Precision) succeeds when the distance between
Got and Expected (that is Abs(Got - Expected)) is at most Precision.
You want to test whether Got and Expected are Precision-close to each other.
This is what the code does and it entails:

  - Approximate(5, 10, 0.1): 5 and 10 are further apart than 0.1 so fails,
  - Approximate(5, 1, 5): 5 and 1 are 4 units apart which is less than 5, so succeeds.

I agree that the note on failure could be customized for Approximate and
RelativeApproximate (showing the Got and Expected values, their error and
the needed precision), but the comparison is working as intended.

Tobias BOEGE changed the state of the bug to: Rejected.




More information about the Bugtracker mailing list