Bug 1414805 - Add more tests for other cases of parsing ternary expressions ending in an arrow function with block body, that aren't already covered in the existing test. r=arai
authorJeff Walden <jwalden@mit.edu>
Tue, 07 Nov 2017 16:06:07 -0800
changeset 444109 eed73ebe0266c7263da00ce634959983edfb8f35
parent 444108 d8441c69c0831e7b497991ff20c8fb09506afd9b
child 444110 af596055be2169def86749be7d8c8e4fbf3ede2f
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1414805
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1414805 - Add more tests for other cases of parsing ternary expressions ending in an arrow function with block body, that aren't already covered in the existing test. r=arai
js/src/tests/ecma_6/ArrowFunctions/arrow-not-as-end-of-statement.js
--- a/js/src/tests/ecma_6/ArrowFunctions/arrow-not-as-end-of-statement.js
+++ b/js/src/tests/ecma_6/ArrowFunctions/arrow-not-as-end-of-statement.js
@@ -3,22 +3,74 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // Grab-bag of ArrowFunctions with block bodies appearing in contexts where the
 // subsequent token-examination must use the Operand modifier to avoid an
 // assertion.
 
 assertEq(`x ${a => {}} z`, "x a => {} z");
 
+for (a => {}; ; )
+  break;
+
 for (; a => {}; )
   break;
 
 for (; ; a => {})
   break;
 
+Function.prototype[Symbol.iterator] = function() { return { next() { return { done: true }; } }; };
+for (let m of 0 ? 1 : a => {})
+  assertEq(true, false);
+for (let [m] of 0 ? 1 : a => {})
+  assertEq(true, false);
+delete Function.prototype[Symbol.iterator];
+
+for (let w in 0 ? 1 : a => {})
+  break;
+for (let [w] in 0 ? 1 : a => {})
+  break;
+
+function* stargen()
+{
+  yield a => {}
+  /Q/g;
+
+  var first = true;
+  Function.prototype[Symbol.iterator] = function() {
+    return {
+      next() {
+        var res = { done: true, value: 8675309 };
+        if (first)
+        {
+          res = { value: "fnord", done: false };
+          first = false;
+        }
+
+        return res;
+      }
+    };
+  };
+
+
+  yield* a => {}
+  /Q/g;
+
+  delete Function.prototype[Symbol.iterator];
+
+  yield 99;
+}
+var gen = stargen();
+assertEq(typeof gen.next().value, "function");
+var result = gen.next();
+assertEq(result.value, "fnord");
+assertEq(result.done, false);
+assertEq(gen.next().value, 99);
+assertEq(gen.next().done, true);
+
 switch (1)
 {
   case a => {}:
    break;
 }
 
 try
 {
@@ -48,16 +100,17 @@ else
 
 switch (a => {})
 {
 }
 
 with (a => {});
 
 assertEq(typeof (a => {}), "function");
+assertEq(typeof (a => b => {}), "function");
 
 for (var x in y => {})
   continue;
 
 assertEq(eval("a => {}, 17, 42;"), 42);
 assertEq(eval("42, a => {}, 17;"), 17);
 assertEq(typeof eval("17, 42, a => {};"), "function");
 
@@ -96,13 +149,29 @@ assertEq(typeof zoom, "function");
 var { b = 0 ? 1 : a => {} } = {};
 assertEq(typeof b, "function");
 
 var [k = 0 ? 1 : a => {}] = [];
 assertEq(typeof k, "function");
 
 assertEq(typeof [0 ? 1 : a => {}][0], "function");
 
+Function.prototype[Symbol.iterator] = function() { return { next() { return { done: true }; } }; };
+assertEq([...0 ? 1 : a => {}].length, 0);
+delete Function.prototype[Symbol.iterator];
+
+var props = Object.getOwnPropertyNames({ ...0 ? 1 : a => {} }).sort();
+assertEq(props.length, 0);
+
+var asyncf = async () => {};
+assertEq(typeof asyncf, "function");
+
 var { [0 ? 1 : a => {}]: h } = { "a => {}": "boo-urns!" };
 assertEq(h, "boo-urns!");
 
+var gencomp = (for (prop of [0]) 0 ? 1 : a => {});
+assertEq(typeof gencomp.next().value, "function");
+
+var arrcomp = [for (prop of [0]) 0 ? 1 : a => {}];
+assertEq(typeof arrcomp[0], "function");
+
 if (typeof reportCompare === "function")
   reportCompare(true, true);