tor-browser

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

letContextualKeyword.js (3443B)


      1 function expectError(str) {
      2  var log = "";
      3  try {
      4    eval(str);
      5  } catch (e) {
      6    log += "e";
      7    assertEq(e instanceof SyntaxError, true);
      8  }
      9  assertEq(log, "e");
     10 }
     11 
     12 eval(`let x = 42; assertEq(x, 42);`);
     13 eval(`var let = 42; assertEq(let, 42);`);
     14 eval(`let;`);
     15 eval(`[...let] = [];`);
     16 eval(`function let() { return 42; } assertEq(let(), 42);`)
     17 eval(`let {x:x} = {x:42}; assertEq(x, 42);`);
     18 eval(`let [x] = [42]; assertEq(x, 42);`);
     19 
     20 eval(`for (let x in [1]) { assertEq(x, "0"); }`);
     21 eval(`for (const x in [1]) { assertEq(x, "0"); }`);
     22 
     23 eval(`for (let x of [1]) { assertEq(x, 1); }`);
     24 eval(`for (const x of [1]) { assertEq(x, 1); }`);
     25 
     26 eval(`for (let i = 0; i < 1; i++) { assertEq(i, 0); }`);
     27 eval(`var done = false; for (const i = 0; !done; done = true) { assertEq(i, 0); }`);
     28 
     29 eval(`for (let of of [1]) { assertEq(of, 1); }`);
     30 eval(`for (const of of [1]) { assertEq(of, 1); }`);
     31 
     32 eval(`try { throw 17; } catch (let) { assertEq(let, 17); }`);
     33 eval(`try { throw [17]; } catch ([let]) { assertEq(let, 17); }`);
     34 eval(`try { throw { x: 17 }; } catch ({ x: let }) { assertEq(let, 17); }`);
     35 eval(`try { throw {}; } catch ({ x: let = 17 }) { assertEq(let, 17); }`);
     36 
     37 expectError(`try { throw [17, 42]; } catch ([let, let]) {}`);
     38 
     39 eval(`for (let in [1]) { assertEq(let, "0"); }`);
     40 eval(`for (let / 1; ; ) { break; }`);
     41 expectError(`let = {}; for (let.x of;;);`);
     42 expectError(`for (let of [1]) { }`);
     43 
     44 expectError(`for (let let in [1]) { }`);
     45 expectError(`for (const let in [1]) { }`);
     46 
     47 expectError(`for (let let of [1]) { }`);
     48 expectError(`for (const let of [1]) { }`);
     49 
     50 expectError(`for (let let = 17; false; ) { }`);
     51 expectError(`for (const let = 17; false; ) { }`);
     52 
     53 expectError(`for (let [let] = 17; false; ) { }`);
     54 expectError(`for (const [let] = 17; false; ) { }`);
     55 
     56 expectError(`for (let [let = 42] = 17; false; ) { }`);
     57 expectError(`for (const [let = 42] = 17; false; ) { }`);
     58 
     59 expectError(`for (let { x: let } = 17; false; ) { }`);
     60 expectError(`for (const { x: let } = 17; false; ) { }`);
     61 
     62 expectError(`for (let { x: let = 42 } = 17; false; ) { }`);
     63 expectError(`for (const { x: let = 42 } = 17; false; ) { }`);
     64 
     65 expectError("let\nlet;");
     66 expectError("const\nlet;");
     67 
     68 expectError(`let let = 17;`);
     69 expectError(`const let = 17;`);
     70 
     71 expectError(`let [let] = 17;`);
     72 expectError(`const [let] = 17;`);
     73 
     74 expectError(`let [let = 42] = 17;`);
     75 expectError(`const [let = 42] = 17;`);
     76 
     77 expectError(`let {let} = 17;`);
     78 expectError(`const {let} = 17;`);
     79 
     80 expectError(`let { let = 42 } = 17;`);
     81 expectError(`const { let = 42 } = 17;`);
     82 
     83 expectError(`let { x: let } = 17;`);
     84 expectError(`const { x: let } = 17;`);
     85 
     86 expectError(`let { x: let = 42 } = 17;`);
     87 expectError(`const { x: let = 42 } = 17;`);
     88 
     89 expectError(`let { ['y']: let } = 17;`);
     90 expectError(`const { ['y']: let } = 17;`);
     91 
     92 expectError(`let { ['y']: let = 42 } = 17;`);
     93 expectError(`const { ['y']: let = 42 } = 17;`);
     94 
     95 expectError(`let { x: [let] } = { x: 17 };`);
     96 expectError(`const { x: [let] } = { x: 17 };`);
     97 
     98 expectError(`let { x: [let = 42] } = { x: 17 };`);
     99 expectError(`const { x: [let = 42] } = { x: 17 };`);
    100 
    101 expectError(`let [foo, let] = 42;`);
    102 expectError(`const [foo, let] = 42;`);
    103 
    104 expectError(`let [foo, { let }] = [17, {}];`);
    105 expectError(`const [foo, { let }] = [17, {}];`);
    106 
    107 expectError(`"use strict"; var let = 42;`);
    108 expectError(`"use strict"; function let() {}`);
    109 expectError(`"use strict"; for (let of [1]) {}`);
    110 expectError(`"use strict"; try {} catch (let) {}`);