Fix tolerance comparison
This commit is contained in:
parent
bac6639a5e
commit
7a2a3b613c
|
@ -52,7 +52,7 @@ export function compare(val1, val2, tol = 0.1) {
|
|||
expect(Object.keys(val1)).toHaveLength(Object.keys(val2).length);
|
||||
|
||||
for (let key in val1) {
|
||||
compare(val1[key], val2[key]);
|
||||
compare(val1[key], val2[key], tol);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ export function compare(val1, val2, tol = 0.1) {
|
|||
|
||||
if (typeof val1 === 'number' && (!Number.isInteger(val1) || !Number.isInteger(val2))) {
|
||||
// If both are numbers and at least one of them is not an integer
|
||||
expect(val1).toBeCloseTo(val2, tol);
|
||||
expect(val1).toBeCloseTo(val2, -Math.log10(tol));
|
||||
} else {
|
||||
// Perform equality test
|
||||
expect(val1).toEqual(val2);
|
||||
|
|
Loading…
Reference in New Issue