Bug 1185106 - Part 11.5: Add async function constructor and prototype. r=till draft
authorTooru Fujisawa <arai_a@mac.com>
Mon, 29 Aug 2016 02:06:19 +0900
changeset 430950 833a7b8c298bcacc012458432f484133e971e1d4
parent 430949 a14def6ea642dea7a71c7314c93f70657aac525a
child 430951 37bce14e7c4840dba90256f4f7fe1575ca226733
push id33945
push userarai_a@mac.com
push dateFri, 28 Oct 2016 11:34:02 +0000
reviewerstill
bugs1185106
milestone52.0a1
Bug 1185106 - Part 11.5: Add async function constructor and prototype. r=till MozReview-Commit-ID: DKdeWuAdhrY
js/src/tests/ecma_7/AsyncFunctions/constructor.js
new file mode 100644
--- /dev/null
+++ b/js/src/tests/ecma_7/AsyncFunctions/constructor.js
@@ -0,0 +1,40 @@
+var BUGNUMBER = 1185106;
+var summary = "async function constructor and prototype";
+
+print(BUGNUMBER + ": " + summary);
+
+var test = `
+
+var f1 = async function() {};
+
+var AsyncFunction = f1.constructor;
+var AsyncFunctionPrototype = AsyncFunction.prototype;
+
+assertEq(AsyncFunction.name, "AsyncFunction");
+assertEq(AsyncFunction.length, 1);
+assertEq(Object.getPrototypeOf(async function() {}), AsyncFunctionPrototype);
+
+assertEq(AsyncFunctionPrototype.constructor, AsyncFunction);
+
+var f2 = AsyncFunction("await 1");
+assertEq(f2.constructor, AsyncFunction);
+assertEq(f2.length, 0);
+assertEq(Object.getPrototypeOf(f2), AsyncFunctionPrototype);
+
+var f3 = new AsyncFunction("await 1");
+assertEq(f3.constructor, AsyncFunction);
+assertEq(f3.length, 0);
+assertEq(Object.getPrototypeOf(f3), AsyncFunctionPrototype);
+
+var f4 = AsyncFunction("a", "b", "c", "await 1");
+assertEq(f4.constructor, AsyncFunction);
+assertEq(f4.length, 3);
+assertEq(Object.getPrototypeOf(f4), AsyncFunctionPrototype);
+
+`;
+
+if (asyncFunctionsEnabled())
+    eval(test);
+
+if (typeof reportCompare === "function")
+    reportCompare(true, true);