tor-browser

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

dflt-params-arg-val-not-undefined.js (3196B)


      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/cls-decl-async-meth-static.template
      5 /*---
      6 description: Use of initializer when argument value is not `undefined` (static class declaration async method)
      7 esid: sec-runtime-semantics-bindingclassdeclarationevaluation
      8 features: [default-parameters, async-functions]
      9 flags: [generated, async]
     10 info: |
     11    ClassDeclaration : class BindingIdentifier ClassTail
     12 
     13    1. Let className be StringValue of BindingIdentifier.
     14    2. Let value be the result of ClassDefinitionEvaluation of ClassTail with
     15       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        b. Else,
     23           Let status be the result of performing PropertyDefinitionEvaluation for
     24           m with arguments F and false.
     25    [...]
     26 
     27    Runtime Semantics: PropertyDefinitionEvaluation
     28 
     29    AsyncMethod : async PropertyName ( UniqueFormalParameters ) { AsyncFunctionBody }
     30 
     31    1. Let propKey be the result of evaluating PropertyName.
     32    2. ReturnIfAbrupt(propKey).
     33    3. If the function code for this AsyncMethod is strict mode code, let strict be true. Otherwise
     34       let strict be false.
     35    4. Let scope be the LexicalEnvironment of the running execution context.
     36    5. Let closure be ! AsyncFunctionCreate(Method, UniqueFormalParameters, AsyncFunctionBody,
     37       scope, strict).
     38    [...]
     39 
     40 
     41    14.1.19 Runtime Semantics: IteratorBindingInitialization
     42 
     43    FormalsList : FormalsList , FormalParameter
     44 
     45    [...]
     46    23. Let iteratorRecord be Record {[[Iterator]]:
     47        CreateListIterator(argumentsList), [[Done]]: false}.
     48    24. If hasDuplicates is true, then
     49        [...]
     50    25. Else,
     51        a. Perform ? IteratorBindingInitialization for formals with
     52           iteratorRecord and env as arguments.
     53    [...]
     54 
     55 ---*/
     56 var obj = {};
     57 var falseCount = 0;
     58 var stringCount = 0;
     59 var nanCount = 0;
     60 var zeroCount = 0;
     61 var nullCount = 0;
     62 var objCount = 0;
     63 
     64 
     65 var callCount = 0;
     66 class C {
     67  static async method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) {
     68    assert.sameValue(aFalse, false);
     69    assert.sameValue(aString, '');
     70    assert.sameValue(aNaN, NaN);
     71    assert.sameValue(a0, 0);
     72    assert.sameValue(aNull, null);
     73    assert.sameValue(aObj, obj);
     74    callCount = callCount + 1;
     75  }
     76 }
     77 
     78 // Stores a reference `ref` for case evaluation
     79 var ref = C.method;
     80 
     81 ref(false, '', NaN, 0, null, obj).then(() => {
     82    assert.sameValue(callCount, 1, 'method invoked exactly once');
     83 }).then($DONE, $DONE);
     84 
     85 assert.sameValue(falseCount, 0, 'initializer not evaluated: false');
     86 assert.sameValue(stringCount, 0, 'initializer not evaluated: string');
     87 assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN');
     88 assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0');
     89 assert.sameValue(nullCount, 0, 'initializer not evaluated: null');
     90 assert.sameValue(objCount, 0, 'initializer not evaluated: object');