tor-browser

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

shell.js (684B)


      1 function GenericPartCreator(type) {
      2    return str => ({ type, value: str });
      3 }
      4 
      5 const ListFormatParts = {
      6    Element: GenericPartCreator("element"),
      7    Literal: GenericPartCreator("literal"),
      8 };
      9 
     10 function assertParts(lf, x, expected) {
     11    var parts = lf.formatToParts(x);
     12    assertEq(parts.map(part => part.value).join(""), lf.format(x),
     13             "formatToParts and format must agree");
     14 
     15    var len = parts.length;
     16    assertEq(len, expected.length, "parts count mismatch");
     17    for (var i = 0; i < len; i++) {
     18        assertEq(parts[i].type, expected[i].type, "type mismatch at " + i);
     19        assertEq(parts[i].value, expected[i].value, "value mismatch at " + i);
     20    }
     21 }