Debian Codegraph @

js/src/tests/test262/language/expressions/object/dstr/meth-ary-ptrn-elem-ary-elision-init.js

raw
1 // This file was procedurally generated from the following sources:
2 // - src/dstr-binding/ary-ptrn-elem-ary-elision-init.case
3 // - src/dstr-binding/default/meth.template
4 /*---
5 description: BindingElement with array binding pattern and initializer is used (method)
6 esid: sec-runtime-semantics-definemethod
7 features: [generators, destructuring-binding]
8 flags: [generated]
9 info: |
10 MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody }
11
12 [...]
13 6. Let closure be FunctionCreate(kind, StrictFormalParameters,
14 FunctionBody, scope, strict). If functionPrototype was passed as a
15 parameter then pass its value as the functionPrototype optional argument
16 of FunctionCreate.
17 [...]
18
19 9.2.1 [[Call]] ( thisArgument, argumentsList)
20
21 [...]
22 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
23 [...]
24
25 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
26
27 1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
28 [...]
29
30 9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
31
32 [...]
33 23. Let iteratorRecord be Record {[[iterator]]:
34 CreateListIterator(argumentsList), [[done]]: false}.
35 24. If hasDuplicates is true, then
36 [...]
37 25. Else,
38 b. Let formalStatus be IteratorBindingInitialization for formals with
39 iteratorRecord and env as arguments.
40 [...]
41
42 13.3.3.6 Runtime Semantics: IteratorBindingInitialization
43
44 BindingElement : BindingPatternInitializer opt
45
46 [...]
47 2. If iteratorRecord.[[done]] is true, let v be undefined.
48 3. If Initializer is present and v is undefined, then
49 a. Let defaultValue be the result of evaluating Initializer.
50 b. Let v be ? GetValue(defaultValue).
51 4. Return the result of performing BindingInitialization of BindingPattern
52 with v and environment as the arguments.
53
54 ---*/
55 var first = 0;
56 var second = 0;
57 function* g() {
58 first += 1;
59 yield;
60 second += 1;
61 };
62
63 var callCount = 0;
64 var obj = {
65 method([[,] = g()]) {
66 assert.sameValue(first, 1);
67 assert.sameValue(second, 0);
68 callCount = callCount + 1;
69 }
70 };
71
72 obj.method([]);
73 assert.sameValue(callCount, 1, 'method invoked exactly once');
74
75 reportCompare(0, 0);