same-line-async-gen-literal-names.js (2583B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/class-elements/literal-names.case 4 // - src/class-elements/productions/cls-expr-after-same-line-async-gen.template 5 /*--- 6 description: Literal property names (field definitions after an async generator in the same line) 7 esid: prod-FieldDefinition 8 features: [class-fields-public, class, async-iteration] 9 flags: [generated, async] 10 includes: [propertyHelper.js] 11 info: | 12 ClassElement: 13 ... 14 FieldDefinition ; 15 16 FieldDefinition: 17 ClassElementName Initializer_opt 18 19 ClassElementName: 20 PropertyName 21 22 ---*/ 23 const fn = function() {} 24 25 26 27 var C = class { 28 async *m() { return 42; } a; b = 42; 29 c = fn; 30 31 } 32 33 var c = new C(); 34 35 assert( 36 !Object.prototype.hasOwnProperty.call(c, "m"), 37 "m doesn't appear as an own property on the C instance" 38 ); 39 assert.sameValue(c.m, C.prototype.m); 40 41 verifyProperty(C.prototype, "m", { 42 enumerable: false, 43 configurable: true, 44 writable: true, 45 }, {restore: true}); 46 47 c.m().next().then(function(v) { 48 assert.sameValue(v.value, 42); 49 assert.sameValue(v.done, true); 50 51 function assertions() { 52 // Cover $DONE handler for async cases. 53 function $DONE(error) { 54 if (error) { 55 throw new Test262Error('Test262:AsyncTestFailure') 56 } 57 } 58 assert( 59 !Object.prototype.hasOwnProperty.call(C.prototype, "a"), 60 "a doesn't appear as an own property on C prototype" 61 ); 62 assert( 63 !Object.prototype.hasOwnProperty.call(C, "a"), 64 "a doesn't appear as an own property on C constructor" 65 ); 66 67 verifyProperty(c, "a", { 68 value: undefined, 69 enumerable: true, 70 writable: true, 71 configurable: true 72 }); 73 74 assert( 75 !Object.prototype.hasOwnProperty.call(C.prototype, "b"), 76 "b doesn't appear as an own property on C prototype" 77 ); 78 assert( 79 !Object.prototype.hasOwnProperty.call(C, "b"), 80 "b doesn't appear as an own property on C constructor" 81 ); 82 83 verifyProperty(c, "b", { 84 value: 42, 85 enumerable: true, 86 writable: true, 87 configurable: true 88 }); 89 90 assert( 91 !Object.prototype.hasOwnProperty.call(C.prototype, "c"), 92 "c doesn't appear as an own property on C prototype" 93 ); 94 assert( 95 !Object.prototype.hasOwnProperty.call(C, "c"), 96 "c doesn't appear as an own property on C constructor" 97 ); 98 99 verifyProperty(c, "c", { 100 value: fn, 101 enumerable: true, 102 writable: true, 103 configurable: true 104 }); 105 106 } 107 108 return Promise.resolve(assertions()); 109 }).then($DONE, $DONE);