Debian Codegraph @

js/src/tests/test262/language/statements/with/S12.10_A3.12_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: |
6 No matter how control leaves the embedded 'Statement',
7 the scope chain is always restored to its former state
8 es5id: 12.10_A3.12_T3
9 description: >
10 Calling a function without "with" statement declared within the
11 statement, leading to normal completion by "return"
12 flags: [noStrict]
13 ---*/
14
15 this.p1 = 1;
16 var result = "result";
17 var value = "value";
18 var myObj = {p1: 'a',
19 value: 'myObj_value',
20 valueOf : function(){return 'obj_valueOf';}
21 }
22
23 with(myObj){
24 var f = function(){
25 return value;
26 p1 = 'x1';
27 }
28 }
29 result = f();
30
31 if(!(p1 === 1)){
32 throw new Test262Error('#1: p1 === 1. Actual: p1 ==='+ p1 );
33 }
34
35 if(!(myObj.p1 === "a")){
36 throw new Test262Error('#2: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 );
37 }
38
39 if(!(result === "myObj_value")){
40 throw new Test262Error('#3: result === "myObj_value". Actual: result ==='+ result );
41 }
42
43 reportCompare(0, 0);