tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

meth-dflt-obj-ptrn-prop-id-init-skipped.js (3122B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/dstr-binding/obj-ptrn-prop-id-init-skipped.case
      3 // - src/dstr-binding/default/cls-expr-meth-dflt.template
      4 /*---
      5 description: Destructuring initializer is not evaluated when value is not `undefined` (class expression method (default parameter))
      6 esid: sec-class-definitions-runtime-semantics-evaluation
      7 features: [destructuring-binding, default-parameters]
      8 flags: [generated]
      9 info: |
     10    ClassExpression : class BindingIdentifieropt ClassTail
     11 
     12    1. If BindingIdentifieropt is not present, let className be undefined.
     13    2. Else, let className be StringValue of BindingIdentifier.
     14    3. Let value be the result of ClassDefinitionEvaluation of ClassTail
     15       with argument className.
     16    [...]
     17 
     18    14.5.14 Runtime Semantics: ClassDefinitionEvaluation
     19 
     20    21. For each ClassElement m in order from methods
     21        a. If IsStatic of m is false, then
     22           i. Let status be the result of performing
     23              PropertyDefinitionEvaluation for m with arguments proto and
     24              false.
     25        [...]
     26 
     27    14.3.8 Runtime Semantics: DefineMethod
     28 
     29    MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody }
     30 
     31    [...]
     32    6. Let closure be FunctionCreate(kind, StrictFormalParameters, FunctionBody,
     33       scope, strict). If functionPrototype was passed as a parameter then pass its
     34       value as the functionPrototype optional argument of FunctionCreate.
     35    [...]
     36 
     37    9.2.1 [[Call]] ( thisArgument, argumentsList)
     38 
     39    [...]
     40    7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
     41    [...]
     42 
     43    9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
     44 
     45    1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
     46    [...]
     47 
     48    9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
     49 
     50    [...]
     51    23. Let iteratorRecord be Record {[[iterator]]:
     52        CreateListIterator(argumentsList), [[done]]: false}.
     53    24. If hasDuplicates is true, then
     54        [...]
     55    25. Else,
     56        b. Let formalStatus be IteratorBindingInitialization for formals with
     57           iteratorRecord and env as arguments.
     58    [...]
     59 
     60    13.3.3.7 Runtime Semantics: KeyedBindingInitialization
     61 
     62    BindingElement : BindingPattern Initializeropt
     63 
     64    [...]
     65    3. If Initializer is present and v is undefined, then
     66    [...]
     67 ---*/
     68 var initCount = 0;
     69 function counter() {
     70  initCount += 1;
     71 }
     72 
     73 var callCount = 0;
     74 var C = class {
     75  method({ s: t = counter(), u: v = counter(), w: x = counter(), y: z = counter() } = { s: null, u: 0, w: false, y: '' }) {
     76    assert.sameValue(t, null);
     77    assert.sameValue(v, 0);
     78    assert.sameValue(x, false);
     79    assert.sameValue(z, '');
     80    assert.sameValue(initCount, 0);
     81 
     82    assert.throws(ReferenceError, function() {
     83      s;
     84    });
     85    assert.throws(ReferenceError, function() {
     86      u;
     87    });
     88    assert.throws(ReferenceError, function() {
     89      w;
     90    });
     91    assert.throws(ReferenceError, function() {
     92      y;
     93    });
     94    callCount = callCount + 1;
     95  }
     96 };
     97 
     98 new C().method();
     99 assert.sameValue(callCount, 1, 'method invoked exactly once');
    100 
    101 reportCompare(0, 0);