Since we want the user to be able to pass a negative comparison function, the extra layer of wrapping is now needed
19 lines
376 B
JavaScript
19 lines
376 B
JavaScript
getJasmineRequireObj().toBeCloseTo = function() {
|
|
|
|
function toBeCloseTo() {
|
|
return {
|
|
compare: function(actual, expected, precision) {
|
|
if (precision !== 0) {
|
|
precision = precision || 2;
|
|
}
|
|
|
|
return {
|
|
pass: Math.abs(expected - actual) < (Math.pow(10, -precision) / 2)
|
|
};
|
|
}
|
|
};
|
|
}
|
|
|
|
return toBeCloseTo;
|
|
};
|