Debian Codegraph @

js/src/tests/test262/built-ins/AsyncFunction/AsyncFunction-construct.js

raw
1 // Copyright 2016 Microsoft, Inc. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 author: Brian Terlson <[email protected]>
6 esid: sec-async-function-constructor
7 description: >
8 %AsyncFunction% creates functions with or without new and handles arguments
9 similarly to functions.
10 ---*/
11
12 var AsyncFunction = async function foo() {}.constructor;
13 var fn;
14
15 fn = AsyncFunction("a", "await 1;");
16 assert.sameValue(fn.length, 1, "length with 1 argument, call");
17
18 fn = AsyncFunction("a,b", "await 1;");
19 assert.sameValue(fn.length, 2, "length with 2 arguments in one, call");
20
21 fn = AsyncFunction("a", "b", "await 1;");
22 assert.sameValue(fn.length, 2, "length with 2 arguments, call");
23
24 fn = new AsyncFunction("a", "await 1;");
25 assert.sameValue(fn.length, 1, "length with 1 argument, construct");
26
27 fn = new AsyncFunction("a,b", "await 1;");
28 assert.sameValue(fn.length, 2, "length with 2 arguments in one, construct");
29
30 fn = new AsyncFunction("a", "b", "await 1;");
31 assert.sameValue(fn.length, 2, "length with 2 arguments, construct");
32
33 reportCompare(0, 0);