js/src/tests/test262/ch12/12.14/S12.14_A11_T4.js

changeset 0
6474c204b198
     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_T4.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,56 @@
     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_T4.js
    1.11 + * @description Try statement inside loop, where combinate using break and continue
    1.12 + */
    1.13 +
    1.14 +// CHECK#1
    1.15 +var c1=0,fin=0;
    1.16 +for(var i=0;i<5;i++){
    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 +    continue;
    1.25 +  }
    1.26 +  fin=-1;
    1.27 +  c1+=2;
    1.28 +}
    1.29 +if(fin!==1){
    1.30 +  $ERROR('#1.1: "finally" block must be evaluated');
    1.31 +}
    1.32 +if(c1!==5){
    1.33 +  $ERROR('#1.2: "try{break} catch finally{continue}" must work correctly');
    1.34 +}
    1.35 +
    1.36 +// CHECK#2
    1.37 +var c2=0,fin2=0;
    1.38 +for(var i=0;i<5;i++){
    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 +    continue;
    1.49 +  }
    1.50 +  c2+=2;
    1.51 +  fin2=-1;
    1.52 +}
    1.53 +if(fin2!==1){
    1.54 +  $ERROR('#2.1: "finally" block must be evaluated');
    1.55 +}
    1.56 +if(c2!==5){
    1.57 +  $ERROR('#2.2: "try catch{break} finally{continue}" must work correctly');
    1.58 +}
    1.59 +

mercurial