yield-identifier-spread-strict-strict.js (2300B)
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-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. (Generator private method as a ClassExpression element) 8 esid: prod-GeneratorPrivateMethod 9 features: [object-spread, generators, class-methods-private] 10 flags: [generated, onlyStrict] 11 negative: 12 phase: parse 13 type: SyntaxError 14 info: | 15 ClassElement : 16 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 *#gen() { 40 callCount += 1; 41 return { 42 ...(function() { 43 var yield; 44 throw new Test262Error(); 45 }()), 46 } 47 } 48 get gen() { return this.#gen; } 49 } 50 51 const c = new C(); 52 53 // Test the private fields do not appear as properties before set to value 54 assert( 55 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 56 "Private field '#gen' does not appear as an own property on C prototype" 57 ); 58 assert( 59 !Object.prototype.hasOwnProperty.call(C, "#gen"), 60 "Private field '#gen' does not appear as an own property on C constructor" 61 ); 62 assert( 63 !Object.prototype.hasOwnProperty.call(c, "#gen"), 64 "Private field '#gen' does not appear as an own property on C instance" 65 ); 66 67 var iter = c.gen(); 68 69 70 71 assert.sameValue(callCount, 1); 72 73 // Test the private fields do not appear as properties after set to value 74 assert( 75 !Object.prototype.hasOwnProperty.call(C.prototype, "#gen"), 76 "Private field '#gen' does not appear as an own property on C prototype" 77 ); 78 assert( 79 !Object.prototype.hasOwnProperty.call(C, "#gen"), 80 "Private field '#gen' does not appear as an own property on C constructor" 81 ); 82 assert( 83 !Object.prototype.hasOwnProperty.call(c, "#gen"), 84 "Private field '#gen' does not appear as an own property on C instance" 85 );