Debian Codegraph @

js/src/tests/test262/language/expressions/async-generator/dstr/named-dflt-obj-ptrn-prop-id-init-skipped.js

raw
1 // |reftest| async
2 // This file was procedurally generated from the following sources:
3 // - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case
4 // - src/dstr-binding/default/async-gen-func-named-expr-dflt.template
5 /*---
6 description: Destructuring initializer is not evaluated when value is not `undefined` (async generator named function expression (default parameter))
7 esid: sec-asyncgenerator-definitions-evaluation
8 features: [async-iteration]
9 flags: [generated, async]
10 info: |
11 AsyncGeneratorExpression : async [no LineTerminator here] function * BindingIdentifier
12 ( FormalParameters ) { AsyncGeneratorBody }
13
14 [...]
15 7. Let closure be ! AsyncGeneratorFunctionCreate(Normal, FormalParameters,
16 AsyncGeneratorBody, funcEnv, strict).
17 [...]
18
19
20 13.3.3.7 Runtime Semantics: KeyedBindingInitialization
21
22 BindingElement : BindingPattern Initializeropt
23
24 [...]
25 3. If Initializer is present and v is undefined, then
26 [...]
27 ---*/
28 var initCount = 0;
29 function counter() {
30 initCount += 1;
31 }
32
33
34 var callCount = 0;
35 var f;
36 f = async function* h({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) {
37 assert.sameValue(t, null);
38 assert.sameValue(v, 0);
39 assert.sameValue(x, false);
40 assert.sameValue(z, '');
41 assert.sameValue(initCount, 0);
42
43 assert.throws(ReferenceError, function() {
44 s;
45 });
46 assert.throws(ReferenceError, function() {
47 u;
48 });
49 assert.throws(ReferenceError, function() {
50 w;
51 });
52 assert.throws(ReferenceError, function() {
53 y;
54 });
55 callCount = callCount + 1;
56 };
57
58 f().next().then(() => {
59 assert.sameValue(callCount, 1, 'invoked exactly once');
60 }).then($DONE, $DONE);