michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: function strictThis() { 'use strict'; return this; } michael@0: michael@0: /* Check that calls of flat closure slots get the right |this|. */ michael@0: function flat(g) { michael@0: function h() { return g(); } michael@0: return h; michael@0: } michael@0: assertEq(flat(strictThis)(), undefined); michael@0: michael@0: /* Check that calls up upvars get the right |this|. */ michael@0: function upvar(f) { michael@0: function h() { michael@0: return f(); michael@0: } michael@0: return h(); michael@0: } michael@0: assertEq(upvar(strictThis), undefined); michael@0: michael@0: /* Check that calls to with-object properties get an appropriate 'this'. */ michael@0: var obj = { f: strictThis }; michael@0: with (obj) { michael@0: /* michael@0: * The method won't compile anything containing a 'with', but it can michael@0: * compile 'g'. michael@0: */ michael@0: function g() { return f(); } michael@0: assertEq(g(), obj); michael@0: } michael@0: michael@0: reportCompare(true, true);