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" statement michael@0: * michael@0: * @path ch12/12.14/S12.14_A11_T2.js michael@0: * @description Try statement inside loop, where use continue loop michael@0: */ michael@0: michael@0: // CHECK#1 michael@0: var fin=0; michael@0: for(var i=0;i<5;i++){ michael@0: try{ michael@0: i+=1; michael@0: continue; michael@0: } michael@0: catch(er1){} michael@0: finally{ michael@0: fin=1; michael@0: } michael@0: fin=-1; michael@0: } michael@0: if(fin!==1){ michael@0: $ERROR('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: var c2=0,fin2=0; michael@0: for(var i=0;i<5;i++){ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: c2+=1; michael@0: continue; michael@0: } michael@0: finally{ michael@0: fin2=1; michael@0: } 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!==5){ michael@0: $ERROR('#2.1: "try catch{continue} finally" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#3 michael@0: var c3=0,fin3=0; michael@0: for(var i=0;i<5;i++){ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: c3+=1; michael@0: } michael@0: finally{ michael@0: fin3=1; michael@0: continue; michael@0: } michael@0: fin3=0; michael@0: } michael@0: if(fin3!==1){ michael@0: $ERROR('#3.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c3!==5){ michael@0: $ERROR('#3.2: "try catch finally{continue}" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#4 michael@0: var fin=0; michael@0: for(var i=0;i<5;i++){ michael@0: try{ michael@0: i+=1; michael@0: continue; michael@0: } michael@0: finally{ michael@0: fin=1; michael@0: } michael@0: fin=-1; michael@0: }; michael@0: if(fin!==1){ michael@0: $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); michael@0: } michael@0: michael@0: // CHECK#5 michael@0: var c5=0; michael@0: for(var c5=0;c5<10;){ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: c5+=1; michael@0: continue; michael@0: } michael@0: c5+=12; michael@0: }; michael@0: if(c5!==10){ michael@0: $ERROR('#5: "try catch{continue} must work correctly'); michael@0: } michael@0: michael@0: // CHECK#6 michael@0: var c6=0,fin6=0; michael@0: for(var c6=0;c6<10;){ michael@0: try{ michael@0: c6+=1; michael@0: throw "ex1" michael@0: } michael@0: finally{ michael@0: fin6=1; michael@0: continue; michael@0: } michael@0: fin6=-1; michael@0: }; michael@0: if(fin6!==1){ michael@0: $ERROR('#6.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c6!==10){ michael@0: $ERROR('#6.2: "try finally{continue}" must work correctly'); michael@0: } michael@0: