Skip to content

Commit

Permalink
Deal with approximation on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joaosimbiose committed Apr 25, 2018
1 parent 2130264 commit d64bfd4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests_and_examples/runQueryTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,19 @@ class SlicingDiceTester {
return this.arrayEqual(expected, result);
}

if(typeof expected === "object") {
if (typeof expected === "object") {
return this.compareJsonValue(expected, result);
}

return expected === result;
if (isNaN(expected)) {
return expected === result;
}

return this.numberIsClose(expected, result);
}

numberIsClose(a, b, rel_tol=1e-09, abs_tol=0.0) {
return Math.abs(a - b) <= Math.max(rel_tol * Math.max(Math.abs(a), Math.abs(b)), abs_tol);
}

/* Compare two JSON's values
Expand Down

0 comments on commit d64bfd4

Please sign in to comment.