diff --git a/js/src/tests/js1_8/extensions/regress-385729.js b/js/src/tests/js1_8/extensions/regress-385729.js index 82d06b6f6cc9..4b860fcdeaa9 100644 --- a/js/src/tests/js1_8/extensions/regress-385729.js +++ b/js/src/tests/js1_8/extensions/regress-385729.js @@ -9,6 +9,13 @@ var summary = 'uneval(eval(expression closure))'; var actual = 'No Crash'; var expect = 'No Crash'; +function normalizeSource(source) { + source = String(source); + source = source.replace(/([(){},.:\[\]])/mg, ' $1 '); + source = source.replace(/\s+/mg, ' '); + + return source; +} //----------------------------------------------------------------------------- test(); @@ -34,7 +41,7 @@ function test() expect = 'SyntaxError: missing { before function body'; actual = ex + ''; } - compareSource(expect, actual, summary); + compareSource(normalizeSource(expect), normalizeSource(actual), summary); expect = '({get f () /x/g})'; try @@ -48,7 +55,7 @@ function test() expect = 'SyntaxError: missing { before function body'; actual = ex + ''; } - compareSource(expect, actual, summary); + compareSource(normalizeSource(expect), normalizeSource(actual), summary); } exitFunc ('test'); diff --git a/js/src/tests/shell.js b/js/src/tests/shell.js index 3895642b256f..35183cf6a8c8 100644 --- a/js/src/tests/shell.js +++ b/js/src/tests/shell.js @@ -95,28 +95,6 @@ return ReflectApply(StringPrototypeEndsWith, str, [needle]); } - function StringReplace(str, regexp, replacement) { - assertEq(typeof str === "string" && typeof regexp === "object" && - typeof replacement === "function", true, - "StringReplace must be called with a string, a RegExp object and a function"); - - regexp.lastIndex = 0; - - var result = ""; - var last = 0; - while (true) { - var match = ReflectApply(RegExpPrototypeExec, regexp, [str]); - if (!match) { - result += ReflectApply(StringPrototypeSubstring, str, [last]); - return result; - } - - result += ReflectApply(StringPrototypeSubstring, str, [last, match.index]); - result += ReflectApply(replacement, null, match); - last = match.index + match[0].length; - } - } - function StringSplit(str, delimiter) { assertEq(typeof str === "string" && typeof delimiter === "string", true, "StringSplit must be called with two string arguments"); @@ -624,18 +602,10 @@ } global.reportMatch = reportMatch; - function normalizeSource(source) { - source = String(source); - source = StringReplace(source, /([(){},.:\[\]])/mg, (_, punctuator) => ` ${punctuator} `); - source = StringReplace(source, /\s+/mg, _ => ' '); - - return source; - } - function compareSource(expect, actual, summary) { // compare source - var expectP = normalizeSource(expect); - var actualP = normalizeSource(actual); + var expectP = String(expect); + var actualP = String(actual); print('expect:\n' + expectP); print('actual:\n' + actualP);