Automattic / expect.js

Minimalistic BDD-style assertions for Node.JS and the browser.
2.11k stars 209 forks source link

Approximate floating point value #83

Open skeggse opened 10 years ago

skeggse commented 10 years ago

Expect.js currently does not support ensuring a floating point number approximates another number within a certain accuracy. Proposed usage:

expect(0.99999).to.approximate(0.99998, 4); // works
expect(0.99999).to.approximate(0.99998, 5); // fails
expect(0.999999).to.approximate(0.999998, 5); // works
expect(0.999999).to.approximate(0.999998, 6); // fails