Make addJsamineCustomFloatEqualityTest configurable
PiperOrigin-RevId: 499263931
This commit is contained in:
parent
f53c0eacee
commit
987f4dc1ed
|
@ -44,10 +44,10 @@ export function createSpyWasmModule(): SpyWasmModule {
|
||||||
* Sets up our equality testing to use a custom float equality checking function
|
* Sets up our equality testing to use a custom float equality checking function
|
||||||
* to avoid incorrect test results due to minor floating point inaccuracies.
|
* 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
|
jasmine.addCustomEqualityTester((a, b) => { // Custom float equality
|
||||||
if (a === +a && b === +b && (a !== (a | 0) || b !== (b | 0))) {
|
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;
|
return;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user