michael@0: // Check that the implicit-this logic needed for CALLNAME global stubs michael@0: // handles non-function values correctly. michael@0: var self = this; michael@0: var count = 0; michael@0: function g1() { michael@0: assertEq(this, self); michael@0: this.count++; michael@0: } michael@0: function g2() { michael@0: this.count += 10; michael@0: } michael@0: function f() { michael@0: function f1(other) { michael@0: eval("gc(); h = g1"); michael@0: try { michael@0: for(var i=0; i<20; i++) { michael@0: h(); michael@0: if (i === 9) { michael@0: h = other; michael@0: } michael@0: } michael@0: assertEq(typeof other, "function"); michael@0: } catch(e) { michael@0: assertEq(typeof other !== "function", true); michael@0: assertEq(e instanceof TypeError, true); michael@0: } michael@0: } michael@0: f1(3); michael@0: f1(null); michael@0: f1({}); michael@0: f1(Math.abs); michael@0: f1(g2); michael@0: } michael@0: f(); michael@0: assertEq(count, 150);