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: * "try" with "catch" or "finally" statement within/without an "do while" statement michael@0: * michael@0: * @path ch12/12.14/S12.14_A9_T3.js michael@0: * @description "try" statement within a loop, the statement contains "break" statement michael@0: */ michael@0: michael@0: // CHECK#1 michael@0: var c1=0,fin=0; michael@0: do{ 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: } michael@0: fin=-1; michael@0: c1+=2; michael@0: } michael@0: while(c1<2); michael@0: if(fin!==1){ michael@0: $ERROR('#1.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c1!==1){ michael@0: $ERROR('#1.2: "try{break}catch finally" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: var c2=0,fin2=0; michael@0: do{ 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: } michael@0: c2+=2; michael@0: fin2=-1; michael@0: } michael@0: while(c2<2); michael@0: if(fin2!==1){ michael@0: $ERROR('#2.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c2!==1){ michael@0: $ERROR('#2.2: "try catch{break} finally" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#3 michael@0: var c3=0,fin3=0; michael@0: do{ 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: break; michael@0: } michael@0: c3+=2; michael@0: fin3=0; michael@0: } michael@0: while(c3<2); michael@0: if(fin3!==1){ michael@0: $ERROR('#3.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c3!==1){ michael@0: $ERROR('#3.2: "try catch finally{break}" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#4 michael@0: var c4=0,fin4=0; michael@0: do{ michael@0: try{ michael@0: c4+=1; michael@0: break; michael@0: } michael@0: finally{ michael@0: fin4=1; michael@0: } michael@0: fin4=-1; michael@0: c4+=2; michael@0: } michael@0: while(c4<2); michael@0: if(fin4!==1){ michael@0: $ERROR('#4.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c4!==1){ michael@0: $ERROR('#4.2: "try{break} finally" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#5 michael@0: var c5=0; michael@0: do{ michael@0: try{ michael@0: throw "ex1"; michael@0: } michael@0: catch(er1){ michael@0: break; michael@0: } michael@0: } michael@0: while(c5<2); michael@0: if(c5!==0){ michael@0: $ERROR('#5: "try catch{break}" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#6 michael@0: var c6=0; michael@0: do{ michael@0: try{ michael@0: c6+=1; michael@0: break; michael@0: } michael@0: catch(er1){} michael@0: c6+=2; michael@0: } michael@0: while(c6<2); michael@0: if(c6!==1){ michael@0: $ERROR('#6: "try{break} catch" must work correctly'); michael@0: } michael@0: michael@0: // CHECK#7 michael@0: var c7=0,fin7=0; michael@0: try{ michael@0: do{ michael@0: try{ michael@0: c7+=1; michael@0: throw "ex1"; michael@0: } michael@0: finally{ michael@0: fin7=1; michael@0: break; michael@0: } michael@0: fin7=-1; michael@0: c7+=2; michael@0: } michael@0: while(c7<2); michael@0: } michael@0: catch(ex1){ michael@0: c7=10; michael@0: } michael@0: if(fin7!==1){ michael@0: $ERROR('#7.1: "finally" block must be evaluated'); michael@0: } michael@0: if(c7!==1){ michael@0: $ERROR('#7.2: try finally{break} error'); michael@0: } michael@0: