tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

unicode_other_id_continue.js (1723B)


      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 otherIdContinue = [
      7    0x00B7,     // MIDDLE DOT, Gc=Po
      8    0x0387,     // GREEK ANO TELEIA, Gc=Po
      9    0x1369,     // ETHIOPIC DIGIT ONE, Gc=No
     10    0x136A,     // ETHIOPIC DIGIT TWO, Gc=No
     11    0x136B,     // ETHIOPIC DIGIT THREE, Gc=No
     12    0x136C,     // ETHIOPIC DIGIT FOUR, Gc=No
     13    0x136D,     // ETHIOPIC DIGIT FIVE, Gc=No
     14    0x136E,     // ETHIOPIC DIGIT SIX, Gc=No
     15    0x136F,     // ETHIOPIC DIGIT SEVEN, Gc=No
     16    0x1370,     // ETHIOPIC DIGIT EIGHT, Gc=No
     17    0x1371,     // ETHIOPIC DIGIT NINE, Gc=No
     18    0x19DA,     // NEW TAI LUE THAM DIGIT ONE, Gc=No
     19 ];
     20 
     21 // Leading character in identifier.
     22 for (let ident of [...otherIdContinue]) {
     23    assertThrowsInstanceOf(() => eval(`${String.fromCodePoint(ident)}`), SyntaxError);
     24    assertThrowsInstanceOf(() => eval(`\\u${ident.toString(16).padStart(4, "0")}`), SyntaxError);
     25    assertThrowsInstanceOf(() => eval(`\\u{${ident.toString(16)}}`), SyntaxError);
     26 }
     27 
     28 // Not leading character in identifier.
     29 for (let ident of [...otherIdContinue]) {
     30    eval(`
     31        let A${String.fromCodePoint(ident)} = 123;
     32        assertEq(${String.fromCodePoint(0x41, ident)}, 123);
     33    `);
     34    eval(`
     35        let A\\u${ident.toString(16).padStart(4, "0")} = 123;
     36        assertEq(${String.fromCodePoint(0x41, ident)}, 123);
     37    `);
     38    eval(`
     39        let A\\u{${ident.toString(16)}} = 123;
     40        assertEq(${String.fromCodePoint(0x41, ident)}, 123);
     41    `);
     42 }
     43 
     44 if (typeof reportCompare === "function")
     45    reportCompare(0, 0, "ok");