commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / bower_components / qunit / addons / close-enough / qunit-close-enough.js
1 QUnit.extend( QUnit, {
2 /**
3 * Checks that the first two arguments are equal, or are numbers close enough to be considered equal
4 * based on a specified maximum allowable difference.
5 *
6 * @example close(3.141, Math.PI, 0.001);
7 *
8 * @param Number actual
9 * @param Number expected
10 * @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)
11 * @param String message (optional)
12 */
13 close: function(actual, expected, maxDifference, message) {
14 var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference;
15 QUnit.push(passes, actual, expected, message);
16 },
17
18 /**
19 * Checks that the first two arguments are numbers with differences greater than the specified
20 * minimum difference.
21 *
22 * @example notClose(3.1, Math.PI, 0.001);
23 *
24 * @param Number actual
25 * @param Number expected
26 * @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)
27 * @param String message (optional)
28 */
29 notClose: function(actual, expected, minDifference, message) {
30 QUnit.push(Math.abs(actual - expected) > minDifference, actual, expected, message);
31 }
32 });