S12.14_A7_T2.js (3174B)
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: Evaluating the nested productions TryStatement 6 es5id: 12.14_A7_T2 7 description: > 8 Checking if the production of nested TryStatement statements 9 evaluates correct 10 ---*/ 11 12 // CHECK#1 13 try{ 14 try{ 15 throw "ex2"; 16 } 17 finally{ 18 throw "ex1"; 19 } 20 } 21 catch(er1){ 22 if (er1!=="ex1") throw new Test262Error('#1.2: Exception === "ex1". Actual: Exception ==='+er1 ); 23 if (er1==="ex2") throw new Test262Error('#1.3: Exception !== "ex2". Actual: catch previous embedded exception'); 24 } 25 26 // CHECK#2 27 try{ 28 try{ 29 throw "ex1"; 30 } 31 catch(er1){ 32 if (er1!=="ex1") throw new Test262Error('#2.1: Exception === "ex1". Actual: Exception ==='+er1 ); 33 try{ 34 throw "ex2"; 35 } 36 finally{ 37 throw "ex3"; 38 } 39 throw new Test262Error('#2.2: throw "ex1" lead to throwing exception'); 40 } 41 } 42 catch(er1){ 43 if (er1!=="ex3") throw new Test262Error('#2.3: Exception === "ex3". Actual: Exception ==='+er1 ); 44 } 45 46 // CHECK#3 47 try{ 48 try{ 49 throw "ex1"; 50 } 51 catch(er1){ 52 if (er1!=="ex1") throw new Test262Error('#3.1: Exception === "ex1". Actual: Exception ==='+er1 ); 53 } 54 finally{ 55 try{ 56 throw "ex2"; 57 } 58 finally{ 59 throw "ex3"; 60 } 61 } 62 } 63 catch(er1){ 64 if (er1!=="ex3") throw new Test262Error('#3.2: Exception === "ex3". Actual: Exception ==='+er1 ); 65 } 66 67 // CHECK#4 68 var c4=0; 69 try{ 70 try{ 71 throw "ex1"; 72 } 73 catch(er1){ 74 if (er1!=="ex1") throw new Test262Error('#4.1: Exception === "ex1". Actual: Exception ==='+er1 ); 75 try{ 76 throw "ex2"; 77 } 78 finally{ 79 throw "ex3"; 80 } 81 } 82 finally{ 83 c4=1; 84 } 85 } 86 catch(er1){ 87 if (er1!=="ex3") throw new Test262Error('#4.2: Exception === "ex3". Actual: Exception ==='+er1 ); 88 } 89 if (c4!==1) throw new Test262Error('#4.3: "finally" block must be evaluated'); 90 91 // CHECK#5 92 var c5=0; 93 try{ 94 try{ 95 throw "ex2"; 96 } 97 finally{ 98 throw "ex3"; 99 } 100 throw "ex1"; 101 } 102 catch(er1){ 103 if (er1!=="ex3") throw new Test262Error('#5.1: Exception === "ex3". Actual: Exception ==='+er1 ); 104 if (er1==="ex2") throw new Test262Error('#5.2: Exception !== "ex2". Actual: catch previous embedded exception'); 105 if (er1==="ex1") throw new Test262Error('#5.3: Exception !=="ex1". Actual: catch previous embedded exception'); 106 } 107 finally{ 108 c5=1; 109 } 110 if (c5!==1) throw new Test262Error('#5.4: "finally" block must be evaluated'); 111 112 // CHECK#6 113 var c6=0; 114 try{ 115 try{ 116 try{ 117 throw "ex1"; 118 } 119 finally{ 120 throw "ex2"; 121 } 122 } 123 finally{ 124 c6=1; 125 } 126 } 127 catch(er1){ 128 if (er1!=="ex2") throw new Test262Error('#6.1: Exception === "ex2". Actual: Exception ==='+er1 ); 129 } 130 if (c6!==1) throw new Test262Error('#6.2: "finally" block must be evaluated'); 131 132 // CHECK#7 133 var c7=0; 134 try{ 135 try{ 136 throw "ex1"; 137 } 138 finally{ 139 try{ 140 c7=1; 141 throw "ex2"; 142 } 143 finally{ 144 c7++; 145 throw "ex3"; 146 } 147 } 148 } 149 catch(er1){ 150 if (er1!=="ex3") throw new Test262Error('#7.1: Exception === "ex3". Actual: Exception ==='+er1 ); 151 } 152 if (c7!==2) throw new Test262Error('#7.2: Embedded "try/finally" blocks must be evaluated'); 153 154 reportCompare(0, 0);