S12.14_A12_T4.js (1176B)
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-in" 7 statement 8 es5id: 12.14_A12_T4 9 description: Try statement inside loop, where combinate using break and continue 10 ---*/ 11 12 var x; 13 var mycars = new Array(); 14 mycars[0] = "Saab"; 15 mycars[1] = "Volvo"; 16 mycars[2] = "BMW"; 17 18 // CHECK#1 19 var c1=0,fin=0; 20 for (x in mycars){ 21 try{ 22 c1+=1; 23 break; 24 } 25 catch(er1){} 26 finally{ 27 fin=1; 28 continue; 29 } 30 fin=-1; 31 c1+=2; 32 } 33 if(fin!==1){ 34 throw new Test262Error('#1.1: "finally" block must be evaluated'); 35 } 36 if(c1!==3){ 37 throw new Test262Error('#1.2: "try{break} catch finally{continue}" must work correctly'); 38 } 39 40 // CHECK#2 41 var c2=0,fin2=0; 42 for (x in mycars){ 43 try{ 44 throw "ex1"; 45 } 46 catch(er1){ 47 c2+=1; 48 break; 49 } 50 finally{ 51 fin2=1; 52 continue; 53 } 54 c2+=2; 55 fin2=-1; 56 } 57 if(fin2!==1){ 58 throw new Test262Error('#2.1: "finally" block must be evaluated'); 59 } 60 if(c2!==3){ 61 throw new Test262Error('#2.2: "try catch{break} finally{continue}" must work correctly'); 62 } 63 64 reportCompare(0, 0);