tor-browser

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

finally-implicit-return.js (797B)


      1 // Implicit return at the end of a function should return |undefined|,
      2 // even if we initially set another return value and then executed a finally
      3 // block.
      4 
      5 function test1() {
      6    try {
      7        try {
      8            return 3;
      9        } finally {
     10            throw 4;
     11        }
     12    } catch (e) {}
     13 }
     14 assertEq(test1(), undefined);
     15 
     16 function test2() {
     17    L: try {
     18        return 3;
     19    } finally {
     20        break L;
     21    }
     22 }
     23 assertEq(test2(), undefined);
     24 
     25 function test3() {
     26    for (var i=0; i<2; i++) {
     27        try {
     28            return 5;
     29        } finally {
     30            continue;
     31        }
     32    }
     33 }
     34 assertEq(test3(), undefined);
     35 
     36 // "return;" should work the same way.
     37 function test4() {
     38    L: try {
     39        return 6;
     40    } finally {
     41        break L;
     42    }
     43    return;
     44 }
     45 assertEq(test4(), undefined);