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