multiple-definitions-computed-names.js (3643B)
1 // This file was procedurally generated from the following sources: 2 // - src/class-elements/computed-names.case 3 // - src/class-elements/productions/cls-expr-multiple-definitions.template 4 /*--- 5 description: Computed property names (multiple fields definitions) 6 esid: prod-FieldDefinition 7 features: [class-fields-public, computed-property-names, class] 8 flags: [generated] 9 includes: [propertyHelper.js] 10 info: | 11 ClassElement: 12 ... 13 FieldDefinition ; 14 15 FieldDefinition: 16 ClassElementName Initializer_opt 17 18 ClassElementName: 19 PropertyName 20 21 ---*/ 22 var x = "b"; 23 24 25 26 var C = class { 27 foo = "foobar"; 28 m() { return 42 } 29 [x] = 42; [10] = "meep"; ["not initialized"] 30 m2() { return 39 } 31 bar = "barbaz"; 32 33 } 34 35 var c = new C(); 36 37 assert.sameValue(c.m(), 42); 38 assert( 39 !Object.prototype.hasOwnProperty.call(c, "m"), 40 "m doesn't appear as an own property on the C instance" 41 ); 42 assert.sameValue(c.m, C.prototype.m); 43 44 verifyProperty(C.prototype, "m", { 45 enumerable: false, 46 configurable: true, 47 writable: true, 48 }); 49 50 assert.sameValue(c.m2(), 39); 51 assert( 52 !Object.prototype.hasOwnProperty.call(c, "m2"), 53 "m2 doesn't appear as an own property on the C instance" 54 ); 55 assert.sameValue(c.m2, C.prototype.m2); 56 57 verifyProperty(C.prototype, "m2", { 58 enumerable: false, 59 configurable: true, 60 writable: true, 61 }); 62 63 assert.sameValue(c.foo, "foobar"); 64 assert( 65 !Object.prototype.hasOwnProperty.call(C, "foo"), 66 "foo doesn't appear as an own property on the C constructor" 67 ); 68 assert( 69 !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), 70 "foo doesn't appear as an own property on the C prototype" 71 ); 72 73 verifyProperty(c, "foo", { 74 value: "foobar", 75 enumerable: true, 76 configurable: true, 77 writable: true, 78 }); 79 80 assert.sameValue(c.bar, "barbaz"); 81 assert( 82 !Object.prototype.hasOwnProperty.call(C, "bar"), 83 "bar doesn't appear as an own property on the C constructor" 84 ); 85 assert( 86 !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), 87 "bar doesn't appear as an own property on the C prototype" 88 ); 89 90 verifyProperty(c, "bar", { 91 value: "barbaz", 92 enumerable: true, 93 configurable: true, 94 writable: true, 95 }); 96 97 assert( 98 !Object.prototype.hasOwnProperty.call(C.prototype, "b"), 99 "b doesn't appear as an own property on C prototype" 100 ); 101 assert( 102 !Object.prototype.hasOwnProperty.call(C, "b"), 103 "b doesn't appear as an own property on C constructor" 104 ); 105 106 verifyProperty(c, "b", { 107 value: 42, 108 enumerable: true, 109 writable: true, 110 configurable: true 111 }); 112 113 assert( 114 !Object.prototype.hasOwnProperty.call(C.prototype, "x"), 115 "x doesn't appear as an own property on C prototype" 116 ); 117 assert( 118 !Object.prototype.hasOwnProperty.call(C, "x"), 119 "x doesn't appear as an own property on C constructor" 120 ); 121 assert( 122 !Object.prototype.hasOwnProperty.call(c, "x"), 123 "x doesn't appear as an own property on C instance" 124 ); 125 126 assert( 127 !Object.prototype.hasOwnProperty.call(C.prototype, "10"), 128 "10 doesn't appear as an own property on C prototype" 129 ); 130 assert( 131 !Object.prototype.hasOwnProperty.call(C, "10"), 132 "10 doesn't appear as an own property on C constructor" 133 ); 134 135 verifyProperty(c, "10", { 136 value: "meep", 137 enumerable: true, 138 writable: true, 139 configurable: true 140 }); 141 142 assert( 143 !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), 144 "'not initialized' doesn't appear as an own property on C prototype" 145 ); 146 assert( 147 !Object.prototype.hasOwnProperty.call(C, "not initialized"), 148 "'not initialized' doesn't appear as an own property on C constructor" 149 ); 150 151 verifyProperty(c, "not initialized", { 152 value: undefined, 153 enumerable: true, 154 writable: true, 155 configurable: true 156 }); 157 158 reportCompare(0, 0);