1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/test262/ch12/12.14/S12.14_A9_T3.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,158 @@ 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 + * "try" with "catch" or "finally" statement within/without an "do while" statement 1.9 + * 1.10 + * @path ch12/12.14/S12.14_A9_T3.js 1.11 + * @description "try" statement within a loop, the statement contains "break" statement 1.12 + */ 1.13 + 1.14 +// CHECK#1 1.15 +var c1=0,fin=0; 1.16 +do{ 1.17 + try{ 1.18 + c1+=1; 1.19 + break; 1.20 + } 1.21 + catch(er1){} 1.22 + finally{ 1.23 + fin=1; 1.24 + } 1.25 + fin=-1; 1.26 + c1+=2; 1.27 +} 1.28 +while(c1<2); 1.29 +if(fin!==1){ 1.30 + $ERROR('#1.1: "finally" block must be evaluated'); 1.31 +} 1.32 +if(c1!==1){ 1.33 + $ERROR('#1.2: "try{break}catch finally" must work correctly'); 1.34 +} 1.35 + 1.36 +// CHECK#2 1.37 +var c2=0,fin2=0; 1.38 +do{ 1.39 + try{ 1.40 + throw "ex1"; 1.41 + } 1.42 + catch(er1){ 1.43 + c2+=1; 1.44 + break; 1.45 + } 1.46 + finally{ 1.47 + fin2=1; 1.48 + } 1.49 + c2+=2; 1.50 + fin2=-1; 1.51 +} 1.52 +while(c2<2); 1.53 +if(fin2!==1){ 1.54 + $ERROR('#2.1: "finally" block must be evaluated'); 1.55 +} 1.56 +if(c2!==1){ 1.57 + $ERROR('#2.2: "try catch{break} finally" must work correctly'); 1.58 +} 1.59 + 1.60 +// CHECK#3 1.61 +var c3=0,fin3=0; 1.62 +do{ 1.63 + try{ 1.64 + throw "ex1"; 1.65 + } 1.66 + catch(er1){ 1.67 + c3+=1; 1.68 + } 1.69 + finally{ 1.70 + fin3=1; 1.71 + break; 1.72 + } 1.73 + c3+=2; 1.74 + fin3=0; 1.75 +} 1.76 +while(c3<2); 1.77 +if(fin3!==1){ 1.78 + $ERROR('#3.1: "finally" block must be evaluated'); 1.79 +} 1.80 +if(c3!==1){ 1.81 + $ERROR('#3.2: "try catch finally{break}" must work correctly'); 1.82 +} 1.83 + 1.84 +// CHECK#4 1.85 +var c4=0,fin4=0; 1.86 +do{ 1.87 + try{ 1.88 + c4+=1; 1.89 + break; 1.90 + } 1.91 + finally{ 1.92 + fin4=1; 1.93 + } 1.94 + fin4=-1; 1.95 + c4+=2; 1.96 +} 1.97 +while(c4<2); 1.98 +if(fin4!==1){ 1.99 + $ERROR('#4.1: "finally" block must be evaluated'); 1.100 +} 1.101 +if(c4!==1){ 1.102 + $ERROR('#4.2: "try{break} finally" must work correctly'); 1.103 +} 1.104 + 1.105 +// CHECK#5 1.106 +var c5=0; 1.107 +do{ 1.108 + try{ 1.109 + throw "ex1"; 1.110 + } 1.111 + catch(er1){ 1.112 + break; 1.113 + } 1.114 +} 1.115 +while(c5<2); 1.116 +if(c5!==0){ 1.117 + $ERROR('#5: "try catch{break}" must work correctly'); 1.118 +} 1.119 + 1.120 +// CHECK#6 1.121 +var c6=0; 1.122 +do{ 1.123 + try{ 1.124 + c6+=1; 1.125 + break; 1.126 + } 1.127 + catch(er1){} 1.128 + c6+=2; 1.129 +} 1.130 +while(c6<2); 1.131 +if(c6!==1){ 1.132 + $ERROR('#6: "try{break} catch" must work correctly'); 1.133 +} 1.134 + 1.135 +// CHECK#7 1.136 +var c7=0,fin7=0; 1.137 +try{ 1.138 + do{ 1.139 + try{ 1.140 + c7+=1; 1.141 + throw "ex1"; 1.142 + } 1.143 + finally{ 1.144 + fin7=1; 1.145 + break; 1.146 + } 1.147 + fin7=-1; 1.148 + c7+=2; 1.149 + } 1.150 + while(c7<2); 1.151 +} 1.152 +catch(ex1){ 1.153 + c7=10; 1.154 +} 1.155 +if(fin7!==1){ 1.156 + $ERROR('#7.1: "finally" block must be evaluated'); 1.157 +} 1.158 +if(c7!==1){ 1.159 + $ERROR('#7.2: try finally{break} error'); 1.160 +} 1.161 +