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_T4.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 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_T4.js 1.11 + * @description Try statement inside loop, where combinate using break and continue 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 c1=0,fin=0; 1.22 +for (x in mycars){ 1.23 + try{ 1.24 + c1+=1; 1.25 + break; 1.26 + } 1.27 + catch(er1){} 1.28 + finally{ 1.29 + fin=1; 1.30 + continue; 1.31 + } 1.32 + fin=-1; 1.33 + c1+=2; 1.34 +} 1.35 +if(fin!==1){ 1.36 + $ERROR('#1.1: "finally" block must be evaluated'); 1.37 +} 1.38 +if(c1!==3){ 1.39 + $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly'); 1.40 +} 1.41 + 1.42 +// CHECK#2 1.43 +var c2=0,fin2=0; 1.44 +for (x in mycars){ 1.45 + try{ 1.46 + throw "ex1"; 1.47 + } 1.48 + catch(er1){ 1.49 + c2+=1; 1.50 + break; 1.51 + } 1.52 + finally{ 1.53 + fin2=1; 1.54 + continue; 1.55 + } 1.56 + c2+=2; 1.57 + fin2=-1; 1.58 +} 1.59 +if(fin2!==1){ 1.60 + $ERROR('#2.1: "finally" block must be evaluated'); 1.61 +} 1.62 +if(c2!==3){ 1.63 + $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly'); 1.64 +} 1.65 +