tor-browser

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

grapheme-latin1.js (1044B)


      1 // |reftest| slow skip-if(!this.hasOwnProperty('Intl')||!this.Intl.Segmenter)
      2 
      3 // CRLF should be the only compound grapheme for Latin-1 strings.
      4 
      5 let segmenter = new Intl.Segmenter("en", {granularity: "grapheme"});
      6 
      7 for (let i = 0; i <= 0xff; ++i) {
      8  for (let j = 0; j <= 0xff; ++j) {
      9    let string = String.fromCodePoint(i, j);
     10    let segments = segmenter.segment(string);
     11 
     12    let data1 = segments.containing(0);
     13    let data2 = segments.containing(1);
     14    let graphemes = [...segments];
     15 
     16    if (i === "\r".charCodeAt(0) && j === "\n".charCodeAt(0)) {
     17      assertEq(data1.index, 0);
     18      assertEq(data1.segment, "\r\n");
     19 
     20      assertEq(data2.index, 0);
     21      assertEq(data2.segment, "\r\n");
     22 
     23      assertEq(graphemes.length, 1);
     24    } else {
     25      assertEq(data1.index, 0);
     26      assertEq(data1.segment, String.fromCodePoint(i));
     27 
     28      assertEq(data2.index, 1);
     29      assertEq(data2.segment, String.fromCodePoint(j));
     30 
     31      assertEq(graphemes.length, 2);
     32    }
     33  }
     34 }
     35 
     36 if (typeof reportCompare === "function")
     37  reportCompare(0, 0);