same-line-async-gen-computed-symbol-names.js (3061B)
1 // |reftest| async 2 // This file was procedurally generated from the following sources: 3 // - src/class-elements/computed-symbol-names.case 4 // - src/class-elements/productions/cls-expr-after-same-line-async-gen.template 5 /*--- 6 description: Computed property symbol names (field definitions after an async generator in the same line) 7 esid: prod-FieldDefinition 8 features: [class-fields-public, Symbol, 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 = Symbol(); 24 var y = Symbol(); 25 26 27 28 var C = class { 29 async *m() { return 42; } [x]; [y] = 42; 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, x), 60 "Symbol x doesn't appear as an own property on C prototype" 61 ); 62 assert( 63 !Object.prototype.hasOwnProperty.call(C, x), 64 "Symbol x doesn't appear as an own property on C constructor" 65 ); 66 67 verifyProperty(c, x, { 68 value: undefined, 69 enumerable: true, 70 writable: true, 71 configurable: true 72 }); 73 74 assert( 75 !Object.prototype.hasOwnProperty.call(C.prototype, y), 76 "Symbol y doesn't appear as an own property on C prototype" 77 ); 78 assert( 79 !Object.prototype.hasOwnProperty.call(C, y), 80 "Symbol y doesn't appear as an own property on C constructor" 81 ); 82 83 verifyProperty(c, y, { 84 value: 42, 85 enumerable: true, 86 writable: true, 87 configurable: true 88 }); 89 90 assert( 91 !Object.prototype.hasOwnProperty.call(C.prototype, "x"), 92 "x doesn't appear as an own property on C prototype" 93 ); 94 assert( 95 !Object.prototype.hasOwnProperty.call(C, "x"), 96 "x doesn't appear as an own property on C constructor" 97 ); 98 assert( 99 !Object.prototype.hasOwnProperty.call(c, "x"), 100 "x doesn't appear as an own property on C instance" 101 ); 102 103 assert( 104 !Object.prototype.hasOwnProperty.call(C.prototype, "y"), 105 "y doesn't appear as an own property on C prototype" 106 ); 107 assert( 108 !Object.prototype.hasOwnProperty.call(C, "y"), 109 "y doesn't appear as an own property on C constructor" 110 ); 111 assert( 112 !Object.prototype.hasOwnProperty.call(c, "y"), 113 "y doesn't appear as an own property on C instance" 114 ); 115 } 116 117 return Promise.resolve(assertions()); 118 }).then($DONE, $DONE);