multiple-definitions-grammar-privatename-identifier-semantics-stringvalue.js (3885B)
1 // This file was procedurally generated from the following sources: 2 // - src/class-elements/grammar-privatename-identifier-semantics-stringvalue.case 3 // - src/class-elements/productions/cls-decl-multiple-definitions.template 4 /*--- 5 description: PrivateName Static Semantics, StringValue (multiple fields definitions) 6 esid: prod-FieldDefinition 7 features: [class-fields-private, class, class-fields-public] 8 flags: [generated] 9 includes: [propertyHelper.js] 10 info: | 11 ClassElement : 12 MethodDefinition 13 static MethodDefinition 14 FieldDefinition ; 15 ; 16 17 FieldDefinition : 18 ClassElementName Initializer _opt 19 20 ClassElementName : 21 PropertyName 22 PrivateName 23 24 PrivateName :: 25 # IdentifierName 26 27 IdentifierName :: 28 IdentifierStart 29 IdentifierName IdentifierPart 30 31 IdentifierStart :: 32 UnicodeIDStart 33 $ 34 _ 35 \ UnicodeEscapeSequence 36 37 IdentifierPart:: 38 UnicodeIDContinue 39 $ 40 \ UnicodeEscapeSequence 41 <ZWNJ> <ZWJ> 42 43 UnicodeIDStart:: 44 any Unicode code point with the Unicode property "ID_Start" 45 46 UnicodeIDContinue:: 47 any Unicode code point with the Unicode property "ID_Continue" 48 49 50 NOTE 3 51 The sets of code points with Unicode properties "ID_Start" and 52 "ID_Continue" include, respectively, the code points with Unicode 53 properties "Other_ID_Start" and "Other_ID_Continue". 54 55 56 1. Return the String value consisting of the sequence of code 57 units corresponding to PrivateName. In determining the sequence 58 any occurrences of \ UnicodeEscapeSequence are first replaced 59 with the code point represented by the UnicodeEscapeSequence 60 and then the code points of the entire PrivateName are converted 61 to code units by UTF16Encoding (10.1.1) each code point. 62 63 ---*/ 64 65 66 class C { 67 foo = "foobar"; 68 m() { return 42 } 69 #\u{6F}; 70 #\u2118; 71 #ZW_\u200C_NJ; 72 #ZW_\u200D_J; 73 m2() { return 39 } 74 bar = "barbaz"; 75 o(value) { 76 this.#o = value; 77 return this.#o; 78 } 79 ℘(value) { 80 this.#℘ = value; 81 return this.#℘; 82 } 83 ZW__NJ(value) { // DO NOT CHANGE THE NAME OF THIS METHOD 84 this.#ZW__NJ = value; 85 return this.#ZW__NJ; 86 } 87 ZW__J(value) { // DO NOT CHANGE THE NAME OF THIS METHOD 88 this.#ZW__J = value; 89 return this.#ZW__J; 90 } 91 } 92 93 var c = new C(); 94 95 assert.sameValue(c.m(), 42); 96 assert( 97 !Object.prototype.hasOwnProperty.call(c, "m"), 98 "m doesn't appear as an own property on the C instance" 99 ); 100 assert.sameValue(c.m, C.prototype.m); 101 102 verifyProperty(C.prototype, "m", { 103 enumerable: false, 104 configurable: true, 105 writable: true, 106 }); 107 108 assert.sameValue(c.m2(), 39); 109 assert(! 110 Object.prototype.hasOwnProperty.call(c, "m2"), 111 "m2 doesn't appear as an own property on the C instance" 112 ); 113 assert.sameValue(c.m2, C.prototype.m2); 114 115 verifyProperty(C.prototype, "m2", { 116 enumerable: false, 117 configurable: true, 118 writable: true, 119 }); 120 121 assert.sameValue(c.foo, "foobar"); 122 assert( 123 !Object.prototype.hasOwnProperty.call(C, "foo"), 124 "foo doesn't appear as an own property on the C constructor" 125 ); 126 assert( 127 !Object.prototype.hasOwnProperty.call(C.prototype, "foo"), 128 "foo doesn't appear as an own property on the C prototype" 129 ); 130 131 verifyProperty(c, "foo", { 132 value: "foobar", 133 enumerable: true, 134 configurable: true, 135 writable: true, 136 }); 137 138 assert.sameValue(c.bar, "barbaz"); 139 assert( 140 !Object.prototype.hasOwnProperty.call(C, "bar"), 141 "bar doesn't appear as an own property on the C constructor" 142 ); 143 assert( 144 !Object.prototype.hasOwnProperty.call(C.prototype, "bar"), 145 "bar doesn't appear as an own property on the C prototype" 146 ); 147 148 verifyProperty(c, "bar", { 149 value: "barbaz", 150 enumerable: true, 151 configurable: true, 152 writable: true, 153 }); 154 155 assert.sameValue(c.o(1), 1); 156 assert.sameValue(c.℘(1), 1); 157 assert.sameValue(c.ZW__NJ(1), 1); 158 assert.sameValue(c.ZW__J(1), 1); 159 160 reportCompare(0, 0);