From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/jit-test/lib/codegen-test-common.js | 53 ++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 js/src/jit-test/lib/codegen-test-common.js (limited to 'js/src/jit-test/lib/codegen-test-common.js') diff --git a/js/src/jit-test/lib/codegen-test-common.js b/js/src/jit-test/lib/codegen-test-common.js new file mode 100644 index 0000000000..ad5511746b --- /dev/null +++ b/js/src/jit-test/lib/codegen-test-common.js @@ -0,0 +1,53 @@ +// Set to true to emit ' +' instead of the unreadable '\s+'. +var SPACEDEBUG = false; + +// Any hex string +var HEX = '[0-9a-fA-F]' +var HEXES = `${HEX}+`; + +function wrap(options, funcs) { + if ('memory' in options) + return `(module (memory ${options.memory}) ${funcs})`; + return `(module ${funcs})`; +} + +function fixlines(s) { + return s.split(/\n+/) + .map(strip) + .filter(x => x.length > 0) + .map(x => '(?:0x)?' + HEXES + ' ' + x) + .map(spaces) + .join('\n'); +} + +function strip(s) { + while (s.length > 0 && isspace(s.charAt(0))) + s = s.substring(1); + while (s.length > 0 && isspace(s.charAt(s.length-1))) + s = s.substring(0, s.length-1); + return s; +} + +function striplines(s) { + return s.split('\n').map(strip).join('\n'); +} + +function spaces(s) { + let t = ''; + let i = 0; + while (i < s.length) { + if (isspace(s.charAt(i))) { + t += SPACEDEBUG ? ' +' : '\\s+'; + i++; + while (i < s.length && isspace(s.charAt(i))) + i++; + } else { + t += s.charAt(i++); + } + } + return t; +} + +function isspace(c) { + return c == ' ' || c == '\t'; +} -- cgit v1.2.3