S12.14_A10_T4.js (1070B)
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_T4 9 description: Try statement inside loop, where combinate using break and continue 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 continue; 23 } 24 fin=-1; 25 c1+=2; 26 } 27 if(fin!==1){ 28 throw new Test262Error('#1.1: "finally" block must be evaluated'); 29 } 30 if(c1!==2){ 31 throw new Test262Error('#1.2: "try{break} catch finally{continue}" must work correctly'); 32 } 33 34 // CHECK#2 35 var c2=0,fin2=0; 36 while(c2<2){ 37 try{ 38 throw "ex1"; 39 } 40 catch(er1){ 41 c2+=1; 42 break; 43 } 44 finally{ 45 fin2=1; 46 continue; 47 } 48 c2+=2; 49 fin2=-1; 50 } 51 if(fin2!==1){ 52 throw new Test262Error('#2.1: "finally" block must be evaluated'); 53 } 54 if(c2!==2){ 55 throw new Test262Error('#2.2: "try catch{break} finally{continue} must work correctly'); 56 } 57 58 reportCompare(0, 0);