michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * FunctionExpression containing "with" statement is admitted michael@0: * michael@0: * @path ch13/13.2/S13.2.2_A17_T3.js michael@0: * @description In the check 4 we populate field getRight in __obj object since var getRight declaration adds variable to function scope michael@0: * but getRight in statement resolves within with(__obj) scope and searchs getRight in __obj first michael@0: */ michael@0: michael@0: p1="alert"; michael@0: michael@0: this.__obj={p1:1,getRight:function(){return "right";}}; michael@0: michael@0: var getRight=function(){return "napravo";}; michael@0: michael@0: resukt=(function(){ michael@0: with(__obj){ michael@0: p1="w1"; michael@0: var getRight=function(){return false;}; michael@0: return p1; michael@0: } michael@0: })(); michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#1 michael@0: if (p1!=="alert") { michael@0: $ERROR('#1: p1 === "alert". Actual: p1==='+p1); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#2 michael@0: if (getRight()!=="napravo") { michael@0: $ERROR('#2: getRight() === "napravo". Actual: getRight()==='+getRight()); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#3 michael@0: if (__obj.p1!=="w1") { michael@0: $ERROR('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#4 michael@0: if (__obj.getRight()!==false) { michael@0: $ERROR('#4: __obj.getRight() === false. Actual: __obj.getRight()==='+__obj.getRight()); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#5 michael@0: if (resukt !== "w1") { michael@0: $ERROR('#5: resukt === "w1". Actual: resukt ==='+resukt); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: var resukt; michael@0: michael@0: