Bug 1313490 - Part 2: Remove unnecessary expression closure from jstests. r=evilpie
authorTooru Fujisawa <arai_a@mac.com>
Sat, 26 Nov 2016 06:41:42 +0900
changeset 324323 64a9c8f9d503f56b914566f6943cf084381e96fe
parent 324322 8aee096b3c4b3780b5d1a61d814bfe383664e285
child 324324 349bfd47d48b4af6eb1b8d8e1485d928e65606aa
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersevilpie
bugs1313490
milestone53.0a1
Bug 1313490 - Part 2: Remove unnecessary expression closure from jstests. r=evilpie
js/src/tests/ecma_3/FunExpr/regress-545980.js
js/src/tests/ecma_5/strict/13.1.js
js/src/tests/ecma_6/Class/newTargetEval.js
js/src/tests/js1_8/extensions/regress-452913.js
js/src/tests/js1_8/extensions/regress-454744.js
js/src/tests/js1_8/extensions/regress-469625.js
js/src/tests/js1_8/regress/regress-452491.js
js/src/tests/js1_8/regress/regress-459389.js
js/src/tests/js1_8/regress/regress-464096.js
js/src/tests/js1_8/regress/regress-465220.js
js/src/tests/js1_8/regress/regress-465460-01.js
js/src/tests/js1_8/regress/regress-467495-01.js
js/src/tests/js1_8_1/extensions/regress-452498-196.js
js/src/tests/js1_8_1/regress/regress-452498-027.js
js/src/tests/js1_8_1/regress/regress-452498-079.js
js/src/tests/js1_8_1/regress/regress-452498-102.js
js/src/tests/js1_8_1/regress/regress-452498-121.js
js/src/tests/js1_8_1/regress/regress-452498-160.js
js/src/tests/js1_8_5/regress/regress-607863.js
js/src/tests/js1_8_5/regress/regress-646820-1.js
js/src/tests/js1_8_5/regress/regress-646820-2.js
js/src/tests/js1_8_5/regress/regress-646820-3.js
--- a/js/src/tests/ecma_3/FunExpr/regress-545980.js
+++ b/js/src/tests/ecma_3/FunExpr/regress-545980.js
@@ -22,17 +22,17 @@ function run_test() {
 
   (function doSearch(query) {
     ac.startSearch(query, "", null, {
       onSearchResult: function() {
         var num = tagIds.length;
 
         var timer = new Timer;
         var next = query.slice(1);
-        timer.initWithCallback({ notify: function() doSearch(next) });
+        timer.initWithCallback({ notify: function() { return doSearch(next); } });
       }
     });
   })("title");
 }
 
 run_test();
 later.onSearchResult();
 for (var i in Timer.q)
--- a/js/src/tests/ecma_5/strict/13.1.js
+++ b/js/src/tests/ecma_5/strict/13.1.js
@@ -81,21 +81,21 @@ assertEq(testLenientAndStrict('Function(
                               completesNormally),
          true);
 
 
 /*
  * The parameter lists of function expressions should not contain
  * duplicate identifiers.
  */
