yield-identifier-spread-strict-strict.js (2049B)
1 // |reftest| error:SyntaxError 2 'use strict'; 3 // This file was procedurally generated from the following sources: 4 // - src/generators/yield-identifier-spread-strict.case 5 // - src/generators/default/class-expr-static-private-method.template 6 /*--- 7 description: It's an early error if the AssignmentExpression is a function body with yield as an identifier in strict mode. (Static generator private method as a ClassExpression element) 8 esid: prod-GeneratorPrivateMethod 9 features: [object-spread, 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 Spread Properties 28 29 PropertyDefinition[Yield]: 30 (...) 31 ...AssignmentExpression[In, ?Yield] 32 33 ---*/ 34 $DONOTEVALUATE(); 35 36 var callCount = 0; 37 38 var C = class { 39 static *#gen() { 40 callCount += 1; 41 return { 42 ...(function() { 43 var yield; 44 throw new Test262Error(); 45 }()), 46 } 47 } 48 static get gen() { return this.#gen; } 49 } 50 51 // Test the private fields do not appear as properties before set to value 52 assert( 53 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 54 "Private field '#gen' does not appear as an own property on C prototype" 55 ); 56 assert( 57 !Object.prototype.hasOwnProperty.call(C, "#gen"), 58 "Private field '#gen' does not appear as an own property on C constructor" 59 ); 60 61 var iter = C.gen(); 62 63 64 65 assert.sameValue(callCount, 1); 66 67 // Test the private fields do not appear as properties before set to value 68 assert( 69 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 70 "Private field '#gen' does not appear as an own property on C prototype" 71 ); 72 assert( 73 !Object.prototype.hasOwnProperty.call(C, "#gen"), 74 "Private field '#gen' does not appear as an own property on C constructor" 75 );