Skip to content

Commit d64bfd4

Browse files
committed
Deal with approximation on tests
1 parent 2130264 commit d64bfd4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tests_and_examples/runQueryTests.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,19 @@ class SlicingDiceTester {
338338
return this.arrayEqual(expected, result);
339339
}
340340

341-
if(typeof expected === "object") {
341+
if (typeof expected === "object") {
342342
return this.compareJsonValue(expected, result);
343343
}
344344

345-
return expected === result;
345+
if (isNaN(expected)) {
346+
return expected === result;
347+
}
348+
349+
return this.numberIsClose(expected, result);
350+
}
351+
352+
numberIsClose(a, b, rel_tol=1e-09, abs_tol=0.0) {
353+
return Math.abs(a - b) <= Math.max(rel_tol * Math.max(Math.abs(a), Math.abs(b)), abs_tol);
346354
}
347355

348356
/* Compare two JSON's values

0 commit comments

Comments
 (0)