1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A11_T2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,123 @@ 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 "for" statement 1.9 + * 1.10 + * @path ch12/12.14/S12.14_A11_T2.js 1.11 + * @description Try statement inside loop, where use continue loop 1.12 + */ 1.13 + 1.14 +// CHECK#1 1.15 +var fin=0; 1.16 +for(var i=0;i<5;i++){ 1.17 + try{ 1.18 + i+=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 +for(var i=0;i<5;i++){ 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.1: "finally" block must be evaluated'); 1.48 +} 1.49 +if(c2!==5){ 1.50 + $ERROR('#2.1: "try catch{continue} finally" must work correctly'); 1.51 +} 1.52 + 1.53 +// CHECK#3 1.54 +var c3=0,fin3=0; 1.55 +for(var i=0;i<5;i++){ 1.56 + try{ 1.57 + throw "ex1"; 1.58 + } 1.59 + catch(er1){ 1.60 + c3+=1; 1.61 + } 1.62 + finally{ 1.63 + fin3=1; 1.64 + continue; 1.65 + } 1.66 + fin3=0; 1.67 +} 1.68 +if(fin3!==1){ 1.69 + $ERROR('#3.1: "finally" block must be evaluated'); 1.70 +} 1.71 +if(c3!==5){ 1.72 + $ERROR('#3.2: "try catch finally{continue}" must work correctly'); 1.73 +} 1.74 + 1.75 +// CHECK#4 1.76 +var fin=0; 1.77 +for(var i=0;i<5;i++){ 1.78 + try{ 1.79 + i+=1; 1.80 + continue; 1.81 + } 1.82 + finally{ 1.83 + fin=1; 1.84 + } 1.85 + fin=-1; 1.86 +}; 1.87 +if(fin!==1){ 1.88 + $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); 1.89 +} 1.90 + 1.91 +// CHECK#5 1.92 +var c5=0; 1.93 +for(var c5=0;c5<10;){ 1.94 + try{ 1.95 + throw "ex1"; 1.96 + } 1.97 + catch(er1){ 1.98 + c5+=1; 1.99 + continue; 1.100 + } 1.101 + c5+=12; 1.102 +}; 1.103 +if(c5!==10){ 1.104 + $ERROR('#5: "try catch{continue} must work correctly'); 1.105 +} 1.106 + 1.107 +// CHECK#6 1.108 +var c6=0,fin6=0; 1.109 +for(var c6=0;c6<10;){ 1.110 + try{ 1.111 + c6+=1; 1.112 + throw "ex1" 1.113 + } 1.114 + finally{ 1.115 + fin6=1; 1.116 + continue; 1.117 + } 1.118 + fin6=-1; 1.119 +}; 1.120 +if(fin6!==1){ 1.121 + $ERROR('#6.1: "finally" block must be evaluated'); 1.122 +} 1.123 +if(c6!==10){ 1.124 + $ERROR('#6.2: "try finally{continue}" must work correctly'); 1.125 +} 1.126 +