From 57ad3a5acb07f3623b1204e0ea642994ea944ffa Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 8 May 2019 13:58:16 +0200 Subject: [PATCH] Fuzzy match in the `should parse PostScript numbers` unit-test, to work-around rounding bugs in Chromium browsers --- test/unit/parser_spec.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/unit/parser_spec.js b/test/unit/parser_spec.js index b26ed2dcf..4e0404bba 100644 --- a/test/unit/parser_spec.js +++ b/test/unit/parser_spec.js @@ -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); } });