gen-meth-dflt-params-arg-val-not-undefined.js (3234B)
1 // This file was procedurally generated from the following sources: 2 // - src/function-forms/dflt-params-arg-val-not-undefined.case 3 // - src/function-forms/default/gen-meth.template 4 /*--- 5 description: Use of initializer when argument value is not `undefined` (generator method) 6 esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation 7 features: [default-parameters, generators] 8 flags: [generated] 9 info: | 10 GeneratorMethod : 11 * PropertyName ( StrictFormalParameters ) { GeneratorBody } 12 13 1. Let propKey be the result of evaluating PropertyName. 14 2. ReturnIfAbrupt(propKey). 15 3. If the function code for this GeneratorMethod is strict mode code, 16 let strict be true. Otherwise let strict be false. 17 4. Let scope be the running execution context's LexicalEnvironment. 18 5. Let closure be GeneratorFunctionCreate(Method, 19 StrictFormalParameters, GeneratorBody, scope, strict). 20 [...] 21 22 9.2.1 [[Call]] ( thisArgument, argumentsList) 23 24 [...] 25 7. Let result be OrdinaryCallEvaluateBody(F, argumentsList). 26 [...] 27 28 9.2.1.3 OrdinaryCallEvaluateBody ( F, argumentsList ) 29 30 1. Let status be FunctionDeclarationInstantiation(F, argumentsList). 31 [...] 32 33 9.2.12 FunctionDeclarationInstantiation(func, argumentsList) 34 35 [...] 36 23. Let iteratorRecord be Record {[[iterator]]: 37 CreateListIterator(argumentsList), [[done]]: false}. 38 24. If hasDuplicates is true, then 39 [...] 40 25. Else, 41 b. Let formalStatus be IteratorBindingInitialization for formals with 42 iteratorRecord and env as arguments. 43 [...] 44 45 46 14.1.19 Runtime Semantics: IteratorBindingInitialization 47 48 FormalsList : FormalsList , FormalParameter 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 a. Perform ? IteratorBindingInitialization for formals with 57 iteratorRecord and env as arguments. 58 [...] 59 60 ---*/ 61 var obj = {}; 62 var falseCount = 0; 63 var stringCount = 0; 64 var nanCount = 0; 65 var zeroCount = 0; 66 var nullCount = 0; 67 var objCount = 0; 68 69 var callCount = 0; 70 var obj = { 71 *method(aFalse = falseCount +=1, aString = stringCount += 1, aNaN = nanCount += 1, a0 = zeroCount += 1, aNull = nullCount += 1, aObj = objCount +=1) { 72 assert.sameValue(aFalse, false); 73 assert.sameValue(aString, ''); 74 assert.sameValue(aNaN, NaN); 75 assert.sameValue(a0, 0); 76 assert.sameValue(aNull, null); 77 assert.sameValue(aObj, obj); 78 callCount = callCount + 1; 79 } 80 }; 81 82 obj.method(false, '', NaN, 0, null, obj).next(); 83 84 // Stores a reference `ref` for case evaluation 85 var ref = obj.method; 86 87 assert.sameValue(callCount, 1, 'generator method invoked exactly once'); 88 89 assert.sameValue(falseCount, 0, 'initializer not evaluated: false'); 90 assert.sameValue(stringCount, 0, 'initializer not evaluated: string'); 91 assert.sameValue(nanCount, 0, 'initializer not evaluated: NaN'); 92 assert.sameValue(zeroCount, 0, 'initializer not evaluated: 0'); 93 assert.sameValue(nullCount, 0, 'initializer not evaluated: null'); 94 assert.sameValue(objCount, 0, 'initializer not evaluated: object'); 95 96 reportCompare(0, 0);