tor-browser

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

async-gen-meth-dflt-params-arg-val-not-undefined.js (2667B)


      1 // |reftest| async
      2 // This file was procedurally generated from the following sources:
      3 // - src/function-forms/dflt-params-arg-val-not-undefined.case
      4 // - src/function-forms/default/async-gen-meth.template
      5 /*---
      6 description: Use of initializer when argument value is not `undefined` (async generator method)
      7 esid: sec-asyncgenerator-definitions-propertydefinitionevaluation
      8 features: [default-parameters, async-iteration]
      9 flags: [generated, async]
     10 info: |
     11    AsyncGeneratorMethod :
     12        async [no LineTerminator here] * PropertyName ( UniqueFormalParameters )
     13            { AsyncGeneratorBody }
     14 
     15    1. Let propKey be the result of evaluating PropertyName.
     16    2. ReturnIfAbrupt(propKey).
     17    3. If the function code for this AsyncGeneratorMethod is strict mode code, let strict be true.
     18       Otherwise let strict be false.
     19    4. Let scope be the running execution context's LexicalEnvironment.
     20    5. Let closure be ! AsyncGeneratorFunctionCreate(Method, UniqueFormalParameters,
     21       AsyncGeneratorBody, scope, strict).
     22    [...]
     23 
     24 
     25    14.1.19 Runtime Semantics: IteratorBindingInitialization
     26 
     27    FormalsList : FormalsList , FormalParameter
     28 
     29    [...]
     30    23. Let iteratorRecord be Record {[[Iterator]]:
     31        CreateListIterator(argumentsList), [[Done]]: false}.
     32    24. If hasDuplicates is true, then
     33        [...]
     34    25. Else,
     35        a. Perform ? IteratorBindingInitialization for formals with
     36           iteratorRecord and env as arguments.
     37    [...]
     38 
     39 ---*/
     40 var obj = {};
     41 var falseCount = 0;
     42 var stringCount = 0;
     43 var nanCount = 0;
     44 var zeroCount = 0;
     45 var nullCount = 0;
     46 var objCount = 0;
     47 
     48 var callCount = 0;
     49 var obj = {
     50  async *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) {
     51    assert.sameValue(aFalse, false);
     52    assert.sameValue(aString, '');
     53    assert.sameValue(aNaN, NaN);
     54    assert.sameValue(a0, 0);
     55    assert.sameValue(aNull, null);
     56    assert.sameValue(aObj, obj);
     57    callCount = callCount + 1;
     58  }
     59 };
     60 
     61 // Stores a reference `ref` for case evaluation
     62 var ref = obj.method;
     63 
     64 ref(false, '', NaN, 0, null, obj).next().then(() => {
     65    assert.sameValue(callCount, 1, 'generator method invoked exactly once');
     66 }).then($DONE, $DONE);
     67 
     68 assert.sameValue(falseCount, 0, 'initializer not evaluated: false');
     69 assert.sameValue(stringCount, 0, 'initializer not evaluated: string');
     70 assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN');
     71 assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0');
     72 assert.sameValue(nullCount, 0, 'initializer not evaluated: null');
     73 assert.sameValue(objCount, 0, 'initializer not evaluated: object');