js/src/tests/test262/ch12/12.10/S12.10_A3.12_T5.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:662fe862c8e4
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 * No matter how control leaves the embedded 'Statement',
6 * the scope chain is always restored to its former state
7 *
8 * @path ch12/12.10/S12.10_A3.12_T5.js
9 * @description Calling a function without "with" statement declared within the statement, leading to completion by exception
10 * @noStrict
11 */
12
13 this.p1 = 1;
14 var result = "result";
15 var value = "value";
16 var myObj = {p1: 'a',
17 value: 'myObj_value',
18 valueOf : function(){return 'obj_valueOf';}
19 }
20
21 try {
22 with(myObj){
23 var f = function(){
24 throw value;
25 p1 = 'x1';
26 }
27 }
28 f();
29 } catch(e){
30 result = e;
31 }
32
33 if(!(p1 === 1)){
34 $ERROR('#1: p1 === 1. Actual: p1 ==='+ p1 );
35 }
36
37 if(!(myObj.p1 === "a")){
38 $ERROR('#2: myObj.p1 === "a". Actual: myObj.p1 ==='+ myObj.p1 );
39 }
40
41 if(!(result === "myObj_value")){
42 $ERROR('#3: result === "myObj_value". Actual: result ==='+ result );
43 }
44

mercurial