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