tor-browser

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

meth-params-trailing-comma-single.js (1882B)


      1 // This file was procedurally generated from the following sources:
      2 // - src/function-forms/params-trailing-comma-single.case
      3 // - src/function-forms/default/meth.template
      4 /*---
      5 description: A trailing comma should not increase the respective length, using a single parameter (method)
      6 esid: sec-runtime-semantics-definemethod
      7 flags: [generated]
      8 info: |
      9    MethodDefinition : PropertyName ( StrictFormalParameters ) { FunctionBody }
     10 
     11    [...]
     12    6. Let closure be FunctionCreate(kind, StrictFormalParameters,
     13       FunctionBody, scope, strict). If functionPrototype was passed as a
     14       parameter then pass its value as the functionPrototype optional argument
     15       of FunctionCreate.
     16    [...]
     17 
     18    9.2.1 [[Call]] ( thisArgument, argumentsList)
     19 
     20    [...]
     21    7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
     22    [...]
     23 
     24    9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
     25 
     26    1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
     27    [...]
     28 
     29    9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
     30 
     31    [...]
     32    23. Let iteratorRecord be Record {[[iterator]]:
     33        CreateListIterator(argumentsList), [[done]]: false}.
     34    24. If hasDuplicates is true, then
     35        [...]
     36    25. Else,
     37        b. Let formalStatus be IteratorBindingInitialization for formals with
     38           iteratorRecord and env as arguments.
     39    [...]
     40 
     41    Trailing comma in the parameters list
     42 
     43    14.1 Function Definitions
     44 
     45    FormalParameters[Yield, Await] : FormalParameterList[?Yield, ?Await] ,
     46 ---*/
     47 
     48 var callCount = 0;
     49 var obj = {
     50  method(a,) {
     51    assert.sameValue(a, 42);
     52    callCount = callCount + 1;
     53  }
     54 };
     55 
     56 obj.method(42, 39);
     57 
     58 // Stores a reference `ref` for case evaluation
     59 var ref = obj.method;
     60 
     61 assert.sameValue(callCount, 1, 'method invoked exactly once');
     62 
     63 assert.sameValue(ref.length, 1, 'length is properly set');
     64 
     65 reportCompare(0, 0);