Debian Codegraph @

js/src/tests/test262/language/statements/function/S13.2.2_A17_T3.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: FunctionExpression containing "with" statement is admitted
6 es5id: 13.2.2_A17_T3
7 description: >
8 In the check 4 we populate field getRight in __obj object since
9 var getRight declaration adds variable to function scope but
10 getRight in statement resolves within with(__obj) scope and
11 searchs getRight in __obj first
12 flags: [noStrict]
13 ---*/
14
15 p1="alert";
16
17 this.__obj={p1:1,getRight:function(){return "right";}};
18
19 var getRight=function(){return "napravo";};
20
21 resukt=(function(){
22 with(__obj){
23 p1="w1";
24 var getRight=function(){return false;};
25 return p1;
26 }
27 })();
28
29 //////////////////////////////////////////////////////////////////////////////
30 //CHECK#1
31 if (p1!=="alert") {
32 throw new Test262Error('#1: p1 === "alert". Actual: p1==='+p1);
33 }
34 //
35 //////////////////////////////////////////////////////////////////////////////
36
37 //////////////////////////////////////////////////////////////////////////////
38 //CHECK#2
39 if (getRight()!=="napravo") {
40 throw new Test262Error('#2: getRight() === "napravo". Actual: getRight()==='+getRight());
41 }
42 //
43 //////////////////////////////////////////////////////////////////////////////
44
45 //////////////////////////////////////////////////////////////////////////////
46 //CHECK#3
47 if (__obj.p1!=="w1") {
48 throw new Test262Error('#3: __obj.p1 === "w1". Actual: __obj.p1 ==='+__obj.p1);
49 }
50 //
51 //////////////////////////////////////////////////////////////////////////////
52
53 //////////////////////////////////////////////////////////////////////////////
54 //CHECK#4
55 if (__obj.getRight()!==false) {
56 throw new Test262Error('#4: __obj.getRight() === false. Actual: __obj.getRight()==='+__obj.getRight());
57 }
58 //
59 //////////////////////////////////////////////////////////////////////////////
60
61 //////////////////////////////////////////////////////////////////////////////
62 //CHECK#5
63 if (resukt !== "w1") {
64 throw new Test262Error('#5: resukt === "w1". Actual: resukt ==='+resukt);
65 }
66 //
67 //////////////////////////////////////////////////////////////////////////////
68
69 var resukt;
70
71 reportCompare(0, 0);