I just started using QUnit a few days ago and I'm very happy with it so far. However, I found myself wishing that I could supply an acceptable delta value when comparing two numbers, so that 34.99999 and 35 are treated as equal if the acceptable delta passed in is anything greater than or equal to 0.00001.
Of course I could get around this by rounding the numbers that I pass to equal(), but then I lose knowledge of which numbers were truly equal, or only equal within an acceptable level of inprecision. Also it would just be more convenient if QUnit did this so I wouldn't have to clutter my tests with calls to Math.round() or num.toPrecision().
The syntax might look something like this:
- line.angle(25);
- line.rotate(10);
- var delta = 0.00001;
- equal(line.angle(), 35, "25 degs rotated +10 to 35 degs", delta);
I put together a proof-of-concept for how this might work in a fork at
https://github.com/righi/qunit/tree/close-enough . I put the code in QUnit.equal(), but it might make more sense to move the logic into QUnit.equiv() so that it can more easily be united tested itself.
I also changed the way the output is displayed so that it indicates if the test passed with the help of the delta or not:
Thanks,
Michael