tor-browser

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

defaults-bound-to-function.js (840B)


      1 load(libdir + "asserts.js");
      2 
      3 function f(a=42) {
      4    return a;
      5    function a() { return 19; }
      6 }
      7 assertEq(f()(), 19);
      8 function h(a=b, b=43) {
      9    return [a, b];
     10    function b() { return 42; }
     11 }
     12 // TDZ
     13 assertThrowsInstanceOf(h, ReferenceError);
     14 function i(b=FAIL) {
     15    function b() {}
     16 }
     17 assertThrowsInstanceOf(i, ReferenceError);
     18 i(42);
     19 function j(a=(b=42), b=8) {
     20    return b;
     21    function b() { return 43; }
     22 }
     23 // TDZ
     24 assertThrowsInstanceOf(j, ReferenceError);
     25 function k(a=(b=42), b=8) {
     26    return b;
     27    function a() { return 43; }
     28 }
     29 // TDZ
     30 assertThrowsInstanceOf(k, ReferenceError);
     31 function l(a=8, b=a) {
     32    return b;
     33    function a() { return 42; }
     34 }
     35 assertEq(l(), 8);
     36 function m([a, b]=[1, 2], c=a) {
     37  function a() { return 42; }
     38  assertEq(typeof a, "function");
     39  assertEq(a(), 42);
     40  assertEq(b, 2);
     41  assertEq(c, 1);
     42 }
     43 m();