tor-browser

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

missing-closing-brace.js (1288B)


      1 function test(source, [lineNumber, columnNumber], openType = "{", closeType = "}") {
      2  let caught = false;
      3  try {
      4    Reflect.parse(source, { source: "foo.js" });
      5  } catch (e) {
      6    assertEq(e.message.includes("missing " + closeType + " "), true);
      7    let notes = getErrorNotes(e);
      8    assertEq(notes.length, 1);
      9    let note = notes[0];
     10    assertEq(note.message, openType + " opened at line " + lineNumber + ", column " + columnNumber);
     11    assertEq(note.fileName, "foo.js");
     12    assertEq(note.lineNumber, lineNumber);
     13    assertEq(note.columnNumber, columnNumber);
     14    caught = true;
     15  }
     16  assertEq(caught, true);
     17 }
     18 
     19 // Function
     20 
     21 test(`
     22 function test1() {
     23 }
     24 function test2() {
     25  if (true) {
     26  //}
     27 }
     28 function test3() {
     29 }
     30 `, [4, 18]);
     31 
     32 // Block statement.
     33 test(`
     34 {
     35  if (true) {
     36 }
     37 `, [2, 1]);
     38 test(`
     39 if (true) {
     40  if (true) {
     41 }
     42 `, [2, 11]);
     43 test(`
     44 for (;;) {
     45  if (true) {
     46 }
     47 `, [2, 10]);
     48 test(`
     49 while (true) {
     50  if (true) {
     51 }
     52 `, [2, 14]);
     53 test(`
     54 do {
     55  do {
     56 } while(true);
     57 `, [2, 4]);
     58 
     59 // try-catch-finally.
     60 test(`
     61 try {
     62  if (true) {
     63 }
     64 `, [2, 5]);
     65 test(`
     66 try {
     67 } catch (e) {
     68  if (true) {
     69 }
     70 `, [3, 13]);
     71 test(`
     72 try {
     73 } finally {
     74  if (true) {
     75 }
     76 `, [3, 11]);
     77 
     78 // Object literal.
     79 test(`
     80 var x = {
     81  foo: {
     82 };
     83 `, [2, 9]);
     84 
     85 // Array literal.
     86 test(`
     87 var x = [
     88  [
     89 ];
     90 `, [2, 9], "[", "]");