Debian Codegraph @

js/src/tests/non262/syntax/unicode_other_id_start.js

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 // From PropList.txt (Unicode 9):
6 const otherIdStart = [
7 0x1885, // MONGOLIAN LETTER ALI GALI BALUDA, Gc=Mn
8 0x1886, // MONGOLIAN LETTER ALI GALI THREE BALUDA, Gc=Mn
9 0x2118, // SCRIPT CAPITAL P, Gc=Sm
10 0x212E, // ESTIMATED SYMBOL, Gc=So
11 0x309B, // KATAKANA-HIRAGANA VOICED SOUND MARK, Gc=Sk
12 0x309C, // KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK, Gc=Sk
13 ];
14
15 // Leading character in identifier.
16 for (let ident of otherIdStart) {
17 eval(`
18 let ${String.fromCodePoint(ident)} = 123;
19 assertEq(${String.fromCodePoint(ident)}, 123);
20 `);
21 eval(`
22 let \\u${ident.toString(16).padStart(4, "0")} = 123;
23 assertEq(${String.fromCodePoint(ident)}, 123);
24 `);
25 eval(`
26 let \\u{${ident.toString(16)}} = 123;
27 assertEq(${String.fromCodePoint(ident)}, 123);
28 `);
29 }
30
31 // Not leading character in identifier.
32 for (let ident of otherIdStart) {
33 eval(`
34 let A${String.fromCodePoint(ident)} = 123;
35 assertEq(${String.fromCodePoint(0x41, ident)}, 123);
36 `);
37 eval(`
38 let A\\u${ident.toString(16).padStart(4, "0")} = 123;
39 assertEq(${String.fromCodePoint(0x41, ident)}, 123);
40 `);
41 eval(`
42 let A\\u{${ident.toString(16)}} = 123;
43 assertEq(${String.fromCodePoint(0x41, ident)}, 123);
44 `);
45 }
46
47 if (typeof reportCompare === "function")
48 reportCompare(0, 0, "ok");