tor-browser

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

error-locations.js (969B)


      1 // |reftest|
      2 function assertLineAndColumn(str, line, column) {
      3  try {
      4    eval(str);
      5    throw 'didn\'t syntaxerror, bad.'
      6  } catch (e) {
      7    assertEq(e instanceof SyntaxError, true);
      8    assertEq(e.lineNumber, line);
      9    assertEq(e.columnNumber, column);
     10  }
     11 }
     12 
     13 assertLineAndColumn(`class A { g() { return this.#x; }}`, 1, 29);
     14 // Make sure we're reporting the first error, if there are multiple, in class
     15 // exit context;
     16 assertLineAndColumn(
     17    `class A { g() { return this.#x; } y() { return       this.#z + this.#y; } }`,
     18    1, 29);
     19 assertLineAndColumn(`this.#x`, 1, 6);
     20 // Make sure we're reporting the first error, if there are multiple, in
     21 // non-class context;
     22 assertLineAndColumn(`this.#x; this.#y; this.#z`, 1, 6);
     23 
     24 assertLineAndColumn(
     25    `class A {
     26 g() { return this.#x; }}`,
     27    2, 19);
     28 assertLineAndColumn(
     29    `class A {
     30 
     31 g() { return this.#x; } y() { return this.#y; }}`,
     32    3, 19);
     33 
     34 if (typeof reportCompare === 'function') reportCompare(0, 0);