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: * Evaluating the nested productions TryStatement michael@0: * michael@0: * @path ch12/12.14/S12.14_A7_T3.js michael@0: * @description Checking if the production of nested TryStatement statements evaluates correct michael@0: */ michael@0: michael@0: // CHECK#1 michael@0: try{ michael@0: try{ michael@0: throw "ex2"; michael@0: } michael@0: catch(er2){ michael@0: if (er2!=="ex2") $ERROR('#1.1: Exception === "ex2". Actual: Exception ==='+er2); michael@0: throw "ex1"; michael@0: } michael@0: finally{ michael@0: throw "ex3"; michael@0: } michael@0: } michael@0: catch(er1){ michael@0: if (er1!=="ex3") $ERROR('#1.2: Exception === "ex3". Actual: Exception ==='+er1); michael@0: if (er1==="ex2") $ERROR('#1.3: Exception !=="ex2". Actual: catch previous catched exception'); michael@0: if (er1==="ex1") $ERROR('#1.4: Exception !=="ex1". Actual: catch previous embedded exception'); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: var c2=0; michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: try{ michael@0: throw "ex2"; michael@0: } michael@0: catch(er1){ michael@0: if (er1==="ex1") $ERROR('#2.1: Exception !=="ex1". Actual: catch previous catched exception'); michael@0: if (er1!=="ex2") $ERROR('#2.2: Exception === "ex2". Actual: Exception ==='+er1); michael@0: } michael@0: finally{ michael@0: c2=1; michael@0: } michael@0: if (er1!=="ex1") $ERROR('#2.3: Exception === "ex1". Actual: Exception ==='+er1); michael@0: if (er1==="ex2") $ERROR('#2.4: Exception !== "ex2". Actual: catch previous embedded exception'); michael@0: } michael@0: if (c2!==1) $ERROR('#2.5: "finally" block must be evaluated'); michael@0: michael@0: // CHECK#3 michael@0: var c3=0; michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: if (er1!=="ex1") $ERROR('#3.1: Exception === "ex1". Actual: Exception ==='+er1); michael@0: } michael@0: finally{ michael@0: try{ michael@0: throw "ex2"; michael@0: } michael@0: catch(er1){ michael@0: if (er1==="ex1") $ERROR('#3.2: Exception !=="ex1". Actual: catch previous catched exception'); michael@0: if (er1!=="ex2") $ERROR('#3.3: Exception === "ex2". Actual: Exception ==='+er1); michael@0: } michael@0: finally{ michael@0: c3=1; michael@0: } michael@0: } michael@0: if (c3!==1) $ERROR('#3.4: "finally" block must be evaluated'); michael@0: michael@0: // CHECK#4 michael@0: var c4=0; michael@0: try{ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: try{ michael@0: throw "ex2"; michael@0: } michael@0: catch(er1){ michael@0: if (er1==="ex1") $ERROR('#4.1: Exception !=="ex2". Actual: catch previous catched exception'); michael@0: if (er1!=="ex2") $ERROR('#4.2: Exception === "ex2". Actual: Exception ==='+er1); michael@0: } michael@0: finally{ michael@0: c4=2; michael@0: throw "ex3"; michael@0: } michael@0: if (er1!=="ex1") $ERROR('#4.3: Exception === "ex2". Actual: Exception ==='+er1); michael@0: if (er1==="ex2") $ERROR('#4.4: Exception !=="ex2". Actual: catch previous catched exception'); michael@0: if (er1==="ex3") $ERROR('#4.5: Exception !=="ex3". Actual: Catch previous embedded exception'); michael@0: } michael@0: finally{ michael@0: c4*=2; michael@0: } michael@0: } michael@0: catch(er1){} michael@0: if (c4!==4) $ERROR('#4.6: "finally" block must be evaluated'); michael@0: michael@0: // CHECK#5 michael@0: var c5=0; michael@0: try{ michael@0: try{ michael@0: throw "ex2"; michael@0: } michael@0: catch(er1){ michael@0: if (er1!=="ex2") $ERROR('#5.1: Exception === "ex2". Actual: Exception ==='+er1); michael@0: } michael@0: finally{ michael@0: throw "ex3"; michael@0: } michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: if (er1!=="ex3") $ERROR('#5.2: Exception === "ex3". Actual: Exception ==='+er1); michael@0: if (er1==="ex2") $ERROR('#5.3: Exception !=="ex2". Actual: catch previous catched exception'); michael@0: if (er1==="ex1") $ERROR('#5.4: Exception !=="ex1". Actual: catch previous embedded exception'); michael@0: } michael@0: finally{ michael@0: c5=1; michael@0: } michael@0: if (c5!==1) $ERROR('#5.5: "finally" block must be evaluated'); michael@0: michael@0: // CHECK#6 michael@0: var c6=0; michael@0: try{ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: if (er1!=="ex1") $ERROR('#6.1: Exception === "ex1". Actual: Exception ==='+er1); michael@0: } michael@0: finally{ michael@0: c6=2; michael@0: } michael@0: } michael@0: finally{ michael@0: c6*=2; michael@0: } michael@0: if (c6!==4) $ERROR('#6.2: "finally" block must be evaluated'); michael@0: michael@0: // CHECK#7 michael@0: var c7=0; michael@0: try{ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: finally{ michael@0: try{ michael@0: c7=1; michael@0: throw "ex2"; michael@0: } michael@0: catch(er1){ michael@0: if (er1!=="ex2") $ERROR('#7.1: Exception === "ex2". Actual: Exception ==='+er1); michael@0: if (er1==="ex1") $ERROR('#7.2: Exception !=="ex2". Actual: catch previous catched exception'); michael@0: c7++; michael@0: } michael@0: finally{ michael@0: c7*=2; michael@0: } michael@0: } michael@0: } michael@0: catch(er1){ michael@0: if (er1!=="ex1") $ERROR('#7.3: Exception === "ex1". Actual: Exception ==='+er1); michael@0: } michael@0: if (c7!==4) $ERROR('#7.4: "finally" block must be evaluated'); michael@0: