S12.14_A11_T3.js (2419B)
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 Using "try" with "catch" or "finally" statement within/without a "for" 7 statement 8 es5id: 12.14_A11_T3 9 description: Try statement inside loop, where use break 10 ---*/ 11 12 // CHECK#1 13 var c1=0,fin=0; 14 for(var i=0;i<5;i++){ 15 try{ 16 c1+=1; 17 break; 18 } 19 catch(er1){} 20 finally{ 21 fin=1; 22 } 23 fin=-1; 24 c1+=2; 25 }; 26 if(fin!==1){ 27 throw new Test262Error('#1.1: "finally" block must be evaluated'); 28 } 29 if(c1!==1){ 30 throw new Test262Error('#1.2: "try{break}catch finally" must work correctly'); 31 } 32 33 // CHECK#2 34 var c2=0,fin2=0; 35 for(var i=0;i<5;i++){ 36 try{ 37 throw "ex1"; 38 } 39 catch(er1){ 40 c2+=1; 41 break; 42 } 43 finally{ 44 fin2=1; 45 } 46 c2+=2; 47 fin2=-1; 48 }; 49 if(fin2!==1){ 50 throw new Test262Error('#2.1: "finally" block must be evaluated'); 51 } 52 if(c2!==1){ 53 throw new Test262Error('#2.2: "try catch{break} finally" must work correctly'); 54 } 55 56 // CHECK#3 57 var c3=0,fin3=0; 58 for(var i=0;i<5;i++){ 59 try{ 60 throw "ex1"; 61 } 62 catch(er1){ 63 c3+=1; 64 } 65 finally{ 66 fin3=1; 67 break; 68 } 69 c3+=2; 70 fin3=0; 71 }; 72 if(fin3!==1){ 73 throw new Test262Error('#3.1: "finally" block must be evaluated'); 74 } 75 if(c3!==1){ 76 throw new Test262Error('#3.2: "try catch finally{break}" must work correctly'); 77 } 78 79 // CHECK#4 80 var c4=0,fin4=0; 81 for(var i=0;i<5;i++){ 82 try{ 83 c4+=1; 84 break; 85 } 86 finally{ 87 fin4=1; 88 } 89 fin4=-1; 90 c4+=2; 91 }; 92 if(fin4!==1){ 93 throw new Test262Error('#4.1: "finally" block must be evaluated'); 94 } 95 if(c4!==1){ 96 throw new Test262Error('#4.2: "try{break} finally" must work correctly'); 97 } 98 99 // CHECK#5 100 for(var i=0;i<5;i++){ 101 try{ 102 throw "ex1"; 103 } 104 catch(er1){ 105 break; 106 } 107 }; 108 if(i!==0){ 109 throw new Test262Error('#5: "try catch{break}" must work correctly'); 110 } 111 112 // CHECK#6 113 var c6=0; 114 for(var c6=0;c6<5;){ 115 try{ 116 c6+=1; 117 break; 118 } 119 catch(er1){} 120 c6+=2; 121 }; 122 if(c6!==1){ 123 throw new Test262Error('#6: "try{break} catch" must work correctly'); 124 } 125 126 // CHECK#7 127 var c7=0,fin7=0; 128 try{ 129 for(var c7=0;c7<5;){ 130 try{ 131 c7+=1; 132 throw "ex1"; 133 } 134 finally{ 135 fin7=1; 136 break; 137 } 138 fin7=-1; 139 c7+=2; 140 } 141 } 142 catch(ex1){ 143 c7=10; 144 } 145 if(fin7!==1){ 146 throw new Test262Error('#7.1: "finally" block must be evaluated'); 147 } 148 if(c7!==1){ 149 throw new Test262Error('#7.2: "try finally{break}" must work correctly'); 150 } 151 152 reportCompare(0, 0);