multiple-stacked-definitions-computed-names.js (3043B)
1 // This file was procedurally generated from the following sources: 2 // - src/class-elements/computed-names.case 3 // - src/class-elements/productions/cls-decl-multiple-stacked-definitions.template 4 /*--- 5 description: Computed property names (multiple stacked fields definitions through ASI) 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 class C { 27 [x] = 42; [10] = "meep"; ["not initialized"] 28 foo = "foobar" 29 bar = "barbaz"; 30 31 } 32 33 var c = new C(); 34 35 assert.sameValue(c.foo, "foobar"); 36 assert( 37 !Object.prototype.hasOwnProperty.call(C, "foo"), 38 "foo doesn't appear as an own property on the C constructor" 39 ); 40 assert( 41 !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), 42 "foo doesn't appear as an own property on the C prototype" 43 ); 44 45 verifyProperty(c, "foo", { 46 value: "foobar", 47 enumerable: true, 48 configurable: true, 49 writable: true, 50 }); 51 52 assert.sameValue(c.bar, "barbaz"); 53 assert( 54 !Object.prototype.hasOwnProperty.call(C, "bar"), 55 "bar doesn't appear as an own property on the C constructor" 56 ); 57 assert( 58 !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), 59 "bar doesn't appear as an own property on the C prototype" 60 ); 61 62 verifyProperty(c, "bar", { 63 value: "barbaz", 64 enumerable: true, 65 configurable: true, 66 writable: true, 67 }); 68 69 assert( 70 !Object.prototype.hasOwnProperty.call(C.prototype, "b"), 71 "b doesn't appear as an own property on C prototype" 72 ); 73 assert( 74 !Object.prototype.hasOwnProperty.call(C, "b"), 75 "b doesn't appear as an own property on C constructor" 76 ); 77 78 verifyProperty(c, "b", { 79 value: 42, 80 enumerable: true, 81 writable: true, 82 configurable: true 83 }); 84 85 assert( 86 !Object.prototype.hasOwnProperty.call(C.prototype, "x"), 87 "x doesn't appear as an own property on C prototype" 88 ); 89 assert( 90 !Object.prototype.hasOwnProperty.call(C, "x"), 91 "x doesn't appear as an own property on C constructor" 92 ); 93 assert( 94 !Object.prototype.hasOwnProperty.call(c, "x"), 95 "x doesn't appear as an own property on C instance" 96 ); 97 98 assert( 99 !Object.prototype.hasOwnProperty.call(C.prototype, "10"), 100 "10 doesn't appear as an own property on C prototype" 101 ); 102 assert( 103 !Object.prototype.hasOwnProperty.call(C, "10"), 104 "10 doesn't appear as an own property on C constructor" 105 ); 106 107 verifyProperty(c, "10", { 108 value: "meep", 109 enumerable: true, 110 writable: true, 111 configurable: true 112 }); 113 114 assert( 115 !Object.prototype.hasOwnProperty.call(C.prototype, "not initialized"), 116 "'not initialized' doesn't appear as an own property on C prototype" 117 ); 118 assert( 119 !Object.prototype.hasOwnProperty.call(C, "not initialized"), 120 "'not initialized' doesn't appear as an own property on C constructor" 121 ); 122 123 verifyProperty(c, "not initialized", { 124 value: undefined, 125 enumerable: true, 126 writable: true, 127 configurable: true 128 }); 129 130 reportCompare(0, 0);