michael@0: function t1() { michael@0: assertEq(thisValue, this); michael@0: } michael@0: michael@0: thisValue = {}; michael@0: var f1 = t1.bind(thisValue); michael@0: f1() michael@0: f1() michael@0: michael@0: //////////////////////////////////////////////////////////// michael@0: michael@0: function t2() { michael@0: bailout(); michael@0: } michael@0: michael@0: var f2 = t2.bind(thisValue); michael@0: f2() michael@0: f2() michael@0: michael@0: //////////////////////////////////////////////////////////// michael@0: michael@0: function test3() { michael@0: function i3(a,b,c,d) { michael@0: bailout(); michael@0: } michael@0: michael@0: function t3(a,b,c,d) { michael@0: i3(a,b,c,d); michael@0: } michael@0: michael@0: var f3 = t3.bind(thisValue); michael@0: for (var i=0;i<10; i++) { michael@0: f3(1,2,3,4) michael@0: f3(1,2,3,4) michael@0: } michael@0: } michael@0: test3(); michael@0: test3(); michael@0: michael@0: //////////////////////////////////////////////////////////// michael@0: michael@0: function test4() { michael@0: this.a = 1; michael@0: var inner = function(a,b,c,d) { michael@0: bailout(); michael@0: } michael@0: michael@0: var t = function(a,b,c,d) { michael@0: assertEq(this.a, undefined); michael@0: inner(a,b,c,d); michael@0: assertEq(this.a, undefined); michael@0: } michael@0: michael@0: var f = t.bind(thisValue); michael@0: for (var i=0;i<5; i++) { michael@0: var res = f(1,2,3,4) michael@0: var res2 = new f(1,2,3,4) michael@0: assertEq(res, undefined); michael@0: assertEq(res2 == undefined, false); michael@0: } michael@0: } michael@0: test4(); michael@0: test4(); michael@0: michael@0: //////////////////////////////////////////////////////////// michael@0: michael@0: function test5() { michael@0: this.a = 1; michael@0: var inner = function(a,b,c,d) { michael@0: assertEq(a, 1); michael@0: assertEq(b, 2); michael@0: assertEq(c, 3); michael@0: assertEq(d, 1); michael@0: bailout(); michael@0: assertEq(a, 1); michael@0: assertEq(b, 2); michael@0: assertEq(c, 3); michael@0: assertEq(d, 1); michael@0: } michael@0: michael@0: var t = function(a,b,c,d) { michael@0: inner(a,b,c,d); michael@0: } michael@0: michael@0: var f = t.bind(thisValue, 1,2,3); michael@0: for (var i=0;i<5; i++) { michael@0: f(1,2,3,4) michael@0: } michael@0: } michael@0: test5(); michael@0: test5(); michael@0: michael@0: //////////////////////////////////////////////////////////// michael@0: michael@0: function test6() { michael@0: function i6(a,b,c,d) { michael@0: if (a == 1) michael@0: bailout(); michael@0: } michael@0: michael@0: function t6(a,b,c,d) { michael@0: i6(a,b,c,d); michael@0: } michael@0: michael@0: var f6 = t6.bind(thisValue, 1); michael@0: f6(1,2,3,4) michael@0: f6(0,2,3,4) michael@0: } michael@0: test6(); michael@0: test6();