From 07b7ca13e8c49639f84c10b2103caa14607be960 Mon Sep 17 00:00:00 2001 From: tuchida Date: Sun, 16 Jan 2022 17:51:58 +0900 Subject: [PATCH] Fix test for Function.prototype.toString/toSource --- testsrc/doctests/433878.doctest | 10 +++---- testsrc/doctests/773573.doctest | 2 +- testsrc/doctests/expressionclosure.doctest | 24 ++++++---------- .../doctests/object.defineproperty.doctest | 5 ++-- .../object.getownpropertydescriptor.doctest | 4 +-- testsrc/jstests/arrowfn.jstest | 6 ++-- testsrc/jstests/harmony/method-definition.js | 7 +---- .../javascript/tests/Bug491621Test.java | 4 +-- .../javascript/tests/Bug708801Test.java | 2 +- .../javascript/tests/Bug782363Test.java | 3 +- .../javascript/tests/BugGetterSetterTest.java | 5 ++-- .../mozilla/javascript/tests/CodegenTest.java | 28 +++++++++---------- .../tests/commentspr465/MiscCommentsTest.java | 13 +++++---- .../tests/es6/NativeObjectTest.java | 2 +- testsrc/tests/e4x/Regress/regress-301692.js | 15 +++++----- .../tests/e4x/extensions/regress-321547.js | 5 +++- testsrc/tests/js1_5/Scope/regress-185485.js | 2 +- .../js1_5/decompilation/regress-344120.js | 2 +- .../js1_5/decompilation/regress-352022.js | 2 +- .../js1_5/decompilation/regress-352360.js | 2 +- .../js1_5/decompilation/regress-353120.js | 2 +- .../js1_5/decompilation/regress-383721.js | 3 +- .../js1_5/decompilation/regress-437288-02.js | 2 +- .../js1_5/decompilation/regress-456964-01.js | 2 +- .../js1_5/decompilation/regress-460116-01.js | 2 +- .../js1_5/decompilation/regress-460116-02.js | 2 +- .../js1_5/decompilation/regress-460116-03.js | 2 +- .../js1_5/decompilation/regress-461110.js | 2 +- .../tests/js1_5/extensions/regress-245795.js | 2 +- .../tests/js1_5/extensions/regress-313803.js | 2 +- .../tests/js1_5/extensions/regress-352261.js | 4 +-- .../tests/js1_5/extensions/regress-352281.js | 2 +- .../js1_6/decompilation/regress-352084.js | 6 ++-- testsrc/tests/js1_7/block/regress-411279.js | 2 +- .../js1_7/decompilation/regress-349633.js | 2 +- .../js1_7/decompilation/regress-352015.js | 4 +-- .../js1_7/decompilation/regress-352269.js | 2 +- .../js1_7/decompilation/regress-352732.js | 4 +-- .../js1_7/decompilation/regress-380506.js | 4 +-- .../tests/js1_7/extensions/iterator-ctor.js | 4 +-- .../js1_7/extensions/regress-346642-02.js | 2 +- .../js1_8_1/decompilation/regress-371802.js | 2 +- .../js1_8_1/regress/regress-452498-108.js | 2 +- 43 files changed, 94 insertions(+), 110 deletions(-) diff --git a/testsrc/doctests/433878.doctest b/testsrc/doctests/433878.doctest index bb17907ffa..2ae658685a 100644 --- a/testsrc/doctests/433878.doctest +++ b/testsrc/doctests/433878.doctest @@ -9,12 +9,10 @@ js> function f(a,b,c) { > return sum / 3; > } js> f.toString() - -function f(a, b, c) { - let sum = a + b + c; - return sum / 3; -} - +function f(a,b,c) { + let sum = a + b + c; + return sum / 3; + } js> try { > eval("function f() { for (;;) let a=3; return 3; }"); > } catch (e) { diff --git a/testsrc/doctests/773573.doctest b/testsrc/doctests/773573.doctest index 2023e6c473..e4e8d238d9 100755 --- a/testsrc/doctests/773573.doctest +++ b/testsrc/doctests/773573.doctest @@ -7,7 +7,7 @@ js> version(180) js> try { > (function({a}) { return a }).foo() > } catch (e) { - > e.message.indexOf("function ({a}) {...}") != -1; + > e.message.indexOf("function({a}) {...}") != -1; > } true diff --git a/testsrc/doctests/expressionclosure.doctest b/testsrc/doctests/expressionclosure.doctest index 8dcfdd38a1..50658de91b 100644 --- a/testsrc/doctests/expressionclosure.doctest +++ b/testsrc/doctests/expressionclosure.doctest @@ -5,36 +5,28 @@ js> version(180) 180 js> x = function(x) x; - -function (x) x - +function(x) x js> x.toSource() -(function (x) x) +function(x) x js> x(123) === 123 true js> x = function([a, b]) a + b; - -function ([a, b]) a + b - +function([a, b]) a + b js> x([1, 2]) 3 js> x.toSource() -(function ([a, b]) a + b) +function([a, b]) a + b js> function outer() { > var k = function(a) a + 1; > return function(b) k(b) * 2; > } js> outer - function outer() { - var k = function (a) a + 1; - return function (b) k(b) * 2; -} - + var k = function(a) a + 1; + return function(b) k(b) * 2; + } js> outer() - -function (b) k(b) * 2 - +function(b) k(b) * 2 js> outer()(4) 10 js> outer()(5) diff --git a/testsrc/doctests/object.defineproperty.doctest b/testsrc/doctests/object.defineproperty.doctest index 05a40ad240..9c97db78fa 100644 --- a/testsrc/doctests/object.defineproperty.doctest +++ b/testsrc/doctests/object.defineproperty.doctest @@ -48,7 +48,7 @@ js> obj.a js> // when define new property with accessor descriptor then those values are used for the descriptor js> var obj = define({}, 'a', { get: function() { return 3; }, set: function(value) {} }); js> var {get:g, set:s} = describe(obj, 'a'); [g, s].toSource(); -[(function () {return 3;}), (function (value) {})] +[function() { return 3; }, function(value) {}] js> obj.a 3 @@ -128,8 +128,7 @@ js> var obj = define(obj, 'a', {get : function() { return 4 }}); js> obj.a 4 js> describe(obj, 'a').toSource() -({enumerable:false, configurable:true, get:(function () {return 4;})}) - +({enumerable:false, configurable:true, get:function() { return 4 }}) js> // can change from accessor property to data property when configurable is true js> var obj = define({}, 'a', {get : function() { return 2 }, configurable:true}); js> var obj = define(obj, 'a', {value : 5}); diff --git a/testsrc/doctests/object.getownpropertydescriptor.doctest b/testsrc/doctests/object.getownpropertydescriptor.doctest index b0cac1b725..9baa50c103 100644 --- a/testsrc/doctests/object.getownpropertydescriptor.doctest +++ b/testsrc/doctests/object.getownpropertydescriptor.doctest @@ -34,9 +34,9 @@ js> desc.value === undefined; true js> desc.writable js> desc.get.toSource() -(function () {}) +p() {} js> desc.set.toSource() -(function () {}) +p() {} js> desc.enumerable true js> desc.configurable diff --git a/testsrc/jstests/arrowfn.jstest b/testsrc/jstests/arrowfn.jstest index 635989f9a9..7d9f4be48f 100644 --- a/testsrc/jstests/arrowfn.jstest +++ b/testsrc/jstests/arrowfn.jstest @@ -15,11 +15,11 @@ function assertException(exception, fn) { var f = a => a * a; assertEq(f(2), 4); -assertEq(f.toString(), '\na => a * a\n'); +assertEq(f.toString(), 'a => a * a'); var f = (a) => a * a; assertEq(f(2), 4); -assertEq(f.toString(), '\n(a) => a * a\n'); +assertEq(f.toString(), '(a) => a * a'); var f = (a, b) => a * b; assertEq(f(2, 3), 6); @@ -51,7 +51,7 @@ var f = a => { return a * a; }; assertEq(f(10), 100); -assertEq(f.toString(), '\na => {\n return a * a;\n}\n'); +assertEq(f.toString(), 'a => {\n return a * a;\n}'); var f = a => { a * a; diff --git a/testsrc/jstests/harmony/method-definition.js b/testsrc/jstests/harmony/method-definition.js index 77f25819fa..50c475e480 100644 --- a/testsrc/jstests/harmony/method-definition.js +++ b/testsrc/jstests/harmony/method-definition.js @@ -39,12 +39,7 @@ obj = { assertEquals(123, obj.set()); // assertEquals("set", obj.set.name); -assertEquals("\n" + -"function () {\n" + -" +{f() {\n" + -" print(1);\n" + -" }};\n" + -"}\n", (function() { +{ f() { print(1); }}; }).toString()); +assertEquals("function() { +{ f() { print(1); }}; }", (function() { +{ f() { print(1); }}; }).toString()); // Allow reserved word assertEquals(123, { diff --git a/testsrc/org/mozilla/javascript/tests/Bug491621Test.java b/testsrc/org/mozilla/javascript/tests/Bug491621Test.java index 24c03ac42a..754250fee3 100644 --- a/testsrc/org/mozilla/javascript/tests/Bug491621Test.java +++ b/testsrc/org/mozilla/javascript/tests/Bug491621Test.java @@ -104,9 +104,9 @@ public void hexOctDecLiteralToSource() { @Test public void hexOctLiteralPropertyNameToSource() { - assertSource("({ 0xff: 1, 010: 2 });", "({\n ff: 1, \n 10: 2});\n"); + assertSource("({ 0xff: 1, 010: 2 });", "({\n ff: 1,\n 10: 2\n});\n"); assertSource( - "({ 0xff: 1, 010: 2 });", "({\n 0xff: 1, \n 010: 2});\n", Context.VERSION_ES6); + "({ 0xff: 1, 010: 2 });", "({\n 0xff: 1,\n 010: 2\n});\n", Context.VERSION_ES6); } @Test diff --git a/testsrc/org/mozilla/javascript/tests/Bug708801Test.java b/testsrc/org/mozilla/javascript/tests/Bug708801Test.java index e035d3456c..5d53fa325e 100644 --- a/testsrc/org/mozilla/javascript/tests/Bug708801Test.java +++ b/testsrc/org/mozilla/javascript/tests/Bug708801Test.java @@ -71,7 +71,7 @@ protected ScriptNode compile(CharSequence source) { Codegen codegen = new Codegen(); codegen.setMainMethodClass(mainMethodClassName); codegen.compileToClassFile( - compilerEnv, scriptClassName, tree, tree.getEncodedSource(), false); + compilerEnv, scriptClassName, tree, tree.getRawSource(), false); return tree; } diff --git a/testsrc/org/mozilla/javascript/tests/Bug782363Test.java b/testsrc/org/mozilla/javascript/tests/Bug782363Test.java index 01c07716df..2ed041912e 100755 --- a/testsrc/org/mozilla/javascript/tests/Bug782363Test.java +++ b/testsrc/org/mozilla/javascript/tests/Bug782363Test.java @@ -61,8 +61,7 @@ protected ScriptNode compile(CharSequence source) { Codegen codegen = new Codegen(); codegen.setMainMethodClass(mainMethodClassName); - codegen.compileToClassFile( - compilerEnv, scriptClassName, tree, tree.getEncodedSource(), false); + codegen.compileToClassFile(compilerEnv, scriptClassName, tree, tree.getRawSource(), false); return tree; } diff --git a/testsrc/org/mozilla/javascript/tests/BugGetterSetterTest.java b/testsrc/org/mozilla/javascript/tests/BugGetterSetterTest.java index c72664cfe3..600b49c024 100644 --- a/testsrc/org/mozilla/javascript/tests/BugGetterSetterTest.java +++ b/testsrc/org/mozilla/javascript/tests/BugGetterSetterTest.java @@ -26,11 +26,10 @@ public void setUp() throws Exception { public void nodeReplacementInWhileLoopWithBrackets() throws IOException { String script = "var o = {\n" - + " _x: 123, \n" + + " _x: 123,\n" + " get x() {\n" + " return this._x;\n" - + " }\n" - + ", \n" + + " },\n" + " set x(value) {\n" + " this._x = value;\n" + " }\n" diff --git a/testsrc/org/mozilla/javascript/tests/CodegenTest.java b/testsrc/org/mozilla/javascript/tests/CodegenTest.java index 181a405c0b..2f72ee02dc 100644 --- a/testsrc/org/mozilla/javascript/tests/CodegenTest.java +++ b/testsrc/org/mozilla/javascript/tests/CodegenTest.java @@ -74,8 +74,8 @@ public void largeMethod() { .getName() .startsWith("org.mozilla.javascript.InterpretedFunction")); Assert.assertTrue( - "" + ((NativeFunction) script).getEncodedSource().length(), - ((NativeFunction) script).getEncodedSource().length() > 1000); + "" + ((NativeFunction) script).getRawSource().length(), + ((NativeFunction) script).getRawSource().length() > 1000); return null; } catch (IOException e) { Assert.fail(e.getMessage()); @@ -144,8 +144,8 @@ public void largeVarList() { .getName() .startsWith("org.mozilla.javascript.InterpretedFunction")); Assert.assertTrue( - "" + ((NativeFunction) script).getEncodedSource().length(), - ((NativeFunction) script).getEncodedSource().length() > 1000); + "" + ((NativeFunction) script).getRawSource().length(), + ((NativeFunction) script).getRawSource().length() > 1000); return null; }); @@ -164,8 +164,8 @@ public void largeVarList() { .getName() .startsWith("org.mozilla.javascript.InterpretedFunction")); Assert.assertTrue( - "" + ((NativeFunction) script).getEncodedSource().length(), - ((NativeFunction) script).getEncodedSource().length() > 1000); + "" + ((NativeFunction) script).getRawSource().length(), + ((NativeFunction) script).getRawSource().length() > 1000); return null; } catch (IOException e) { Assert.fail(e.getMessage()); @@ -216,8 +216,8 @@ public void largeLocalVarList() { .getName() .startsWith("org.mozilla.javascript.InterpretedFunction")); Assert.assertTrue( - "" + ((NativeFunction) script).getEncodedSource().length(), - ((NativeFunction) script).getEncodedSource().length() > 1000); + "" + ((NativeFunction) script).getRawSource().length(), + ((NativeFunction) script).getRawSource().length() > 1000); return null; }); @@ -236,8 +236,8 @@ public void largeLocalVarList() { .getName() .startsWith("org.mozilla.javascript.InterpretedFunction")); Assert.assertTrue( - "" + ((NativeFunction) script).getEncodedSource().length(), - ((NativeFunction) script).getEncodedSource().length() > 1000); + "" + ((NativeFunction) script).getRawSource().length(), + ((NativeFunction) script).getRawSource().length() > 1000); return null; } catch (IOException e) { Assert.fail(e.getMessage()); @@ -284,8 +284,8 @@ public void tooManyMethods() { .getName() .startsWith("org.mozilla.javascript.InterpretedFunction")); Assert.assertTrue( - "" + ((NativeFunction) script).getEncodedSource().length(), - ((NativeFunction) script).getEncodedSource().length() > 1000); + "" + ((NativeFunction) script).getRawSource().length(), + ((NativeFunction) script).getRawSource().length() > 1000); return null; }); @@ -304,8 +304,8 @@ public void tooManyMethods() { .getName() .startsWith("org.mozilla.javascript.InterpretedFunction")); Assert.assertTrue( - "" + ((NativeFunction) script).getEncodedSource().length(), - ((NativeFunction) script).getEncodedSource().length() > 1000); + "" + ((NativeFunction) script).getRawSource().length(), + ((NativeFunction) script).getRawSource().length() > 1000); return null; } catch (IOException e) { Assert.fail(e.getMessage()); diff --git a/testsrc/org/mozilla/javascript/tests/commentspr465/MiscCommentsTest.java b/testsrc/org/mozilla/javascript/tests/commentspr465/MiscCommentsTest.java index 51f019bc3e..88c574f701 100644 --- a/testsrc/org/mozilla/javascript/tests/commentspr465/MiscCommentsTest.java +++ b/testsrc/org/mozilla/javascript/tests/commentspr465/MiscCommentsTest.java @@ -57,12 +57,13 @@ public void commentsInObjectLiteral() { String outputStr = "function f1() {\n" + " var timeRegistrationLines = {\n" - + " \"orderId\": a.orderId, \n" - + " \"registeredQuantity\": a.datavalue, \n" - + " \"unit\": a.unit, \n" - + " \"wageCompType\": a.wageCompType, \n" - + " \"week\": a[a.timeLineFrom].weekNumber, \n" - + " \"comments\": (a.datavalue || null)};\n" + + " \"orderId\": a.orderId,\n" + + " \"registeredQuantity\": a.datavalue,\n" + + " \"unit\": a.unit,\n" + + " \"wageCompType\": a.wageCompType,\n" + + " \"week\": a[a.timeLineFrom].weekNumber,\n" + + " \"comments\": (a.datavalue || null)\n" + + "};\n" + "}\n"; AstNode scriptRoot = CommentsTestUtils.getRhinoASTRootNode(inputStr, "tryCatch1", null, null); diff --git a/testsrc/org/mozilla/javascript/tests/es6/NativeObjectTest.java b/testsrc/org/mozilla/javascript/tests/es6/NativeObjectTest.java index fe9d1c6e22..bf4f46370a 100644 --- a/testsrc/org/mozilla/javascript/tests/es6/NativeObjectTest.java +++ b/testsrc/org/mozilla/javascript/tests/es6/NativeObjectTest.java @@ -230,7 +230,7 @@ public void getOwnPropertyDescriptorSetPropertyIsAlwaysDefined() { + "+ ' ' + desc.get" + "+ ' ' + desc.set" + "+ ' [' + Object.getOwnPropertyNames(desc) + ']'", - "undefined \nfunction () {\n}\n undefined [get,set,enumerable,configurable]"); + "undefined function() {} undefined [get,set,enumerable,configurable]"); } @Test diff --git a/testsrc/tests/e4x/Regress/regress-301692.js b/testsrc/tests/e4x/Regress/regress-301692.js index c747435f0b..acc6e465c4 100755 --- a/testsrc/tests/e4x/Regress/regress-301692.js +++ b/testsrc/tests/e4x/Regress/regress-301692.js @@ -14,33 +14,32 @@ printBugNumber(BUGNUMBER); START(summary); actual = ToString((function () { return ; })); -expect = 'function () { return ;}'; +expect = 'function () { return ; }'; TEST(1, expect, actual); actual = ToString((function () { return ; })); -expect = 'function () { return ;}'; +expect = 'function () { return ; }'; TEST(2, expect, actual); actual = ToString((function () { return ; })); -expect = 'function () { return ;}'; +expect = 'function () { return ; }'; TEST(3, expect, actual); actual = ToString((function (k) { return {k}; })); -expect = 'function (k) { return {k};}'; +expect = 'function (k) { return {k}; }'; TEST(4, expect, actual); actual = ToString((function (k) { return <{k}/>; })); -expect = 'function (k) { return <{k}/>;}'; +expect = 'function (k) { return <{k}/>; }'; TEST(5, expect, actual); actual = ToString((function (k) { return <{k}>{k}; })); -expect = 'function (k) { return <{k}>{k};}'; +expect = 'function (k) { return <{k}>{k}; }'; TEST(6, expect, actual); actual = ToString((function (k) { return <{k} {k}={k} {"k"}={k + "world"}><{k + "k"}/>; })); -expect = 'function (k) ' + - '{ return <{k} {k}={k} {"k"}={k + "world"}><{k + "k"}/>;}'; +expect = 'function (k) { return <{k} {k}={k} {"k"}={k + "world"}><{k + "k"}/>; }'; TEST(7, expect, actual); END(); diff --git a/testsrc/tests/e4x/extensions/regress-321547.js b/testsrc/tests/e4x/extensions/regress-321547.js index 0ebecfff2d..8e057ba059 100755 --- a/testsrc/tests/e4x/extensions/regress-321547.js +++ b/testsrc/tests/e4x/extensions/regress-321547.js @@ -20,7 +20,10 @@ function a(){ } actual = a.toSource(); -expect = 'function a() {var x = value c;return x..c;}'; +expect = 'function a(){\n\ + var x=value c;\n\ + return x..c;\n\ +}'; actual = actual.replace(/[\n ]+/mg, ' '); expect = expect.replace(/[\n ]+/mg, ' '); diff --git a/testsrc/tests/js1_5/Scope/regress-185485.js b/testsrc/tests/js1_5/Scope/regress-185485.js index 2b6f8e7275..e56e499094 100644 --- a/testsrc/tests/js1_5/Scope/regress-185485.js +++ b/testsrc/tests/js1_5/Scope/regress-185485.js @@ -95,7 +95,7 @@ with (x) } status = inSection(5); actual = x.g.toString(); -expect = (function () {}).toString(); +expect = (function() {}).toString(); addThis(); diff --git a/testsrc/tests/js1_5/decompilation/regress-344120.js b/testsrc/tests/js1_5/decompilation/regress-344120.js index 7680acf2ad..4b8c320942 100755 --- a/testsrc/tests/js1_5/decompilation/regress-344120.js +++ b/testsrc/tests/js1_5/decompilation/regress-344120.js @@ -22,7 +22,7 @@ function test() printStatus (summary); expect = 'function () { x = {1:1};}'; - actual = ''+function (){x={1:1}} + actual = ''+function (){x={1:1};} compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-352022.js b/testsrc/tests/js1_5/decompilation/regress-352022.js index d0bad8e6eb..929b7c972f 100755 --- a/testsrc/tests/js1_5/decompilation/regress-352022.js +++ b/testsrc/tests/js1_5/decompilation/regress-352022.js @@ -23,7 +23,7 @@ function test() var f = function (){a[b] = (c, d)} actual = f + ''; - expect = 'function () {\n a[b] = (c, d);\n}'; + expect = 'function () {\n a[b] = (c, d)\n}'; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-352360.js b/testsrc/tests/js1_5/decompilation/regress-352360.js index da5d0e706e..d6a039adfe 100755 --- a/testsrc/tests/js1_5/decompilation/regress-352360.js +++ b/testsrc/tests/js1_5/decompilation/regress-352360.js @@ -22,7 +22,7 @@ function test() printStatus (summary); var f = function() { return -0 }; - expect = 'function() { return -0; }'; + expect = 'function() { return -0 }'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-353120.js b/testsrc/tests/js1_5/decompilation/regress-353120.js index e446332db8..ffbdf20424 100755 --- a/testsrc/tests/js1_5/decompilation/regress-353120.js +++ b/testsrc/tests/js1_5/decompilation/regress-353120.js @@ -23,7 +23,7 @@ function test() var f; f = function() { return (new x)[y]++ } - expect = 'function() { return (new x)[y]++; }'; + expect = 'function() { return (new x)[y]++ }'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-383721.js b/testsrc/tests/js1_5/decompilation/regress-383721.js index b888263da7..85ea805001 100755 --- a/testsrc/tests/js1_5/decompilation/regress-383721.js +++ b/testsrc/tests/js1_5/decompilation/regress-383721.js @@ -22,11 +22,10 @@ function test() printStatus (summary); var f = function () {return "\t"}; - expect = 'function () {return "\\t";}'; + expect = 'function () {return "\\t"}'; actual = f + ''; compareSource(expect, actual, summary + ': toString'); - expect = '(' + expect + ')'; actual = uneval(f); compareSource(expect, actual, summary + ': uneval'); diff --git a/testsrc/tests/js1_5/decompilation/regress-437288-02.js b/testsrc/tests/js1_5/decompilation/regress-437288-02.js index 05a05ba8ae..c6b1ba1edc 100755 --- a/testsrc/tests/js1_5/decompilation/regress-437288-02.js +++ b/testsrc/tests/js1_5/decompilation/regress-437288-02.js @@ -23,7 +23,7 @@ function test() function f() { const x = 1; for (x in null); } - expect = 'function f() { const x = 1; for (x in null) {} }'; + expect = 'function f() { const x = 1; for (x in null) ; }'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-456964-01.js b/testsrc/tests/js1_5/decompilation/regress-456964-01.js index 95cb53fa79..5d72b17f5b 100755 --- a/testsrc/tests/js1_5/decompilation/regress-456964-01.js +++ b/testsrc/tests/js1_5/decompilation/regress-456964-01.js @@ -33,7 +33,7 @@ function test() print(Test); - expect = 'function Test ( ) { var object = { abc : 1 , def : 2 } ; var o = ""; for ( var i in object ) { o += i + " = " + object [ i ] + "\\ n "; } return o ; }'; + expect = 'function Test ( ) { var object = { abc : 1 , def : 2 } ; var o = \'\'; for ( var i in object ) o += i + \' = \' + object [ i ] + \'\\ n \'; return o ; }'; actual = Test + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-460116-01.js b/testsrc/tests/js1_5/decompilation/regress-460116-01.js index 56c347ab6f..9bcd6f7a45 100755 --- a/testsrc/tests/js1_5/decompilation/regress-460116-01.js +++ b/testsrc/tests/js1_5/decompilation/regress-460116-01.js @@ -24,7 +24,7 @@ function test() var f; f = (function (){if(typeof(false||undef))throw "fail"}); - expect = 'function (){if(typeof(false||undef)) {throw "fail";}}'; + expect = 'function (){if(typeof(false||undef)) throw "fail"}'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-460116-02.js b/testsrc/tests/js1_5/decompilation/regress-460116-02.js index b2e6f5c13a..0084ae3a19 100755 --- a/testsrc/tests/js1_5/decompilation/regress-460116-02.js +++ b/testsrc/tests/js1_5/decompilation/regress-460116-02.js @@ -24,7 +24,7 @@ function test() var f; f = (function (){if((false&&foo)===(true||bar));}); - expect = 'function (){if((false&&foo)===(true||bar)) {}}'; + expect = 'function (){if((false&&foo)===(true||bar));}'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-460116-03.js b/testsrc/tests/js1_5/decompilation/regress-460116-03.js index f772acfb07..63f34183e3 100755 --- a/testsrc/tests/js1_5/decompilation/regress-460116-03.js +++ b/testsrc/tests/js1_5/decompilation/regress-460116-03.js @@ -24,7 +24,7 @@ function test() var f; f = (function (){if((baz&&false&&foo)===(bletch||true||bar));}); - expect = 'function (){if((baz&&false&&foo)===(bletch||true||bar)){}}'; + expect = 'function (){if((baz&&false&&foo)===(bletch||true||bar));}'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/decompilation/regress-461110.js b/testsrc/tests/js1_5/decompilation/regress-461110.js index 97a3b9f954..ea562e4800 100755 --- a/testsrc/tests/js1_5/decompilation/regress-461110.js +++ b/testsrc/tests/js1_5/decompilation/regress-461110.js @@ -23,7 +23,7 @@ function test() var f = (function() { a += b = 3 }); - expect = 'function() { a += b = 3; }'; + expect = 'function() { a += b = 3 }'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/extensions/regress-245795.js b/testsrc/tests/js1_5/extensions/regress-245795.js index b16e5654ad..06c6660df1 100755 --- a/testsrc/tests/js1_5/extensions/regress-245795.js +++ b/testsrc/tests/js1_5/extensions/regress-245795.js @@ -20,7 +20,7 @@ if (typeof uneval != 'undefined') b=function() {}; } - var r = /function a\(\) \{ b = \(?function \(\) \{\s*\}\)?; \}/; + var r = /function a\(\) \{ b=\(?function\(\) \{\s*\}\)?; \}/; eval(uneval(a)); var v = a.toString().replace(/[ \n]+/g, ' '); diff --git a/testsrc/tests/js1_5/extensions/regress-313803.js b/testsrc/tests/js1_5/extensions/regress-313803.js index a3294b6a59..9606547ffd 100755 --- a/testsrc/tests/js1_5/extensions/regress-313803.js +++ b/testsrc/tests/js1_5/extensions/regress-313803.js @@ -20,6 +20,6 @@ var func = function ff() { actual = uneval(func); -expect = '(function ff() {obj = {get foo () {return "foo";}};return 1;})'; +expect = 'function ff() {obj = {get foo () {return "foo";}};return 1;}'; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/extensions/regress-352261.js b/testsrc/tests/js1_5/extensions/regress-352261.js index 606b4c6594..29e6bb1e71 100755 --- a/testsrc/tests/js1_5/extensions/regress-352261.js +++ b/testsrc/tests/js1_5/extensions/regress-352261.js @@ -24,7 +24,7 @@ function test() var g, h; g = function(a,b,c) { return a - (b + c) } - expect = 'function(a,b,c) { return a - (b + c); }'; + expect = 'function(a,b,c) { return a - (b + c) }'; actual = g + ''; compareSource(expect, actual, summary); @@ -36,7 +36,7 @@ function test() var p, q; p = function (a,b,c) { return a + (b - c) } - expect = 'function (a,b,c) { return a + (b - c);}'; + expect = 'function (a,b,c) { return a + (b - c)}'; actual = p + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_5/extensions/regress-352281.js b/testsrc/tests/js1_5/extensions/regress-352281.js index a3ebac8f51..b07f04a3b9 100755 --- a/testsrc/tests/js1_5/extensions/regress-352281.js +++ b/testsrc/tests/js1_5/extensions/regress-352281.js @@ -23,7 +23,7 @@ function test() var f, g; f = function() { { while(0) function t() { } } } - expect = 'function() { while(0) { function t() { } }}'; + expect = 'function() { { while(0) function t() { } } }'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_6/decompilation/regress-352084.js b/testsrc/tests/js1_6/decompilation/regress-352084.js index 1b6ac92023..a79b504073 100755 --- a/testsrc/tests/js1_6/decompilation/regress-352084.js +++ b/testsrc/tests/js1_6/decompilation/regress-352084.js @@ -24,17 +24,17 @@ function test() var f; f = function() { h = {x:5, y:(a,b)}} ; - expect = 'function() { h = {x:5, y:(a,b)};}'; + expect = 'function() { h = {x:5, y:(a,b)}}'; actual = f + ''; compareSource(expect, actual, summary); f = function() { x(a, (b,c)) }; - expect = 'function() { x(a, (b,c));}'; + expect = 'function() { x(a, (b,c))}'; actual = f + ''; compareSource(expect, actual, summary); f = function() { return [(x, y) for each (z in [])] }; - expect = 'function() { return [(x, y) for each (z in [])];}'; + expect = 'function() { return [(x, y) for each (z in [])]}'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_7/block/regress-411279.js b/testsrc/tests/js1_7/block/regress-411279.js index fcd1ffe6f2..de22dc10fe 100755 --- a/testsrc/tests/js1_7/block/regress-411279.js +++ b/testsrc/tests/js1_7/block/regress-411279.js @@ -41,7 +41,7 @@ function test() return value; } - expect = 'function f(x) { var value = ""; switch (x) { ' + expect = 'function f(x) { var value = \'\'; switch (x) { ' + 'case 1: value = "1 " + y; break; ' + 'case 2: let y = 42; value = "2 " + y; break; ' + 'default: value = "default " + y; } return value; }'; diff --git a/testsrc/tests/js1_7/decompilation/regress-349633.js b/testsrc/tests/js1_7/decompilation/regress-349633.js index 77a46d4bab..9a8d5a7fda 100755 --- a/testsrc/tests/js1_7/decompilation/regress-349633.js +++ b/testsrc/tests/js1_7/decompilation/regress-349633.js @@ -24,7 +24,7 @@ function test() var f; f = function () { let (x = 3) { x-- } } - expect = 'function () {\n let (x = 3) {\n x--;\n }\n}'; + expect = 'function () {\n let (x = 3) {\n x--\n }\n}'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_7/decompilation/regress-352015.js b/testsrc/tests/js1_7/decompilation/regress-352015.js index 8f39d7cb63..9d244fa87f 100755 --- a/testsrc/tests/js1_7/decompilation/regress-352015.js +++ b/testsrc/tests/js1_7/decompilation/regress-352015.js @@ -25,12 +25,12 @@ function test() f = function() { (yield).a } actual = f + ''; - expect = 'function () {\n (yield).a;\n}'; + expect = 'function () {\n (yield).a\n}'; compareSource(expect, actual, summary); f = function() { 3 + (yield 4) } actual = f + ''; - expect = 'function () {\n 3 + (yield 4);\n}'; + expect = 'function () {\n 3 + (yield 4)\n}'; compareSource(expect, actual, summary); exitFunc ('test'); diff --git a/testsrc/tests/js1_7/decompilation/regress-352269.js b/testsrc/tests/js1_7/decompilation/regress-352269.js index ef489cd5fd..1b7d1f32d4 100755 --- a/testsrc/tests/js1_7/decompilation/regress-352269.js +++ b/testsrc/tests/js1_7/decompilation/regress-352269.js @@ -23,7 +23,7 @@ function test() var f; f = function() { yield (1,2) } - expect = 'function() { yield (1,2); }'; + expect = 'function() { yield (1,2) }'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_7/decompilation/regress-352732.js b/testsrc/tests/js1_7/decompilation/regress-352732.js index a163340b01..1516c643d7 100755 --- a/testsrc/tests/js1_7/decompilation/regress-352732.js +++ b/testsrc/tests/js1_7/decompilation/regress-352732.js @@ -29,7 +29,7 @@ function test() { c = '(function() { if (x) L: let x; })'; f = eval(c); - expect = 'function() { if (x) { L: let x; } }'; + expect = 'function() { if (x) L: let x; }'; actual = f + ''; compareSource(expect, actual, summary); } @@ -45,7 +45,7 @@ function test() { c = '(function() { if (x) L: let x; else y; })'; f = eval(c); - expect = 'function() { if (x) { L: let x; } else { y;} }'; + expect = 'function() { if (x) L: let x; else y; }'; actual = f + ''; compareSource(expect, actual, summary); } diff --git a/testsrc/tests/js1_7/decompilation/regress-380506.js b/testsrc/tests/js1_7/decompilation/regress-380506.js index ade2f326d5..4f71e3c193 100755 --- a/testsrc/tests/js1_7/decompilation/regress-380506.js +++ b/testsrc/tests/js1_7/decompilation/regress-380506.js @@ -23,12 +23,12 @@ function test() printStatus (summary); var f = function (){return [i*i for(i in [0]) if (i%2)]}; - expect = 'function (){return [i*i for(i in [0]) if (i%2)];}'; + expect = 'function (){return [i*i for(i in [0]) if (i%2)]}'; actual = f + ''; compareSource(expect, actual, summary); f = function (){return [i*j for(i in [0]) for (j in [1])]}; - expect = 'function (){return [i*j for(i in [0]) for (j in [1])];}'; + expect = 'function (){return [i*j for(i in [0]) for (j in [1])]}'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_7/extensions/iterator-ctor.js b/testsrc/tests/js1_7/extensions/iterator-ctor.js index c0657b00eb..bbda46ba1c 100644 --- a/testsrc/tests/js1_7/extensions/iterator-ctor.js +++ b/testsrc/tests/js1_7/extensions/iterator-ctor.js @@ -73,7 +73,7 @@ reportCompare('[-1, -2]', reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji))) flag'); flag = -1; -reportCompare('[["__iterator__", (function (b) {flag = b;yield -1;yield -2;})], ["a", 1], ["b", 2]]', +reportCompare('[["__iterator__", function (b) { flag = b; yield -1; yield -2; }], ["a", 1], ["b", 2]]', uneval(iteratorToArray(new Iterator(obji))), 'uneval(iteratorToArray(new Iterator(obji)))'); reportCompare(-1, flag, 'uneval(iteratorToArray(new Iterator(obji))) flag'); @@ -85,7 +85,7 @@ reportCompare('[-1, -2]', reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji,false))) flag'); flag = -1; -reportCompare('[["__iterator__", (function (b) {flag = b;yield -1;yield -2;})], ["a", 1], ["b", 2]]', +reportCompare('[["__iterator__", function (b) { flag = b; yield -1; yield -2; }], ["a", 1], ["b", 2]]', uneval(iteratorToArray(new Iterator(obji,false))), 'uneval(iteratorToArray(new Iterator(obji,false)))'); reportCompare(-1, flag, 'uneval(iteratorToArray(new Iterator(obji,false))) flag'); diff --git a/testsrc/tests/js1_7/extensions/regress-346642-02.js b/testsrc/tests/js1_7/extensions/regress-346642-02.js index f664c92f02..a3d72c7bfd 100755 --- a/testsrc/tests/js1_7/extensions/regress-346642-02.js +++ b/testsrc/tests/js1_7/extensions/regress-346642-02.js @@ -24,7 +24,7 @@ function test() var f; f = function f() { [z] = 3 } - expect = 'function f() { [z] = 3; }'; + expect = 'function f() { [z] = 3 }'; actual = f + ''; compareSource(expect, actual, summary); diff --git a/testsrc/tests/js1_8_1/decompilation/regress-371802.js b/testsrc/tests/js1_8_1/decompilation/regress-371802.js index f9b5a224e0..a5cc2ae633 100644 --- a/testsrc/tests/js1_8_1/decompilation/regress-371802.js +++ b/testsrc/tests/js1_8_1/decompilation/regress-371802.js @@ -22,7 +22,7 @@ function test() printStatus (summary); var f = (function (a,b,n){for(var [i,j]=[a,b];i