1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A12_T2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,132 @@ 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-in" statement 1.9 + * 1.10 + * @path ch12/12.14/S12.14_A12_T2.js 1.11 + * @description Try statement inside loop, where use continue loop 1.12 + */ 1.13 + 1.14 +var x; 1.15 +var mycars = new Array(); 1.16 +mycars[0] = "Saab"; 1.17 +mycars[1] = "Volvo"; 1.18 +mycars[2] = "BMW"; 1.19 + 1.20 +// CHECK#1 1.21 +var fin=0; 1.22 +var i=0; 1.23 +for (x in mycars){ 1.24 + try{ 1.25 + i+=1; 1.26 + continue; 1.27 + } 1.28 + catch(er1){} 1.29 + finally{ 1.30 + fin=1; 1.31 + } 1.32 + fin=-1; 1.33 +} 1.34 +if(fin!==1){ 1.35 + $ERROR('#1.1: "finally" block must be evaluated'); 1.36 +} 1.37 +if(i!==3){ 1.38 + $ERROR('#1.2: "try{continue} catch finally" must work correctly'); 1.39 +} 1.40 + 1.41 +// CHECK#2 1.42 +var c2=0,fin2=0; 1.43 +for (x in mycars){ 1.44 + try{ 1.45 + throw "ex1"; 1.46 + } 1.47 + catch(er1){ 1.48 + c2+=1; 1.49 + continue; 1.50 + } 1.51 + finally{ 1.52 + fin2=1; 1.53 + } 1.54 + fin2=-1; 1.55 +} 1.56 +if(fin2!==1){ 1.57 + $ERROR('#2.1: "finally" block must be evaluated'); 1.58 +} 1.59 +if(c2!==3){ 1.60 + $ERROR('#2.1: "try catch{continue} finally" must work correctly'); 1.61 +} 1.62 + 1.63 +// CHECK#3 1.64 +var c3=0,fin3=0; 1.65 +for (x in mycars){ 1.66 + try{ 1.67 + throw "ex1"; 1.68 + } 1.69 + catch(er1){ 1.70 + c3+=1; 1.71 + } 1.72 + finally{ 1.73 + fin3=1; 1.74 + continue; 1.75 + } 1.76 + fin3=0; 1.77 +} 1.78 +if(c3!==3){ 1.79 + $ERROR('#3.1: "finally" block must be evaluated'); 1.80 +} 1.81 +if(fin3!==1){ 1.82 + $ERROR('#3.2: "try catch finally{continue}" must work correctly'); 1.83 +} 1.84 + 1.85 +// CHECK#4 1.86 +var fin=0; 1.87 +for (x in mycars){ 1.88 + try{ 1.89 + continue; 1.90 + } 1.91 + finally{ 1.92 + fin=1; 1.93 + } 1.94 + fin=-1; 1.95 +} 1.96 +if(fin!==1){ 1.97 + $ERROR('#4: "finally" block must be evaluated at "try{continue} finally" construction'); 1.98 +} 1.99 + 1.100 +// CHECK#5 1.101 +var c5=0; 1.102 +for (x in mycars){ 1.103 + try{ 1.104 + throw "ex1"; 1.105 + } 1.106 + catch(er1){ 1.107 + c5+=1; 1.108 + continue; 1.109 + } 1.110 + c5+=12; 1.111 +} 1.112 +if(c5!==3){ 1.113 + $ERROR('#5: "try catch{continue}" must work correctly'); 1.114 +} 1.115 + 1.116 +// CHECK#6 1.117 +var c6=0,fin6=0; 1.118 +for (x in mycars){ 1.119 + try{ 1.120 + c6+=1; 1.121 + throw "ex1"; 1.122 + } 1.123 + finally{ 1.124 + fin6=1; 1.125 + continue; 1.126 + } 1.127 + fin6=-1; 1.128 +} 1.129 +if(fin6!==1){ 1.130 + $ERROR('#6.1: "finally" block must be evaluated'); 1.131 +} 1.132 +if(c6!==3){ 1.133 + $ERROR('#6.2: "try finally{continue}" must work correctly'); 1.134 +} 1.135 +