same-line-async-method-computed-names.js (3056B)
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-decl-after-same-line-async-method.template 5 /*--- 6 description: Computed property names (field definitions after an async method in the same line) 7 esid: prod-FieldDefinition 8 features: [class-fields-public, computed-property-names, class, async-functions] 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 class C { 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().then(function(v) { 47 assert.sameValue(v, 42); 48 49 function assertions() { 50 // Cover $DONE handler for async cases. 51 function $DONE(error) { 52 if (error) { 53 throw new Test262Error('Test262:AsyncTestFailure') 54 } 55 } 56 assert( 57 !Object.prototype.hasOwnProperty.call(C.prototype, "b"), 58 "b doesn't appear as an own property on C prototype" 59 ); 60 assert( 61 !Object.prototype.hasOwnProperty.call(C, "b"), 62 "b doesn't appear as an own property on C constructor" 63 ); 64 65 verifyProperty(c, "b", { 66 value: 42, 67 enumerable: true, 68 writable: true, 69 configurable: true 70 }); 71 72 assert( 73 !Object.prototype.hasOwnProperty.call(C.prototype, "x"), 74 "x doesn't appear as an own property on C prototype" 75 ); 76 assert( 77 !Object.prototype.hasOwnProperty.call(C, "x"), 78 "x doesn't appear as an own property on C constructor" 79 ); 80 assert( 81 !Object.prototype.hasOwnProperty.call(c, "x"), 82 "x doesn't appear as an own property on C instance" 83 ); 84 85 assert( 86 !Object.prototype.hasOwnProperty.call(C.prototype, "10"), 87 "10 doesn't appear as an own property on C prototype" 88 ); 89 assert( 90 !Object.prototype.hasOwnProperty.call(C, "10"), 91 "10 doesn't appear as an own property on C constructor" 92 ); 93 94 verifyProperty(c, "10", { 95 value: "meep", 96 enumerable: true, 97 writable: true, 98 configurable: true 99 }); 100 101 assert( 102 !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), 103 "'not initialized' doesn't appear as an own property on C prototype" 104 ); 105 assert( 106 !Object.prototype.hasOwnProperty.call(C, "not initialized"), 107 "'not initialized' doesn't appear as an own property on C constructor" 108 ); 109 110 verifyProperty(c, "not initialized", { 111 value: undefined, 112 enumerable: true, 113 writable: true, 114 configurable: true 115 }); 116 } 117 118 return Promise.resolve(assertions()); 119 }).then($DONE, $DONE);