-assertEq(testLenientAndStrict('(function (x,x) 2)',
+assertEq(testLenientAndStrict('(function (x,x) {})',
                                parsesSuccessfully,
                                parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function (x,y) 2)',
+assertEq(testLenientAndStrict('(function (x,y) {})',
                               parsesSuccessfully,
                               parsesSuccessfully),
          true);
 
 /*
  * All permutations of:
  * - For the two magic identifiers 'arguments' or 'eval'
  *   - For function definitions, function expressions, expression closures,
@@ -168,29 +168,29 @@ assertEq(testLenientAndStrict('(function
 assertEq(testLenientAndStrict('(function f({x:eval}){"use strict";})',
                               parseRaisesException(SyntaxError),
                               parseRaisesException(SyntaxError)),
          true);
 assertEq(testLenientAndStrict('(function eval(){"use strict";})',
                               parseRaisesException(SyntaxError),
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function f(eval) 2)',
+assertEq(testLenientAndStrict('(function f(eval) {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function f([eval]) 2)',
+assertEq(testLenientAndStrict('(function f([eval]) {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function f({x:eval}) 2)',
+assertEq(testLenientAndStrict('(function f({x:eval}) {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function eval() 2)',
+assertEq(testLenientAndStrict('(function eval() {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
 assertEq(testLenientAndStrict('({set x(eval){}})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
 assertEq(testLenientAndStrict('({set x([eval]){}})',
@@ -272,29 +272,29 @@ assertEq(testLenientAndStrict('(function
 assertEq(testLenientAndStrict('(function f({x:arguments}){"use strict";})',
                               parseRaisesException(SyntaxError),
                               parseRaisesException(SyntaxError)),
          true);
 assertEq(testLenientAndStrict('(function arguments(){"use strict";})',
                               parseRaisesException(SyntaxError),
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function f(arguments) 2)',
+assertEq(testLenientAndStrict('(function f(arguments) {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function f([arguments]) 2)',
+assertEq(testLenientAndStrict('(function f([arguments]) {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function f({x:arguments}) 2)',
+assertEq(testLenientAndStrict('(function f({x:arguments}) {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
-assertEq(testLenientAndStrict('(function arguments() 2)',
+assertEq(testLenientAndStrict('(function arguments() {})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
 assertEq(testLenientAndStrict('({set x(arguments){}})',
                               parsesSuccessfully,
                               parseRaisesException(SyntaxError)),
          true);
 assertEq(testLenientAndStrict('({set x([arguments]){}})',
--- a/js/src/tests/ecma_6/Class/newTargetEval.js
+++ b/js/src/tests/ecma_6/Class/newTargetEval.js
@@ -5,17 +5,17 @@ try {
 } catch (e if e instanceof SyntaxError) { }
 
 // new.target is invalid inside eval inside top-level arrow functions
 assertThrowsInstanceOf(() => eval('new.target'), SyntaxError);
 
 // new.target is invalid inside indirect eval.
 let ieval = eval;
 try {
-    (function () ieval('new.target'))();
+    (function () { return ieval('new.target'); })();
     assertEq(false, true);
 } catch (e if e instanceof SyntaxError) { }
 
 function assertNewTarget(expected) {
     assertEq(eval('new.target'), expected);
     assertEq((()=>eval('new.target'))(), expected);
 
     // Also test nestings "by induction"
--- a/js/src/tests/js1_8/extensions/regress-452913.js
+++ b/js/src/tests/js1_8/extensions/regress-452913.js
@@ -7,12 +7,12 @@
 var BUGNUMBER = 452913;
 var summary = 'Do not crash with defined getter and for (let)';
 var actual = '';
 var expect = '';
 
 printBugNumber(BUGNUMBER);
 printStatus (summary);
  
-(this.__defineGetter__("x", function (x)'foo'.replace(/o/g, [1].push)));
+(this.__defineGetter__("x", function (x) { return 'foo'.replace(/o/g, [1].push); }));
 for(let y in [,,,]) for(let y in [,,,]) x = x;
 
 reportCompare(expect, actual, summary);
--- a/js/src/tests/js1_8/extensions/regress-454744.js
+++ b/js/src/tests/js1_8/extensions/regress-454744.js
@@ -17,17 +17,17 @@ function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
 
   try
   {
-    this.__defineGetter__('x', function() 2); for (var j=0;j<4;++j) { x=1; }
+    this.__defineGetter__('x', function() { return 2; }); for (var j=0;j<4;++j) { x=1; }
   }
   catch(ex)
   {
   }
 
 
   reportCompare(expect, actual, summary);
 
--- a/js/src/tests/js1_8/extensions/regress-469625.js
+++ b/js/src/tests/js1_8/extensions/regress-469625.js
@@ -20,17 +20,17 @@ function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
  
   expect = 'TypeError: [].__proto__ is not a function';
 
 
-  Array.prototype.__proto__ = function () 3; 
+  Array.prototype.__proto__ = function () { return 3; };
 
   try
   {
     [].__proto__();
   }
   catch(ex)
   {
     print(actual = ex + '');
--- a/js/src/tests/js1_8/regress/regress-452491.js
+++ b/js/src/tests/js1_8/regress/regress-452491.js
@@ -15,15 +15,15 @@ test();
 
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
 
-  for (var j=0;j<5;++j) (new (function(q) q)).a;
+  for (var j=0;j<5;++j) (new (function(q) { return q; })).a;
 
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8/regress/regress-459389.js
+++ b/js/src/tests/js1_8/regress/regress-459389.js
@@ -48,18 +48,19 @@ var p=new SNI.MetaData.Parameter();
 this.addParameter=p.addParameter;
 this.getParameter=p.getParameter;
 };
 function Ad() {
 var url=new SNI.Ads.Url();
 this.addParameter=url.addParameter;
 this.getParameter=url.getParameter;
 }
-function DartAd()
-AdUrl.prototype=new Ad();
+function DartAd() {
+  return AdUrl.prototype=new Ad();
+}
 function AdUrl() { }
 function AdRestriction() {
 var p=new SNI.MetaData.Parameter();
 this.addParameter=p.addParameter;
 this.getParameter=p.getParameter;
 this.getKeys=p.getKeys;
 }
 function AdRestrictionManager(){
--- a/js/src/tests/js1_8/regress/regress-464096.js
+++ b/js/src/tests/js1_8/regress/regress-464096.js
@@ -17,16 +17,16 @@ test();
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
 
   for (let f in [1,1]);
-  Object.prototype.__defineGetter__('x', function() gc());
+  Object.prototype.__defineGetter__('x', function() { return gc(); });
   (function() { for each (let j in [1,1,1,1,1]) { var y = .2; } })();
 
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8/regress/regress-465220.js
+++ b/js/src/tests/js1_8/regress/regress-465220.js
@@ -20,17 +20,17 @@ function test()
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
   expect = 'TypeError: can\'t convert o to primitive type';
 
  
   try
   {
-    var o = {toString: function()(i > 2) ? this : "foo"};
+    var o = {toString: function() { return (i > 2) ? this : "foo"; }};
     var s = "";
     for (var i = 0; i < 5; i++)
       s += o + o;
     print(s);
     actual = 'No Exception';
   }
   catch(ex)
   {
--- a/js/src/tests/js1_8/regress/regress-465460-01.js
+++ b/js/src/tests/js1_8/regress/regress-465460-01.js
@@ -18,15 +18,15 @@ function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
  
   expect = '11111';
 
 
-  (function(d) { for (let j = 0; j < 5; ++j) { actual += ('' + d); } })({valueOf: function()1});
+  (function(d) { for (let j = 0; j < 5; ++j) { actual += ('' + d); } })({valueOf: function() { return 1; }});
 
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8/regress/regress-467495-01.js
+++ b/js/src/tests/js1_8/regress/regress-467495-01.js
@@ -15,14 +15,14 @@ test();
 //-----------------------------------------------------------------------------
 
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
-  (function() { x = 0; function x() 4; var x; const y = 1; })();
+  (function() { x = 0; function x() { return 4; }; var x; const y = 1; })();
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8_1/extensions/regress-452498-196.js
+++ b/js/src/tests/js1_8_1/extensions/regress-452498-196.js
@@ -29,16 +29,16 @@ function test()
   x+=NaN;
 
   reportCompare(expect, actual, summary + ': 1');
 
 // Assertion failure: lexdep->isLet(), at ../jsparse.cpp:1900
 
   (function (){
     var x;
-    eval("var x; (function ()x)");
+    eval("var x; (function () { return x; })");
   }
     )();
 
   reportCompare(expect, actual, summary + ': 2');
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8_1/regress/regress-452498-027.js
+++ b/js/src/tests/js1_8_1/regress/regress-452498-027.js
@@ -19,17 +19,17 @@ function test()
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
   expect = '5';
 
 // ------- Comment #27 From Brendan Eich
 
-  function f(x){function g(y)x+y;return g}
+  function f(x){function g(y) { return x+y; } return g}
   g = f(2);
 
   actual = String(g(3));
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8_1/regress/regress-452498-079.js
+++ b/js/src/tests/js1_8_1/regress/regress-452498-079.js
@@ -19,16 +19,16 @@ test();
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
 // ------- Comment #79 From Jason Orendorff
 
-  x; var x; function x() 0
+  x; var x; function x() { return 0; }
 
 // Assertion failure: !(pn->pn_dflags & flag), at ../jsparse.h:635
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8_1/regress/regress-452498-102.js
+++ b/js/src/tests/js1_8_1/regress/regress-452498-102.js
@@ -19,17 +19,17 @@ function test()
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
  
 // ------- Comment #102 From Gary Kwong [:nth10sd]
 
 // =====
 
-  (function(){function x(){} function x()y})();
+  (function(){function x(){} function x() { return y; }})();
 
 // Assertion failure: JOF_OPTYPE(op) == JOF_ATOM, at ../jsemit.cpp:1710
 
 // =====
   function f() {
     "" + (function(){
         for( ; [function(){}] ; x = 0)
           with({x: ""}) {
--- a/js/src/tests/js1_8_1/regress/regress-452498-121.js
+++ b/js/src/tests/js1_8_1/regress/regress-452498-121.js
@@ -18,16 +18,16 @@ function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
 // ------- Comment #121 From Gary Kwong [:nth10sd]
 
 // without -j
-  x = function()x;
+  x = function() { return x; };
 
 // Assertion failure: !(pn->pn_dflags & flag), at ../jsparse.h:651
 
   reportCompare(expect, actual, summary);
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8_1/regress/regress-452498-160.js
+++ b/js/src/tests/js1_8_1/regress/regress-452498-160.js
@@ -17,18 +17,18 @@ test();
 
 function test()
 {
   enterFunc ('test');
   printBugNumber(BUGNUMBER);
   printStatus (summary);
 
 // crash [@ js_Interpret]
-  (eval("(function(){ this.watch(\"x\", function () { new function ()y } ); const y = undefined });"))();
+  (eval("(function(){ this.watch(\"x\", function () { new function () { return y; } } ); const y = undefined });"))();
   x = NaN;
   reportCompare(expect, actual, summary + ': 2');
 
 // Assertion failure: JOF_OPTYPE(op) == JOF_ATOM, at ../jsemit.cpp:5916
-  ({ set z(v){},  set y(v)--x, set w(v)--w });
+  ({ set z(v){},  set y(v) { return --x; }, set w(v) { return --w; } });
   reportCompare(expect, actual, summary + ': 3');
 
   exitFunc ('test');
 }
--- a/js/src/tests/js1_8_5/regress/regress-607863.js
+++ b/js/src/tests/js1_8_5/regress/regress-607863.js
@@ -1,14 +1,14 @@
 // |reftest| fails-if(!xulRuntime.shell)
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /*
  * Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/licenses/publicdomain/
  */
 
 var sandbox = evalcx('');
-var foreign = evalcx('({ get f() this, set x(v) { result = this } })', sandbox);
+var foreign = evalcx('({ get f() { return this; }, set x(v) { result = this } })', sandbox);
 var local = Object.create(foreign);
 
 reportCompare(local, local.f, "this should be set correctly in getters");
 local.x = 42;
 reportCompare(local, sandbox.result, "this should be set correctly in setters");
--- a/js/src/tests/js1_8_5/regress/regress-646820-1.js
+++ b/js/src/tests/js1_8_5/regress/regress-646820-1.js
@@ -1,9 +1,9 @@
 // Any copyright is dedicated to the Public Domain.
 // http://creativecommons.org/licenses/publicdomain/
 
 (function () {
-    var [x, y] = [1, function () x];
+    var [x, y] = [1, function () { return x; }];
     assertEq(y(), 1);
 })();
 
 reportCompare(0, 0, 'ok');
--- a/js/src/tests/js1_8_5/regress/regress-646820-2.js
+++ b/js/src/tests/js1_8_5/regress/regress-646820-2.js
@@ -1,11 +1,11 @@
 // Any copyright is dedicated to the Public Domain.
 // http://creativecommons.org/licenses/publicdomain/
 
 (function () {
     var obj = {prop: 1};
-    var [x, {prop: y}] = [function () y, obj];
+    var [x, {prop: y}] = [function () { return y; }, obj];
     assertEq(y, 1);
     assertEq(x(), 1);
 })();
 
 reportCompare(0, 0, 'ok');
--- a/js/src/tests/js1_8_5/regress/regress-646820-3.js
+++ b/js/src/tests/js1_8_5/regress/regress-646820-3.js
@@ -1,9 +1,9 @@
 // Any copyright is dedicated to the Public Domain.
 // http://creativecommons.org/licenses/publicdomain/
 
 (function () {
-    var [x, y] = [function () y, 13];
+    var [x, y] = [function () { return y; }, 13];
     assertEq(x(), 13);
 })();
 
 reportCompare(0, 0, 'ok');