Sha256: 1e4b82ef0c1fd6e344002796ee9f67f6170524013039ddc821dd4e29978c61cf

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

QUnit.extend( QUnit, {
	/**
	 * Checks that the first two arguments are equal, or are numbers close enough to be considered equal
	 * based on a specified maximum allowable difference.
	 *
	 * @example close(3.141, Math.PI, 0.001);
	 *
	 * @param Number actual
	 * @param Number expected
	 * @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)
	 * @param String message (optional)
	 */
	close: function(actual, expected, maxDifference, message) {
		var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference;
		QUnit.push(passes, actual, expected, message);
	},
	
	/**
	 * Checks that the first two arguments are numbers with differences greater than the specified 
	 * minimum difference.
	 *
	 * @example notClose(3.1, Math.PI, 0.001);
	 *
	 * @param Number actual
	 * @param Number expected
	 * @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)
	 * @param String message (optional)
	 */
	notClose: function(actual, expected, minDifference, message) {
		QUnit.push(Math.abs(actual - expected) > minDifference, actual, expected, message);
	}
});

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
sprockets-browserify-0.3.0 node_modules/browserify/node_modules/url/node_modules/punycode/vendor/qunit/addons/close-enough/qunit-close-enough.js
everqueen-1.1.1 lib/qunit/addons/close-enough/qunit-close-enough.js
everqueen-1.1.0 lib/qunit/addons/close-enough/qunit-close-enough.js
everqueen-1.0.1 lib/qunit/addons/close-enough/qunit-close-enough.js