tor-browser

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

string-substring-static-strings.js (425B)


      1 // `str.substring(...)` can return static strings.
      2 
      3 const strings = [
      4  "abcdef",
      5  "ABCDEF",
      6 ];
      7 
      8 for (let i = 0; i < 500; ++i) {
      9  let str = strings[i & 1];
     10 
     11  for (let j = 0; j < 2; ++j) {
     12    // One element static string.
     13    let r = str.substring(j, j + 1);
     14    assertEq(r, str.charAt(j));
     15 
     16    // Two elements static string.
     17    let s = str.substring(j, j + 2);
     18    assertEq(s, str.charAt(j) + str.charAt(j + 1));
     19  }
     20 }