1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A10_T2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,116 @@ 1.4 +// Copyright 2009 the Sputnik authors. All rights reserved. 1.5 +// This code is governed by the BSD license found in the LICENSE file. 1.6 + 1.7 +/** 1.8 + * Using "try" with "catch" or "finally" statement within/without a "while" statement 1.9 + * 1.10 + * @path ch12/12.14/S12.14_A10_T2.js 1.11 + * @description Try statement inside loop, where use continue loop 1.12 + */ 1.13 + 1.14 +// CHECK#1 1.15 +var c1=0,fin=0; 1.16 +while(c1<2){ 1.17 + try{ 1.18 + c1+=1; 1.19 + continue; 1.20 + } 1.21 + catch(er1){} 1.22 + finally{ 1.23 + fin=1; 1.24 + } 1.25 + fin=-1; 1.26 +}; 1.27 +if(fin!==1){ 1.28 + $ERROR('#1: "finally" block must be evaluated at "try{continue} catch finally" construction'); 1.29 +} 1.30 + 1.31 +// CHECK#2 1.32 +var c2=0,fin2=0; 1.33 +while(c2<2){ 1.34 + try{ 1.35 + throw "ex1"; 1.36 + } 1.37 + catch(er1){ 1.38 + c2+=1; 1.39 + continue; 1.40 + } 1.41 + finally{ 1.42 + fin2=1; 1.43 + } 1.44 + fin2=-1; 1.45 +} 1.46 +if(fin2!==1){ 1.47 + $ERROR('#2: "finally" block must be evaluated at "try catch{continue} finally" construction'); 1.48 +} 1.49 + 1.50 +// CHECK#3 1.51 +var c3=0,fin3=0; 1.52 +while(c3<2){ 1.53 + try{ 1.54 + throw "ex1"; 1.55 + } 1.56 + catch(er1){ 1.57 + c3+=1; 1.58 + } 1.59 + finally{ 1.60 + fin3=1; 1.61 + continue; 1.62 + } 1.63 + fin3=0; 1.64 +} 1.65 +if(fin3!==1){ 1.66 + $ERROR('#3: "finally" block must be evaluated at "try catch finally{continue}" construction'); 1.67 +} 1.68 + 1.69 +// CHECK#4 1.70 +var c4=0,fin4=0; 1.71 +while(c4<2){ 1.72 + try{ 1.73 + c4+=1; 1.74 + continue; 1.75 + } 1.76 + finally{ 1.77 + fin4=1; 1.78 + } 1.79 + fin4=-1; 1.80 +}; 1.81 +if(fin4!==1){ 1.82 + $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); 1.83 +} 1.84 + 1.85 +// CHECK#5 1.86 +var c5=0; 1.87 +while(c5<2){ 1.88 + try{ 1.89 + throw "ex1"; 1.90 + } 1.91 + catch(er1){ 1.92 + c5+=1; 1.93 + continue; 1.94 + } 1.95 +} 1.96 +if(c5!==2){ 1.97 + $ERROR('#5: "try catch{continue}" must work correctly'); 1.98 +} 1.99 + 1.100 +// CHECK#6 1.101 +var c6=0,fin6=0; 1.102 +while(c6<2){ 1.103 + try{ 1.104 + c6+=1; 1.105 + throw "ex1" 1.106 + } 1.107 + finally{ 1.108 + fin6=1; 1.109 + continue; 1.110 + } 1.111 + fin6=-1; 1.112 +} 1.113 +if(fin6!==1){ 1.114 + $ERROR('#6.1: "finally" block must be evaluated'); 1.115 +} 1.116 +if(c6!==2){ 1.117 + $ERROR('#6.2: "try finally{continue}" must work correctly'); 1.118 +} 1.119 +