|
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.10_T2.js |
|
9 * @description Using iteration statement within "with" statement, leading completion by exception |
|
10 * @noStrict |
|
11 */ |
|
12 |
|
13 this.p1 = 1; |
|
14 |
|
15 var result = "result"; |
|
16 |
|
17 var myObj = { |
|
18 p1: 'a', |
|
19 value: 'myObj_value', |
|
20 valueOf : function(){return 'obj_valueOf';} |
|
21 } |
|
22 |
|
23 try { |
|
24 with(myObj){ |
|
25 do{ |
|
26 p1 = 'x1'; |
|
27 throw value; |
|
28 } while(false); |
|
29 } |
|
30 } catch(e){ |
|
31 result = p1; |
|
32 } |
|
33 |
|
34 ////////////////////////////////////////////////////////////////////////////// |
|
35 //CHECK#1 |
|
36 if(result !== 1){ |
|
37 $ERROR('#1: result === 1. Actual: result ==='+ result ); |
|
38 } |
|
39 // |
|
40 ////////////////////////////////////////////////////////////////////////////// |
|
41 |
|
42 ////////////////////////////////////////////////////////////////////////////// |
|
43 //CHECK#2 |
|
44 if(p1 !== 1){ |
|
45 $ERROR('#2: p1 === 1. Actual: p1 ==='+ p1 ); |
|
46 } |
|
47 // |
|
48 ////////////////////////////////////////////////////////////////////////////// |
|
49 |
|
50 ////////////////////////////////////////////////////////////////////////////// |
|
51 //CHECK#3 |
|
52 if(myObj.p1 !== "x1"){ |
|
53 $ERROR('#3: myObj.p1 === "x1". Actual: myObj.p1 ==='+ myObj.p1 ); |
|
54 } |
|
55 // |
|
56 ////////////////////////////////////////////////////////////////////////////// |
|
57 |