1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch13/13.2/S13.2.2_A17_T3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,68 @@ 1.4 +// Copyright 2009 the Sputnik authors. All rights reserved. 1.5 +// This code is governed by the BSD license found in the LICENSE file. 1.6 + 1.7 +/** 1.8 + * FunctionExpression containing "with" statement is admitted 1.9 + * 1.10 + * @path ch13/13.2/S13.2.2_A17_T3.js 1.11 + * @description In the check 4 we populate field getRight in __obj object since var getRight declaration adds variable to function scope 1.12 + * but getRight in statement resolves within with(__obj) scope and searchs getRight in __obj first 1.13 + */ 1.14 + 1.15 +p1="alert"; 1.16 + 1.17 +this.__obj={p1:1,getRight:function(){return "right";}}; 1.18 + 1.19 +var getRight=function(){return "napravo";}; 1.20 + 1.21 +resukt=(function(){ 1.22 + with(__obj){ 1.23 + p1="w1"; 1.24 + var getRight=function(){return false;}; 1.25 + return p1; 1.26 + } 1.27 +})(); 1.28 + 1.29 +////////////////////////////////////////////////////////////////////////////// 1.30 +//CHECK#1 1.31 +if (p1!=="alert") { 1.32 + $ERROR('#1: p1 === "alert". Actual: p1==='+p1); 1.33 +} 1.34 +// 1.35 +////////////////////////////////////////////////////////////////////////////// 1.36 + 1.37 +////////////////////////////////////////////////////////////////////////////// 1.38 +//CHECK#2 1.39 +if (getRight()!=="napravo") { 1.40 + $ERROR('#2: getRight() === "napravo". Actual: getRight()==='+getRight()); 1.41 +} 1.42 +// 1.43 +////////////////////////////////////////////////////////////////////////////// 1.44 + 1.45 +////////////////////////////////////////////////////////////////////////////// 1.46 +//CHECK#3 1.47 +if (__obj.p1!=="w1") { 1.48 + $ERROR('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1); 1.49 +} 1.50 +// 1.51 +////////////////////////////////////////////////////////////////////////////// 1.52 + 1.53 +////////////////////////////////////////////////////////////////////////////// 1.54 +//CHECK#4 1.55 +if (__obj.getRight()!==false) { 1.56 + $ERROR('#4: __obj.getRight() === false. Actual: __obj.getRight()==='+__obj.getRight()); 1.57 +} 1.58 +// 1.59 +////////////////////////////////////////////////////////////////////////////// 1.60 + 1.61 +////////////////////////////////////////////////////////////////////////////// 1.62 +//CHECK#5 1.63 +if (resukt !== "w1") { 1.64 + $ERROR('#5: resukt === "w1". Actual: resukt ==='+resukt); 1.65 +} 1.66 +// 1.67 +////////////////////////////////////////////////////////////////////////////// 1.68 + 1.69 +var resukt; 1.70 + 1.71 +