S12.10_A3.3_T4.js (1541B)
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', the scope chain is 7 always restored to its former state 8 es5id: 12.10_A3.3_T4 9 description: > 10 Declaring "with" statement within a function constructor, leading 11 to completion by exception 12 flags: [noStrict] 13 ---*/ 14 15 this.p1 = 1; 16 17 var result = "result"; 18 19 var myObj = { 20 p1: 'a', 21 value: 'myObj_value', 22 valueOf : function(){return 'obj_valueOf';} 23 }; 24 25 function __FACTORY(){ 26 with(myObj){ 27 var p1 = 'x1'; 28 throw value; 29 } 30 } 31 32 try { 33 var obj = new __FACTORY(); 34 } catch(e){ 35 result = p1; 36 } 37 38 ////////////////////////////////////////////////////////////////////////////// 39 //CHECK#1 40 if (result !== 1) { 41 throw new Test262Error('#1: result === 1. Actual: result ==='+ result ); 42 } 43 // 44 ////////////////////////////////////////////////////////////////////////////// 45 46 ////////////////////////////////////////////////////////////////////////////// 47 //CHECK#2 48 if (p1 !== 1) { 49 throw new Test262Error('#2: p1 === 1. Actual: p1 ==='+ p1 ); 50 } 51 // 52 ////////////////////////////////////////////////////////////////////////////// 53 54 ////////////////////////////////////////////////////////////////////////////// 55 //CHECK#3 56 if (myObj.p1 !== "x1") { 57 throw new Test262Error('#3: myObj.p1 === "x1". Actual: myObj.p1 ==='+ myObj.p1 ); 58 } 59 // 60 ////////////////////////////////////////////////////////////////////////////// 61 62 reportCompare(0, 0);