yield-identifier-strict-strict.js (1864B)
1 // |reftest| error:SyntaxError 2 'use strict'; 3 // This file was procedurally generated from the following sources: 4 // - src/generators/yield-identifier-strict.case 5 // - src/generators/default/class-decl-static-private-method.template 6 /*--- 7 description: It's an early error if the generator body has another function body with yield as an identifier in strict mode. (Static generator private method as a ClassDeclaration element) 8 esid: prod-GeneratorPrivateMethod 9 features: [generators, class-static-methods-private] 10 flags: [generated, onlyStrict] 11 negative: 12 phase: parse 13 type: SyntaxError 14 info: | 15 ClassElement : 16 static PrivateMethodDefinition 17 18 MethodDefinition : 19 GeneratorMethod 20 21 14.4 Generator Function Definitions 22 23 GeneratorMethod : 24 * PropertyName ( UniqueFormalParameters ) { GeneratorBody } 25 26 ---*/ 27 $DONOTEVALUATE(); 28 29 var callCount = 0; 30 31 class C { 32 static *#gen() { 33 callCount += 1; 34 (function() { 35 var yield; 36 throw new Test262Error(); 37 }()) 38 } 39 static get gen() { return this.#gen; } 40 } 41 42 // Test the private fields do not appear as properties before set to value 43 assert( 44 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 45 "Private field '#gen' does not appear as an own property on C prototype" 46 ); 47 assert( 48 !Object.prototype.hasOwnProperty.call(C, "#gen"), 49 "Private field '#gen' does not appear as an own property on C constructor" 50 ); 51 52 var iter = C.gen(); 53 54 55 56 assert.sameValue(callCount, 1); 57 58 // Test the private fields do not appear as properties before set to value 59 assert( 60 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 61 "Private field '#gen' does not appear as an own property on C prototype" 62 ); 63 assert( 64 !Object.prototype.hasOwnProperty.call(C, "#gen"), 65 "Private field '#gen' does not appear as an own property on C constructor" 66 );