tor-browser

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

try-finally-3.js (469B)


      1 var target = undefined;
      2 function throwOn(x) {
      3  with ({}) {}
      4  if (x === target) {
      5    throw x;
      6  }
      7 }
      8 
      9 // Test nested try-finally
     10 function foo() {
     11  let result = 0;
     12  try {
     13    throwOn(1);
     14    result += 1;
     15    try {
     16      throwOn(2);
     17      result += 2;
     18    } finally {
     19      result += 3;
     20    }
     21  } finally {
     22    return result;
     23  }
     24 }
     25 
     26 with ({}) {}
     27 for (var i = 0; i < 100; i++) {
     28  assertEq(foo(), 6);
     29 }
     30 
     31 target = 1;
     32 assertEq(foo(), 0);
     33 
     34 target = 2;
     35 assertEq(foo(), 4);