michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * No matter how control leaves the embedded 'Statement', the scope chain is always restored to its former state michael@0: * michael@0: * @path ch12/12.10/S12.10_A3.3_T4.js michael@0: * @description Declaring "with" statement within a function constructor, leading to completion by exception michael@0: * @noStrict michael@0: */ michael@0: michael@0: this.p1 = 1; michael@0: michael@0: var result = "result"; michael@0: michael@0: var myObj = { michael@0: p1: 'a', michael@0: value: 'myObj_value', michael@0: valueOf : function(){return 'obj_valueOf';} michael@0: }; michael@0: michael@0: function __FACTORY(){ michael@0: with(myObj){ michael@0: var p1 = 'x1'; michael@0: throw value; michael@0: } michael@0: } michael@0: michael@0: try { michael@0: var obj = new __FACTORY(); michael@0: } catch(e){ michael@0: result = p1; michael@0: } michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#1 michael@0: if (result !== 1) { michael@0: $ERROR('#1: result === 1. Actual: result ==='+ result ); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#2 michael@0: if (p1 !== 1) { michael@0: $ERROR('#2: p1 === 1. Actual: p1 ==='+ p1 ); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: //CHECK#3 michael@0: if (myObj.p1 !== "x1") { michael@0: $ERROR('#3: myObj.p1 === "x1". Actual: myObj.p1 ==='+ myObj.p1 ); michael@0: } michael@0: // michael@0: ////////////////////////////////////////////////////////////////////////////// michael@0: