Closed Bug 937678 Opened 12 years ago Closed 12 years ago

Add isfuzzy to mochitest framework

Categories

(Testing :: Mochitest, defect)

x86_64
Windows 8
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla28

People

(Reporter: bas.schouten, Assigned: bas.schouten)

References

Details

Attachments

(1 file, 1 obsolete file)

It would be useful to be able to do a fuzzy comparison using the mochitest framework, this would floating point comparisons to be done with an epsilon more easily.
Attachment #830887 - Flags: review?(jmaher)
Comment on attachment 830887 [details] [diff] [review] Add an isfuzzy comparison function to mochitest Review of attachment 830887 [details] [diff] [review]: ----------------------------------------------------------------- simple! ::: testing/mochitest/tests/SimpleTest/SimpleTest.js @@ +246,5 @@ > }; > > +SimpleTest.isfuzzy = function (a, b, epsilon, name) { > + var pass = (a > b - epsilon) && (a < b + epsilon); > + var diag = pass ? "" : "got " + repr(a) + ", expected " + repr(b) + " epsilon: " + repr(epsilon) could we add a +- to the epsilon text?
Attachment #830887 - Flags: review?(jmaher) → review+
Addressed review comment and added the required global. Carrying r+.
Attachment #830887 - Attachment is obsolete: true
Attachment #831156 - Flags: review+
Blocks: 937994
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: