S12.14_A10_T3.js (2365B)
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 "while" 7 statement 8 es5id: 12.14_A10_T3 9 description: Try statement inside loop, where use break 10 ---*/ 11 12 // CHECK#1 13 var c1=0,fin=0; 14 while(c1<2){ 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 while(c2<2){ 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 while(c3<2){ 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 while(c4<2){ 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 var c5=0; 101 while(c5<2){ 102 try{ 103 throw "ex1"; 104 } 105 catch(er1){ 106 break; 107 } 108 } 109 if(c5!==0){ 110 throw new Test262Error('#5: "try catch{break}" must work correctly'); 111 } 112 113 // CHECK#6 114 var c6=0; 115 while(c6<2){ 116 try{ 117 c6+=1; 118 break; 119 } 120 catch(er1){} 121 c6+=2; 122 } 123 if(c6!==1){ 124 throw new Test262Error('#6: "try{break} catch" must work correctly'); 125 } 126 127 // CHECK#7 128 var c7=0,fin7=0; 129 try{ 130 while(c7<2){ 131 try{ 132 c7+=1; 133 throw "ex1"; 134 } 135 finally{ 136 fin7=1; 137 break; 138 } 139 fin7=-1; 140 c7+=2; 141 } 142 } 143 catch(ex1){ 144 c7=10; 145 } 146 if(fin7!==1){ 147 throw new Test262Error('#7.1: "finally" block must be evaluated'); 148 } 149 if(c7!==1){ 150 throw new Test262Error('#7.2: "try finally{break}" must work correctly'); 151 } 152 153 reportCompare(0, 0);