Debian Codegraph @

js/src/tests/test262/language/expressions/object/dstr/async-gen-meth-ary-ptrn-rest-id-elision.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/dstr-binding/ary-ptrn-rest-id-elision.case
4 // - src/dstr-binding/default/async-gen-meth.template
5 /*---
6 description: Rest element following elision elements (async generator method)
7 esid: sec-asyncgenerator-definitions-propertydefinitionevaluation
8 features: [async-iteration]
9 flags: [generated, async]
10 info: |
11 AsyncGeneratorMethod :
12 async [no LineTerminator here] * PropertyName ( UniqueFormalParameters )
13 { AsyncGeneratorBody }
14
15 1. Let propKey be the result of evaluating PropertyName.
16 2. ReturnIfAbrupt(propKey).
17 3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true.
18 Otherwise let strict be false.
19 4. Let scope be the running execution context's LexicalEnvironment.
20 5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters,
21 AsyncGeneratorBody, scope, strict).
22 [...]
23
24
25 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
26 ArrayBindingPattern : [ Elisionopt BindingRestElement ]
27 1. If Elision is present, then
28 a. Let status be the result of performing
29 IteratorDestructuringAssignmentEvaluation of Elision with
30 iteratorRecord as the argument.
31 b. ReturnIfAbrupt(status).
32 2. Return the result of performing IteratorBindingInitialization for
33 BindingRestElement with iteratorRecord and environment as arguments.
34 ---*/
35 var values = [1, 2, 3, 4, 5];
36
37
38 var callCount = 0;
39 var obj = {
40 async *method([ , , ...x]) {
41 assert(Array.isArray(x));
42 assert.sameValue(x.length, 3);
43 assert.sameValue(x[0], 3);
44 assert.sameValue(x[1], 4);
45 assert.sameValue(x[2], 5);
46 assert.notSameValue(x, values);
47 callCount = callCount + 1;
48 }
49 };
50
51 obj.method(values).next().then(() => {
52 assert.sameValue(callCount, 1, 'invoked exactly once');
53 }).then($DONE, $DONE);