Permalink
Browse files

fix for assert.close and use assert.close for 0 case in jstests/geob.js

  • Loading branch information...
1 parent 3ddfaa4 commit d6e3981dc7286a34c8f1030c0dde7c1e2b087abc Mike Dirolf committed Mar 22, 2010
Showing with 5 additions and 2 deletions.
  1. +2 −2 jstests/geob.js
  2. +3 −0 shell/utils.js
View
@@ -15,7 +15,7 @@ t.ensureIndex({p: "2d"});
var res = t.runCommand("geoNear", {near: [0,0]});
assert.close(3, res.stats.avgDistance, "A");
-assert.eq(0, res.results[0].dis, "B1");
+assert.close(0, res.results[0].dis, "B1");
assert.eq(a._id, res.results[0].obj._id, "B2");
assert.close(1, res.results[1].dis, "C1");
@@ -29,7 +29,7 @@ assert.eq(d._id, res.results[3].obj._id, "E2");
res = t.runCommand("geoNear", {near: [0,0], distanceMultiplier: 2});
assert.close(6, res.stats.avgDistance, "F");
-assert.eq(0, res.results[0].dis, "G");
+assert.close(0, res.results[0].dis, "G");
assert.close(2, res.results[1].dis, "H");
assert.close(10, res.results[2].dis, "I");
assert.close(12, res.results[3].dis, "J");
View
@@ -133,6 +133,9 @@ assert.gt = function( a , b , msg ){
}
assert.close = function( a , b , msg ){
+ if (a === 0 && b === 0) {
+ return;
+ }
var diff = Math.abs( (a-b)/((a+b)/2) );
if ( diff < .001 )
return;

0 comments on commit d6e3981

Please sign in to comment.