Move roughlyEqual into expect.js

This commit is contained in:
Tom Payne
2013-03-14 23:55:25 +01:00
parent bddaecbe69
commit 62011dab28
3 changed files with 61 additions and 5 deletions
+18
View File
@@ -299,6 +299,24 @@
return this;
};
/**
* Assert value is within _tol_ of _n_.
*
* @param {Number} n
* @param {Number} tol
*
* @api public
*/
Assertion.prototype.roughlyEqual =
Assertion.prototype.kindaEqual = function(n, tol) {
this.assert(
Math.abs(this.obj - n) <= tol
, function(){ return 'expected ' + i(this.obj) + ' to be within ' + tol + ' of ' + n }
, function(){ return 'expected ' + i(this.obj) + ' not to be within ' + tol + ' of ' + n });
return this;
};
/**
* Assert string value matches _regexp_.
*