Move roughlyEqual into expect.js
This commit is contained in:
@@ -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_.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user