Change toBeCloseTo matcher to be more consistent.
It now calculates and compares a difference, rather than rounding two separate quantities and testing for their equality.
This commit is contained in:
@@ -302,10 +302,7 @@ jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
|
||||
if (!(precision === 0)) {
|
||||
precision = precision || 2;
|
||||
}
|
||||
var multiplier = Math.pow(10, precision);
|
||||
var actual = Math.round(this.actual * multiplier);
|
||||
expected = Math.round(expected * multiplier);
|
||||
return expected == actual;
|
||||
return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,5 +3,5 @@ jasmine.version_= {
|
||||
"major": 1,
|
||||
"minor": 2,
|
||||
"build": 0,
|
||||
"revision": 1337006083
|
||||
"revision": 1343710612
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user