michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * Using "try" with "catch" or "finally" statement within/without a "for-in" statement michael@0: * michael@0: * @path ch12/12.14/S12.14_A12_T4.js michael@0: * @description Try statement inside loop, where combinate using break and continue michael@0: */ michael@0: michael@0: var x; michael@0: var mycars = new Array(); michael@0: mycars[0] = "Saab"; michael@0: mycars[1] = "Volvo"; michael@0: mycars[2] = "BMW"; michael@0: michael@0: // CHECK#1 michael@0: var c1=0,fin=0; michael@0: for (x in mycars){ michael@0: try{ michael@0: c1+=1; michael@0: break; michael@0: } michael@0: catch(er1){} michael@0: finally{ michael@0: fin=1; michael@0: continue; michael@0: } michael@0: fin=-1; michael@0: c1+=2; michael@0: } michael@0: if(fin!==1){ michael@0: $ERROR('#1.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c1!==3){ michael@0: $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: var c2=0,fin2=0; michael@0: for (x in mycars){ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: c2+=1; michael@0: break; michael@0: } michael@0: finally{ michael@0: fin2=1; michael@0: continue; michael@0: } michael@0: c2+=2; michael@0: fin2=-1; michael@0: } michael@0: if(fin2!==1){ michael@0: $ERROR('#2.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c2!==3){ michael@0: $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly'); michael@0: } michael@0: