Fuzzy match in the should parse PostScript numbers unit-test, to work-around rounding bugs in Chromium browsers

This commit is contained in:
Jonas Jenwald 2019-05-08 13:58:16 +02:00
parent a8dd00876a
commit 57ad3a5acb

View File

@ -99,7 +99,17 @@ describe('parser', function() {
for (const number of numbers) {
const input = new StringStream(number);
const lexer = new Lexer(input);
expect(lexer.getNumber()).toEqual(parseFloat(number));
const result = lexer.getNumber(), expected = parseFloat(number);
if (result !== expected && Math.abs(result - expected) < 1e-15) {
console.error(`Fuzzy matching "${result}" with "${expected}" to ` +
'work-around rounding bugs in Chromium browsers.');
expect(true).toEqual(true);
continue;
}
expect(result).toEqual(expected);
}
});