1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/Function/10.2.1.1.6.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + */ 1.8 + 1.9 +function strictThis() { 'use strict'; return this; } 1.10 + 1.11 +/* Check that calls of flat closure slots get the right |this|. */ 1.12 +function flat(g) { 1.13 + function h() { return g(); } 1.14 + return h; 1.15 +} 1.16 +assertEq(flat(strictThis)(), undefined); 1.17 + 1.18 +/* Check that calls up upvars get the right |this|. */ 1.19 +function upvar(f) { 1.20 + function h() { 1.21 + return f(); 1.22 + } 1.23 + return h(); 1.24 +} 1.25 +assertEq(upvar(strictThis), undefined); 1.26 + 1.27 +/* Check that calls to with-object properties get an appropriate 'this'. */ 1.28 +var obj = { f: strictThis }; 1.29 +with (obj) { 1.30 + /* 1.31 + * The method won't compile anything containing a 'with', but it can 1.32 + * compile 'g'. 1.33 + */ 1.34 + function g() { return f(); } 1.35 + assertEq(g(), obj); 1.36 +} 1.37 + 1.38 +reportCompare(true, true);