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: * Throwing exception with "throw" and catching it with "try" statement michael@0: * michael@0: * @path ch12/12.14/S12.14_A2.js michael@0: * @description Checking if execution of "catch" catches an exception thrown with "throw" michael@0: */ michael@0: michael@0: // CHECK#1 michael@0: try { michael@0: throw "catchme"; michael@0: $ERROR('#1: throw "catchme" lead to throwing exception'); michael@0: } michael@0: catch(e){} michael@0: michael@0: // CHECK#2 michael@0: var c2=0; michael@0: try{ michael@0: try{ michael@0: throw "exc"; michael@0: $ERROR('#2.1: throw "exc" lead to throwing exception'); michael@0: }finally{ michael@0: c2=1; michael@0: } michael@0: } michael@0: catch(e){ michael@0: if (c2!==1){ michael@0: $ERROR('#2.2: "finally" block must be evaluated'); michael@0: } michael@0: } michael@0: michael@0: // CHECK#3 michael@0: var c3=0; michael@0: try{ michael@0: throw "exc"; michael@0: $ERROR('#3.1: throw "exc" lead to throwing exception'); michael@0: } michael@0: catch(err){ michael@0: var x3=1; michael@0: } michael@0: finally{ michael@0: c3=1; michael@0: } michael@0: if (x3!==1){ michael@0: $ERROR('#3.2: "catch" block must be evaluated'); michael@0: } michael@0: if (c3!==1){ michael@0: $ERROR('#3.3: "finally" block must be evaluated'); michael@0: } michael@0: