same-line-async-gen-computed-names.js (3110B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/class-elements/computed-names.case 4 // - src/class-elements/productions/cls-expr-after-same-line-async-gen.template 5 /*--- 6 description: Computed property names (field definitions after an async generator in the same line) 7 esid: prod-FieldDefinition 8 features: [class-fields-public, computed-property-names, 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 var x = "b"; 24 25 26 27 var C = class { 28 async *m() { return 42; } [x] = 42; [10] = "meep"; ["not initialized"]; 29 30 } 31 32 var c = new C(); 33 34 assert( 35 !Object.prototype.hasOwnProperty.call(c, "m"), 36 "m doesn't appear as an own property on the C instance" 37 ); 38 assert.sameValue(c.m, C.prototype.m); 39 40 verifyProperty(C.prototype, "m", { 41 enumerable: false, 42 configurable: true, 43 writable: true, 44 }, {restore: true}); 45 46 c.m().next().then(function(v) { 47 assert.sameValue(v.value, 42); 48 assert.sameValue(v.done, true); 49 50 function assertions() { 51 // Cover $DONE handler for async cases. 52 function $DONE(error) { 53 if (error) { 54 throw new Test262Error('Test262:AsyncTestFailure') 55 } 56 } 57 assert( 58 !Object.prototype.hasOwnProperty.call(C.prototype, "b"), 59 "b doesn't appear as an own property on C prototype" 60 ); 61 assert( 62 !Object.prototype.hasOwnProperty.call(C, "b"), 63 "b doesn't appear as an own property on C constructor" 64 ); 65 66 verifyProperty(c, "b", { 67 value: 42, 68 enumerable: true, 69 writable: true, 70 configurable: true 71 }); 72 73 assert( 74 !Object.prototype.hasOwnProperty.call(C.prototype, "x"), 75 "x doesn't appear as an own property on C prototype" 76 ); 77 assert( 78 !Object.prototype.hasOwnProperty.call(C, "x"), 79 "x doesn't appear as an own property on C constructor" 80 ); 81 assert( 82 !Object.prototype.hasOwnProperty.call(c, "x"), 83 "x doesn't appear as an own property on C instance" 84 ); 85 86 assert( 87 !Object.prototype.hasOwnProperty.call(C.prototype, "10"), 88 "10 doesn't appear as an own property on C prototype" 89 ); 90 assert( 91 !Object.prototype.hasOwnProperty.call(C, "10"), 92 "10 doesn't appear as an own property on C constructor" 93 ); 94 95 verifyProperty(c, "10", { 96 value: "meep", 97 enumerable: true, 98 writable: true, 99 configurable: true 100 }); 101 102 assert( 103 !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), 104 "'not initialized' doesn't appear as an own property on C prototype" 105 ); 106 assert( 107 !Object.prototype.hasOwnProperty.call(C, "not initialized"), 108 "'not initialized' doesn't appear as an own property on C constructor" 109 ); 110 111 verifyProperty(c, "not initialized", { 112 value: undefined, 113 enumerable: true, 114 writable: true, 115 configurable: true 116 }); 117 } 118 119 return Promise.resolve(assertions()); 120 }).then($DONE, $DONE);