tor-browser

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

params-dflt-gen-meth-args-unmapped.js (2898B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 description: Referencing the arguments object from a default parameter (generator method)
      5 esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation
      6 es6id: 14.4.13
      7 features: [generators, default-parameters]
      8 info: |
      9    GeneratorMethod :
     10        * PropertyName ( StrictFormalParameters ) { GeneratorBody }
     11 
     12    1. Let propKey be the result of evaluating PropertyName.
     13    2. ReturnIfAbrupt(propKey).
     14    3. If the function code for this GeneratorMethod is strict mode code,
     15       let strict be true. Otherwise let strict be false.
     16    4. Let scope be the running execution context's LexicalEnvironment.
     17    5. Let closure be GeneratorFunctionCreate(Method,
     18       StrictFormalParameters, GeneratorBody, scope, strict).
     19    [...]
     20 
     21    9.2.1 [[Call]] ( thisArgument, argumentsList)
     22 
     23    [...]
     24    7. Let result be OrdinaryCallEvaluateBody(F, argumentsList).
     25    [...]
     26 
     27    9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList )
     28 
     29    1. Let status be FunctionDeclarationInstantiation(F, argumentsList).
     30    [...]
     31 
     32    9.2.12 FunctionDeclarationInstantiation(func, argumentsList)
     33 
     34    [...]
     35    23. Let iteratorRecord be Record {[[iterator]]:
     36        CreateListIterator(argumentsList), [[done]]: false}.
     37    24. If hasDuplicates is true, then
     38        [...]
     39    25. Else,
     40        b. Let formalStatus be IteratorBindingInitialization for formals with
     41           iteratorRecord and env as arguments.
     42    [...]
     43 
     44    14.1.19 Runtime Semantics: IteratorBindingInitialization
     45 
     46    FormalsList : FormalsList , FormalParameter
     47 
     48    1. Let status be the result of performing IteratorBindingInitialization for
     49       FormalsList using iteratorRecord and environment as the arguments.
     50    2. ReturnIfAbrupt(status).
     51    3. Return the result of performing IteratorBindingInitialization for
     52       FormalParameter using iteratorRecord and environment as the arguments.
     53 ---*/
     54 
     55 var callCount = 0;
     56 var obj = {
     57  *method(x, _ = 0) {
     58    assert.sameValue(x, undefined, 'parameter binding value (initial)');
     59    assert.sameValue(
     60      arguments[0], undefined, 'arguments property value (initial)'
     61    );
     62 
     63    arguments[0] = 1;
     64 
     65    assert.sameValue(
     66      x, undefined, 'parameter binding value (after arguments modification)'
     67    );
     68    assert.sameValue(
     69      arguments[0], 1, 'arguments property value (after arguments modification)'
     70    );
     71 
     72    x = 2;
     73 
     74    assert.sameValue(
     75      x, 2, 'parameter binding value (after parameter binding modification)'
     76    );
     77    assert.sameValue(
     78      arguments[0],
     79      1,
     80      'arguments property value (after parameter binding modification)'
     81    );
     82    callCount = callCount + 1;
     83  }
     84 };
     85 
     86 obj.method().next();
     87 
     88 assert.sameValue(callCount, 1, 'generator method invoked exactly once');
     89 
     90 reportCompare(0, 0);