Make addJsamineCustomFloatEqualityTest configurable

PiperOrigin-RevId: 499263931
This commit is contained in:
Sebastian Schmidt 2023-01-03 10:52:41 -08:00 committed by Copybara-Service
parent f53c0eacee
commit 987f4dc1ed

View File

@ -44,10 +44,10 @@ export function createSpyWasmModule(): SpyWasmModule {
* Sets up our equality testing to use a custom float equality checking function
* to avoid incorrect test results due to minor floating point inaccuracies.
*/
export function addJasmineCustomFloatEqualityTester() {
export function addJasmineCustomFloatEqualityTester(tolerance = 5e-8) {
jasmine.addCustomEqualityTester((a, b) => { // Custom float equality
if (a === +a && b === +b && (a !== (a | 0) || b !== (b | 0))) {
return Math.abs(a - b) < 5e-8;
return Math.abs(a - b) < tolerance;
}
return;
});