tor-browser

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

call-generic-bound.js (741B)


      1 // Test that the generic call trampoline calls bound functions correctly,
      2 // including nested bound functions.
      3 
      4 function foo(f) {
      5  return f(0);
      6 }
      7 
      8 function f1(x) { return x; }
      9 var f2 = f1.bind({});
     10 var f3 = f2.bind({}, 1);
     11 var f4 = f3.bind({});
     12 
     13 var f5 = Math.log.bind({});
     14 var f6 = f5.bind({},1);
     15 var f7 = f6.bind({});
     16 
     17 let boundThis = {};
     18 function f8() { return this; }
     19 let f9 = f8.bind(boundThis);
     20 let f10 = f9.bind({});
     21 
     22 with ({}) {}
     23 for (var i = 0; i < 500; i++) {
     24  assertEq(foo(f1), 0);
     25  assertEq(foo(f2), 0);
     26  assertEq(foo(f3), 1);
     27  assertEq(foo(f4), 1);
     28  assertEq(foo(f5), -Infinity);
     29  assertEq(foo(f6), 0);
     30  assertEq(foo(f7), 0);
     31  assertEq(foo(f8), this);
     32  assertEq(foo(f9), boundThis);
     33  assertEq(foo(f10), boundThis);
     34 }