First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
17
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/README.md
vendored
Normal file
17
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/README.md
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
Close-Enough - A QUnit Addon For Number Approximations
|
||||
================================
|
||||
|
||||
This addon for QUnit adds close and notClose assertion methods, to test that
|
||||
numbers are close enough (or different enough) from an expected number, with
|
||||
a specified accuracy.
|
||||
|
||||
Usage:
|
||||
|
||||
close(actual, expected, maxDifference, message)
|
||||
notClose(actual, expected, minDifference, message)
|
||||
|
||||
Where:
|
||||
|
||||
* maxDifference: the maximum inclusive difference allowed between the actual and expected numbers
|
||||
* minDifference: the minimum exclusive difference allowed between the actual and expected numbers
|
||||
* actual, expected, message: The usual
|
35
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/close-enough-test.js
vendored
Normal file
35
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/close-enough-test.js
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
test("Close Numbers", function () {
|
||||
var halfPi = Math.PI / 2,
|
||||
sqrt2 = Math.sqrt(2);
|
||||
|
||||
QUnit.close(7, 7, 0);
|
||||
QUnit.close(7, 7.1, 0.1);
|
||||
QUnit.close(7, 7.1, 0.2);
|
||||
|
||||
QUnit.close(3.141, Math.PI, 0.001);
|
||||
QUnit.close(3.1, Math.PI, 0.1);
|
||||
|
||||
QUnit.close(halfPi, 1.57, 0.001);
|
||||
|
||||
QUnit.close(sqrt2, 1.4142, 0.0001);
|
||||
|
||||
QUnit.close(Infinity, Infinity, 1);
|
||||
});
|
||||
|
||||
test("Distant Numbers", function () {
|
||||
var halfPi = Math.PI / 2,
|
||||
sqrt2 = Math.sqrt(2);
|
||||
|
||||
QUnit.notClose(6, 7, 0);
|
||||
QUnit.notClose(7, 7.2, 0.1);
|
||||
QUnit.notClose(7, 7.2, 0.19999999999);
|
||||
|
||||
QUnit.notClose(3.141, Math.PI, 0.0001);
|
||||
QUnit.notClose(3.1, Math.PI, 0.001);
|
||||
|
||||
QUnit.notClose(halfPi, 1.57, 0.0001);
|
||||
|
||||
QUnit.notClose(sqrt2, 1.4142, 0.00001);
|
||||
|
||||
QUnit.notClose(Infinity, -Infinity, 5);
|
||||
});
|
14
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/close-enough.html
vendored
Normal file
14
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/close-enough.html
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Test Suite - Close Enough Addon</title>
|
||||
<link rel="stylesheet" href="../../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="qunit-close-enough.js"></script>
|
||||
<script type="text/javascript" src="close-enough-test.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit"></div>
|
||||
</body>
|
||||
</html>
|
32
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/qunit-close-enough.js
vendored
Normal file
32
sites/all/modules/civicrm/bower_components/qunit/addons/close-enough/qunit-close-enough.js
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
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);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue